| POST | /quote | Provide waypoints for a route and return a quote. |
|---|
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 RequestQuoteResponse(ApiServiceResponse):
# @ApiMember(Description="Is there an issue for the waypoints details specified?")
waypoint_issue: bool = False
"""
Is there an issue for the waypoints details specified?
"""
# @ApiMember(Description="Is the quote created successfully and ready to be placed as an order?")
quote_ready: bool = False
"""
Is the quote created successfully and ready to be placed as an order?
"""
# @ApiMember(Description="Is the quote expired?")
quote_expired: bool = False
"""
Is the quote expired?
"""
# @ApiMember(Description="The total distance for the quote")
total_distance: float = 0.0
"""
The total distance for the quote
"""
# @ApiMember(Description="The total distance for the quote, formatted as a string")
total_distance_value: Optional[str] = None
"""
The total distance for the quote, 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 might be a problem with a scheduled quote")
scheduling_notice: Optional[str] = None
"""
Will contain a message if there might be a problem with a scheduled quote
"""
# @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="The ID of the generated quote, needed when you want to change this quote later")
quote_id: Optional[str] = None
"""
The ID of the generated quote, needed when you want to change this quote later
"""
# @ApiMember(Description="User friendly waybill number")
way_bill: Optional[str] = None
"""
User friendly waybill number
"""
# @ApiMember(Description="The date this order was created")
date_created: Optional[str] = None
"""
The date this order was created
"""
# @ApiMember(Description="The date this quote was last changed")
last_updated: Optional[str] = None
"""
The date this quote was last changed
"""
# @ApiMember(Description="List of quote information for pricing etc between each waypoint")
waypoints: Optional[List[WaypointQuoteInformation]] = None
"""
List of quote 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 RequestQuote(ApiServiceRequest, ILogRequest):
# @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="Specify a quote Id to amend a quote. Required when amending an existing quote.")
quote_id: Optional[str] = None
"""
Specify a quote Id to amend a quote. Required when amending an existing quote.
"""
# @ApiMember(Description="Set this to true to prevent creating the quote", IsRequired=true)
test: bool = False
"""
Set this to true to prevent creating the quote
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /quote HTTP/1.1
Host: 1fetch.api.client.prod.86degrees.com
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"Waypoints":[{"WaypointNumber":0,"Latitude":0,"Longitude":0,"ContactName":"String","ContactNumber":"String","DeliveryInstructions":"String","Address":"String"}],"IsScheduled":false,"ScheduleType":0,"ScheduledDate":"String","QuoteId":"00000000-0000-0000-0000-000000000000","Test":false,"ApiKey":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{Unable to show example output for type 'RequestQuoteResponse' using the custom 'csv' filter}One or more errors occurred. (Object reference not set to an instance of an object.)