| POST | /order | Provide waypoints for a route and place an order. This will bill the order to your account. |
|---|
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 ApiServiceRequest(IServiceRequest, IHasApiKey):
# @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
api_key: Optional[str] = None
"""
The API Key required for authentication
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ApiServiceResponse(IServiceResponse):
# @ApiMember(Description="Information about the response.", IsRequired=true)
description: Optional[str] = None
"""
Information about the response.
"""
# @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
heading: Optional[str] = None
"""
Heading or summary of the response.
"""
# @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
was_successful: bool = False
"""
Did the intended operation for this response complete successfully?
"""
@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 PlaceOrderResponse(ApiServiceResponse):
# @ApiMember(Description="The ID of the order.")
order_id: Optional[str] = None
"""
The ID of the order.
"""
# @ApiMember(Description="Were there any validation issues for any waypoints")
waypoint_issue: bool = False
"""
Were there any validation issues for any waypoints
"""
# @ApiMember(Description="The total distance for the order")
total_distance: float = 0.0
"""
The total distance for the order
"""
# @ApiMember(Description="The total distance for the order, formatted as a string")
total_distance_value: Optional[str] = None
"""
The total distance for the order, formatted as a string
"""
# @ApiMember(Description="The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true")
scheduled_date: Optional[str] = None
"""
The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true
"""
# @ApiMember(Description="The subtotal of the order before VAT")
sub_total: Optional[str] = None
"""
The subtotal of the order before VAT
"""
# @ApiMember(Description="The total of the order after VAT")
final_price: Optional[str] = None
"""
The total of the order after VAT
"""
# @ApiMember(Description="The amount of VAT ")
vat_value: Optional[str] = None
"""
The amount of VAT
"""
# @ApiMember(Description="Will contain a message if there a problem with a scheduled order")
scheduling_notice: Optional[str] = None
"""
Will contain a message if there a problem with a scheduled order
"""
# @ApiMember(Description="Will contain a message if there is a problem with a scheduled quote, if the order is scheduled to soon to opening times")
scheduling_error: Optional[str] = None
"""
Will contain a message if there is a problem with a scheduled quote, if the order is scheduled to soon to opening times
"""
# @ApiMember(Description="User friendly waybill number")
way_bill: Optional[str] = None
"""
User friendly waybill number
"""
# @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
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RequestQuoteWaypoint(IRequestWaypoint):
# @ApiMember(Description="Number of waypoint for ordering", IsRequired=true)
waypoint_number: int = 0
"""
Number of waypoint for ordering
"""
# @ApiMember(Description="Waypoint Latitude", IsRequired=true)
latitude: float = 0.0
"""
Waypoint Latitude
"""
# @ApiMember(Description="Waypoint Longitude", IsRequired=true)
longitude: float = 0.0
"""
Waypoint Longitude
"""
# @ApiMember(Description="Name of contact person at waypoint", IsRequired=true)
contact_name: Optional[str] = None
"""
Name of contact person at waypoint
"""
# @ApiMember(Description="Telephone number of contact person at waypoint", IsRequired=true)
contact_number: Optional[str] = None
"""
Telephone number of contact person at waypoint
"""
# @ApiMember(Description="Instructions for driver to follow at waypoint", IsRequired=true)
delivery_instructions: Optional[str] = None
"""
Instructions for driver to follow at waypoint
"""
# @ApiMember(Description="Waypoint address", IsRequired=true)
address: Optional[str] = None
"""
Waypoint address
"""
class ScheduleType(IntEnum):
NEXT_AVAILABLE = 0
SPECIFIC_TIME = 1
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PlaceOrder(ApiServiceRequest, ILogRequest):
# @ApiMember(Description="Optionally provide your own reference identifier")
client_reference: Optional[str] = None
"""
Optionally provide your own reference identifier
"""
# @ApiMember(Description="Optionally provide a reference for the customer/business")
customer_reference: Optional[str] = None
"""
Optionally provide a reference for the customer/business
"""
# @ApiMember(Description="Array of waypoints", IsRequired=true)
waypoints: Optional[List[RequestQuoteWaypoint]] = None
"""
Array of waypoints
"""
# @ApiMember(Description="Is this a scheduled order?", IsRequired=true)
is_scheduled: bool = False
"""
Is this a scheduled order?
"""
# @ApiMember(Description="Specify the scheduling type, required if IsScheduled is true")
schedule_type: Optional[ScheduleType] = None
"""
Specify the scheduling type, required if IsScheduled is true
"""
# @ApiMember(Description="Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime")
scheduled_date: Optional[str] = None
"""
Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime
"""
# @ApiMember(Description="Set this to true to prevent creating an order and billing for it", IsRequired=true)
test: bool = False
"""
Set this to true to prevent creating an order and billing for it
"""
# @ApiMember(Description="Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.")
is_urgent: bool = False
"""
Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /order HTTP/1.1
Host: 1fetch.api.client.prod.86degrees.com
Accept: application/json
Content-Type: application/json
Content-Length: length
{"ClientReference":"String","CustomerReference":"String","Waypoints":[{"WaypointNumber":0,"Latitude":0,"Longitude":0,"ContactName":"String","ContactNumber":"String","DeliveryInstructions":"String","Address":"String"}],"IsScheduled":false,"ScheduleType":0,"ScheduledDate":"String","Test":false,"IsUrgent":false,"ApiKey":"String"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"OrderId":"00000000-0000-0000-0000-000000000000","WaypointIssue":false,"TotalDistance":0,"TotalDistanceValue":"0","ScheduledDate":"String","SubTotal":"String","FinalPrice":"String","VATValue":"String","SchedulingNotice":"String","SchedulingError":"String","WayBill":"String","Waypoints":[{}],"WaypointValidations":[{}],"Description":"String","Heading":"String","WasSuccessful":false}