1Fetch Client API

<back to all web services

PicUpCreateShipmentRequest

The following routes are available for this service:
POST/picup/createshipment
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class LinkedWaypoint:
    from_waypoint_number: int = 0
    to_waypoint_number: int = 0
    from_latitude: float = 0.0
    from_longitude: float = 0.0
    to_latitude: float = 0.0
    to_longitude: float = 0.0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class WaypointQuoteInformation(LinkedWaypoint):
    # @ApiMember(Description="Distance between waypoints as a number")
    distance: float = 0.0
    """
    Distance between waypoints as a number
    """


    # @ApiMember(Description="String formatted distance")
    distance_value: Optional[str] = None
    """
    String formatted distance
    """


    waypoint_valid: bool = False
    message: Optional[str] = None
    error_details: Optional[List[str]] = None
    # @ApiMember(Description="Caculated price between waypoints excluding vat")
    price: Decimal = decimal.Decimal(0)
    """
    Caculated price between waypoints excluding vat
    """


    # @ApiMember(Description="Price excluding vat formatted as a string rand value")
    price_value: Optional[str] = None
    """
    Price excluding vat formatted as a string rand value
    """


    # @ApiMember(Description="The price between waypoints including vat")
    price_with_v_a_t: Decimal = decimal.Decimal(0)
    """
    The price between waypoints including vat
    """


    # @ApiMember(Description="The price including vat formatted as a rand value string")
    price_value_with_v_a_t: Optional[str] = None
    """
    The price including vat formatted as a rand value string
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class WaypointValidationInformation:
    waypoint_number: int = 0
    is_valid: bool = False
    error_messages: Optional[List[str]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PicUpCreateShipmentResponse:
    is_success: bool = False
    courier_reference: Optional[str] = None
    error: Optional[str] = None
    # @ApiMember(Description="List of order information for pricing etc between each waypoint")
    waypoints: Optional[List[WaypointQuoteInformation]] = None
    """
    List of order information for pricing etc between each waypoint
    """


    # @ApiMember(Description="List with validation information for each waypoint")
    waypoint_validations: Optional[List[WaypointValidationInformation]] = None
    """
    List with validation information for each waypoint
    """


    # @ApiMember(Description="The 1Fetch Waybill reference for the shipment")
    waybill: Optional[str] = None
    """
    The 1Fetch Waybill reference for the shipment
    """


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BucketDetails:
    delivery_date: datetime.datetime = datetime.datetime(1, 1, 1)


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CourierRequest:
    bucket_details: Optional[BucketDetails] = None
    shipments: Optional[List[Shipment]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PicUpCreateShipmentRequest(IHasApiKey, ILogRequest):
    api_key: Optional[str] = None
    courier_request: Optional[CourierRequest] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Address:
    address_line1: Optional[str] = None
    address_line2: Optional[str] = None
    address_line3: Optional[str] = None
    address_line4: Optional[str] = None
    city: Optional[str] = None
    formatted_address: Optional[str] = None
    latitude: float = 0.0
    longitude: float = 0.0
    postal_code: Optional[str] = None
    suburb: Optional[str] = None
    unit: Optional[str] = None
    building: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Contact:
    customer_name: Optional[str] = None
    customer_phone: Optional[str] = None
    email_address: Optional[str] = None
    special_instructions: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Sender:
    address: Optional[Address] = None
    contact: Optional[Contact] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Receiver:
    parcels: Optional[List[Parcel]] = None
    address: Optional[Address] = None
    contact: Optional[Contact] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Shipment:
    waybill_number: Optional[str] = None
    business_reference: Optional[str] = None
    service_type: Optional[str] = None
    sender: Optional[Sender] = None
    receiver: Optional[Receiver] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Parcel:
    parcel_waybill: Optional[str] = None
    parcel_reference: Optional[str] = None
    tracking_number: Optional[str] = None
    length_mm: int = 0
    width_mm: int = 0
    height_mm: int = 0
    weight_kg: int = 0

Python PicUpCreateShipmentRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /picup/createshipment HTTP/1.1 
Host: api.1fetch.co.za 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	ApiKey: String,
	courier_request: 
	{
		bucket_details: 
		{
			delivery_date: 0001-01-01T00:00:00.0000000+00:00
		},
		shipments: 
		[
			{
				waybill_number: String,
				business_reference: String,
				service_type: String,
				sender: 
				{
					address: 
					{
						address_line_1: String,
						address_line_2: String,
						address_line_3: String,
						address_line_4: String,
						city: String,
						formatted_address: String,
						latitude: 0,
						longitude: 0,
						postal_code: String,
						suburb: String,
						unit: String,
						building: String
					},
					contact: 
					{
						customer_name: String,
						customer_phone: String,
						email_address: String,
						special_instructions: String
					}
				},
				receiver: 
				{
					parcels: 
					[
						{
							parcel_waybill: String,
							parcel_reference: String,
							tracking_number: String,
							length_mm: 0,
							width_mm: 0,
							height_mm: 0,
							weight_kg: 0
						}
					],
					address: 
					{
						address_line_1: String,
						address_line_2: String,
						address_line_3: String,
						address_line_4: String,
						city: String,
						formatted_address: String,
						latitude: 0,
						longitude: 0,
						postal_code: String,
						suburb: String,
						unit: String,
						building: String
					},
					contact: 
					{
						customer_name: String,
						customer_phone: String,
						email_address: String,
						special_instructions: String
					}
				}
			}
		]
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	is_success: False,
	courier_reference: String,
	error: String,
	Waypoints: 
	[
		{
			
		}
	],
	WaypointValidations: 
	[
		{
			
		}
	],
	Waybill: String
}