| POST | /quote | Provide waypoints for a route and return a quote. |
|---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
class ApiServiceRequest implements IServiceRequest, IHasApiKey, JsonSerializable
{
public function __construct(
/** @description The API Key required for authentication */
// @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
/** @var string */
public string $ApiKey=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApiKey'])) $this->ApiKey = $o['ApiKey'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApiKey)) $o['ApiKey'] = $this->ApiKey;
return empty($o) ? new class(){} : $o;
}
}
class ApiServiceResponse implements IServiceResponse, JsonSerializable
{
public function __construct(
/** @description Information about the response. */
// @ApiMember(Description="Information about the response.", IsRequired=true)
/** @var string */
public string $Description='',
/** @description Heading or summary of the response. */
// @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
/** @var string */
public string $Heading='',
/** @description Did the intended operation for this response complete successfully? */
// @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
/** @var bool|null */
public ?bool $WasSuccessful=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Heading'])) $this->Heading = $o['Heading'];
if (isset($o['WasSuccessful'])) $this->WasSuccessful = $o['WasSuccessful'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Heading)) $o['Heading'] = $this->Heading;
if (isset($this->WasSuccessful)) $o['WasSuccessful'] = $this->WasSuccessful;
return empty($o) ? new class(){} : $o;
}
}
class LinkedWaypoint implements JsonSerializable
{
public function __construct(
/** @var int */
public int $FromWaypointNumber=0,
/** @var int */
public int $ToWaypointNumber=0,
/** @var float */
public float $FromLatitude=0.0,
/** @var float */
public float $FromLongitude=0.0,
/** @var float */
public float $ToLatitude=0.0,
/** @var float */
public float $ToLongitude=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['FromWaypointNumber'])) $this->FromWaypointNumber = $o['FromWaypointNumber'];
if (isset($o['ToWaypointNumber'])) $this->ToWaypointNumber = $o['ToWaypointNumber'];
if (isset($o['FromLatitude'])) $this->FromLatitude = $o['FromLatitude'];
if (isset($o['FromLongitude'])) $this->FromLongitude = $o['FromLongitude'];
if (isset($o['ToLatitude'])) $this->ToLatitude = $o['ToLatitude'];
if (isset($o['ToLongitude'])) $this->ToLongitude = $o['ToLongitude'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->FromWaypointNumber)) $o['FromWaypointNumber'] = $this->FromWaypointNumber;
if (isset($this->ToWaypointNumber)) $o['ToWaypointNumber'] = $this->ToWaypointNumber;
if (isset($this->FromLatitude)) $o['FromLatitude'] = $this->FromLatitude;
if (isset($this->FromLongitude)) $o['FromLongitude'] = $this->FromLongitude;
if (isset($this->ToLatitude)) $o['ToLatitude'] = $this->ToLatitude;
if (isset($this->ToLongitude)) $o['ToLongitude'] = $this->ToLongitude;
return empty($o) ? new class(){} : $o;
}
}
class WaypointQuoteInformation extends LinkedWaypoint implements JsonSerializable
{
/**
* @param int $FromWaypointNumber
* @param int $ToWaypointNumber
* @param float $FromLatitude
* @param float $FromLongitude
* @param float $ToLatitude
* @param float $ToLongitude
*/
public function __construct(
int $FromWaypointNumber=0,
int $ToWaypointNumber=0,
float $FromLatitude=0.0,
float $FromLongitude=0.0,
float $ToLatitude=0.0,
float $ToLongitude=0.0,
/** @description Distance between waypoints as a number */
// @ApiMember(Description="Distance between waypoints as a number")
/** @var float */
public float $Distance=0.0,
/** @description String formatted distance */
// @ApiMember(Description="String formatted distance")
/** @var string|null */
public ?string $DistanceValue=null,
/** @var bool|null */
public ?bool $WaypointValid=null,
/** @var string|null */
public ?string $Message=null,
/** @var array<string>|null */
public ?array $ErrorDetails=null,
/** @description Caculated price between waypoints excluding vat */
// @ApiMember(Description="Caculated price between waypoints excluding vat")
/** @var float */
public float $Price=0.0,
/** @description Price excluding vat formatted as a string rand value */
// @ApiMember(Description="Price excluding vat formatted as a string rand value")
/** @var string|null */
public ?string $PriceValue=null,
/** @description The price between waypoints including vat */
// @ApiMember(Description="The price between waypoints including vat")
/** @var float */
public float $PriceWithVAT=0.0,
/** @description The price including vat formatted as a rand value string */
// @ApiMember(Description="The price including vat formatted as a rand value string")
/** @var string|null */
public ?string $PriceValueWithVAT=null
) {
parent::__construct($FromWaypointNumber,$ToWaypointNumber,$FromLatitude,$FromLongitude,$ToLatitude,$ToLongitude);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Distance'])) $this->Distance = $o['Distance'];
if (isset($o['DistanceValue'])) $this->DistanceValue = $o['DistanceValue'];
if (isset($o['WaypointValid'])) $this->WaypointValid = $o['WaypointValid'];
if (isset($o['Message'])) $this->Message = $o['Message'];
if (isset($o['ErrorDetails'])) $this->ErrorDetails = JsonConverters::fromArray('string', $o['ErrorDetails']);
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['PriceValue'])) $this->PriceValue = $o['PriceValue'];
if (isset($o['PriceWithVAT'])) $this->PriceWithVAT = $o['PriceWithVAT'];
if (isset($o['PriceValueWithVAT'])) $this->PriceValueWithVAT = $o['PriceValueWithVAT'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Distance)) $o['Distance'] = $this->Distance;
if (isset($this->DistanceValue)) $o['DistanceValue'] = $this->DistanceValue;
if (isset($this->WaypointValid)) $o['WaypointValid'] = $this->WaypointValid;
if (isset($this->Message)) $o['Message'] = $this->Message;
if (isset($this->ErrorDetails)) $o['ErrorDetails'] = JsonConverters::toArray('string', $this->ErrorDetails);
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->PriceValue)) $o['PriceValue'] = $this->PriceValue;
if (isset($this->PriceWithVAT)) $o['PriceWithVAT'] = $this->PriceWithVAT;
if (isset($this->PriceValueWithVAT)) $o['PriceValueWithVAT'] = $this->PriceValueWithVAT;
return empty($o) ? new class(){} : $o;
}
}
class WaypointValidationInformation implements JsonSerializable
{
public function __construct(
/** @var int */
public int $WaypointNumber=0,
/** @var bool|null */
public ?bool $IsValid=null,
/** @var array<string>|null */
public ?array $ErrorMessages=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['WaypointNumber'])) $this->WaypointNumber = $o['WaypointNumber'];
if (isset($o['IsValid'])) $this->IsValid = $o['IsValid'];
if (isset($o['ErrorMessages'])) $this->ErrorMessages = JsonConverters::fromArray('string', $o['ErrorMessages']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->WaypointNumber)) $o['WaypointNumber'] = $this->WaypointNumber;
if (isset($this->IsValid)) $o['IsValid'] = $this->IsValid;
if (isset($this->ErrorMessages)) $o['ErrorMessages'] = JsonConverters::toArray('string', $this->ErrorMessages);
return empty($o) ? new class(){} : $o;
}
}
class RequestQuoteResponse extends ApiServiceResponse implements JsonSerializable
{
/**
* @param string $Description
* @param string $Heading
* @param bool|null $WasSuccessful
*/
public function __construct(
string $Description='',
string $Heading='',
?bool $WasSuccessful=null,
/** @description Is there an issue for the waypoints details specified? */
// @ApiMember(Description="Is there an issue for the waypoints details specified?")
/** @var bool|null */
public ?bool $WaypointIssue=null,
/** @description Is the quote created successfully and ready to be placed as an order? */
// @ApiMember(Description="Is the quote created successfully and ready to be placed as an order?")
/** @var bool|null */
public ?bool $QuoteReady=null,
/** @description Is the quote expired? */
// @ApiMember(Description="Is the quote expired?")
/** @var bool|null */
public ?bool $QuoteExpired=null,
/** @description The total distance for the quote */
// @ApiMember(Description="The total distance for the quote")
/** @var float */
public float $TotalDistance=0.0,
/** @description The total distance for the quote, formatted as a string */
// @ApiMember(Description="The total distance for the quote, formatted as a string")
/** @var string|null */
public ?string $TotalDistanceValue=null,
/** @description The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true */
// @ApiMember(Description="The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true")
/** @var string|null */
public ?string $ScheduledDate=null,
/** @description The subtotal of the order before VAT */
// @ApiMember(Description="The subtotal of the order before VAT")
/** @var string|null */
public ?string $SubTotal=null,
/** @description The total of the order after VAT */
// @ApiMember(Description="The total of the order after VAT")
/** @var string|null */
public ?string $FinalPrice=null,
/** @description The amount of VAT */
// @ApiMember(Description="The amount of VAT ")
/** @var string|null */
public ?string $VATValue=null,
/** @description Will contain a message if there might be a problem with a scheduled quote */
// @ApiMember(Description="Will contain a message if there might be a problem with a scheduled quote")
/** @var string|null */
public ?string $SchedulingNotice=null,
/** @description 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="Will contain a message if there is a problem with a scheduled quote, if the order is scheduled to soon to opening times")
/** @var string|null */
public ?string $SchedulingError=null,
/** @description The ID of the generated quote, needed when you want to change this quote later */
// @ApiMember(Description="The ID of the generated quote, needed when you want to change this quote later")
/** @var string */
public string $QuoteId='',
/** @description User friendly waybill number */
// @ApiMember(Description="User friendly waybill number")
/** @var string|null */
public ?string $WayBill=null,
/** @description The date this order was created */
// @ApiMember(Description="The date this order was created")
/** @var string|null */
public ?string $DateCreated=null,
/** @description The date this quote was last changed */
// @ApiMember(Description="The date this quote was last changed")
/** @var string|null */
public ?string $LastUpdated=null,
/** @description List of quote information for pricing etc between each waypoint */
// @ApiMember(Description="List of quote information for pricing etc between each waypoint")
/** @var array<WaypointQuoteInformation>|null */
public ?array $Waypoints=null,
/** @description List with validation information for each waypoint */
// @ApiMember(Description="List with validation information for each waypoint")
/** @var array<WaypointValidationInformation>|null */
public ?array $WaypointValidations=null
) {
parent::__construct($Description,$Heading,$WasSuccessful);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['WaypointIssue'])) $this->WaypointIssue = $o['WaypointIssue'];
if (isset($o['QuoteReady'])) $this->QuoteReady = $o['QuoteReady'];
if (isset($o['QuoteExpired'])) $this->QuoteExpired = $o['QuoteExpired'];
if (isset($o['TotalDistance'])) $this->TotalDistance = $o['TotalDistance'];
if (isset($o['TotalDistanceValue'])) $this->TotalDistanceValue = $o['TotalDistanceValue'];
if (isset($o['ScheduledDate'])) $this->ScheduledDate = $o['ScheduledDate'];
if (isset($o['SubTotal'])) $this->SubTotal = $o['SubTotal'];
if (isset($o['FinalPrice'])) $this->FinalPrice = $o['FinalPrice'];
if (isset($o['VATValue'])) $this->VATValue = $o['VATValue'];
if (isset($o['SchedulingNotice'])) $this->SchedulingNotice = $o['SchedulingNotice'];
if (isset($o['SchedulingError'])) $this->SchedulingError = $o['SchedulingError'];
if (isset($o['QuoteId'])) $this->QuoteId = $o['QuoteId'];
if (isset($o['WayBill'])) $this->WayBill = $o['WayBill'];
if (isset($o['DateCreated'])) $this->DateCreated = $o['DateCreated'];
if (isset($o['LastUpdated'])) $this->LastUpdated = $o['LastUpdated'];
if (isset($o['Waypoints'])) $this->Waypoints = JsonConverters::fromArray('WaypointQuoteInformation', $o['Waypoints']);
if (isset($o['WaypointValidations'])) $this->WaypointValidations = JsonConverters::fromArray('WaypointValidationInformation', $o['WaypointValidations']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->WaypointIssue)) $o['WaypointIssue'] = $this->WaypointIssue;
if (isset($this->QuoteReady)) $o['QuoteReady'] = $this->QuoteReady;
if (isset($this->QuoteExpired)) $o['QuoteExpired'] = $this->QuoteExpired;
if (isset($this->TotalDistance)) $o['TotalDistance'] = $this->TotalDistance;
if (isset($this->TotalDistanceValue)) $o['TotalDistanceValue'] = $this->TotalDistanceValue;
if (isset($this->ScheduledDate)) $o['ScheduledDate'] = $this->ScheduledDate;
if (isset($this->SubTotal)) $o['SubTotal'] = $this->SubTotal;
if (isset($this->FinalPrice)) $o['FinalPrice'] = $this->FinalPrice;
if (isset($this->VATValue)) $o['VATValue'] = $this->VATValue;
if (isset($this->SchedulingNotice)) $o['SchedulingNotice'] = $this->SchedulingNotice;
if (isset($this->SchedulingError)) $o['SchedulingError'] = $this->SchedulingError;
if (isset($this->QuoteId)) $o['QuoteId'] = $this->QuoteId;
if (isset($this->WayBill)) $o['WayBill'] = $this->WayBill;
if (isset($this->DateCreated)) $o['DateCreated'] = $this->DateCreated;
if (isset($this->LastUpdated)) $o['LastUpdated'] = $this->LastUpdated;
if (isset($this->Waypoints)) $o['Waypoints'] = JsonConverters::toArray('WaypointQuoteInformation', $this->Waypoints);
if (isset($this->WaypointValidations)) $o['WaypointValidations'] = JsonConverters::toArray('WaypointValidationInformation', $this->WaypointValidations);
return empty($o) ? new class(){} : $o;
}
}
class RequestQuoteWaypoint implements IRequestWaypoint, JsonSerializable
{
public function __construct(
/** @description Number of waypoint for ordering */
// @ApiMember(Description="Number of waypoint for ordering", IsRequired=true)
/** @var int */
public int $WaypointNumber=0,
/** @description Waypoint Latitude */
// @ApiMember(Description="Waypoint Latitude", IsRequired=true)
/** @var float */
public float $Latitude=0.0,
/** @description Waypoint Longitude */
// @ApiMember(Description="Waypoint Longitude", IsRequired=true)
/** @var float */
public float $Longitude=0.0,
/** @description Name of contact person at waypoint */
// @ApiMember(Description="Name of contact person at waypoint", IsRequired=true)
/** @var string */
public string $ContactName='',
/** @description Telephone number of contact person at waypoint */
// @ApiMember(Description="Telephone number of contact person at waypoint", IsRequired=true)
/** @var string */
public string $ContactNumber='',
/** @description Instructions for driver to follow at waypoint */
// @ApiMember(Description="Instructions for driver to follow at waypoint", IsRequired=true)
/** @var string */
public string $DeliveryInstructions='',
/** @description Waypoint address */
// @ApiMember(Description="Waypoint address", IsRequired=true)
/** @var string */
public string $Address=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['WaypointNumber'])) $this->WaypointNumber = $o['WaypointNumber'];
if (isset($o['Latitude'])) $this->Latitude = $o['Latitude'];
if (isset($o['Longitude'])) $this->Longitude = $o['Longitude'];
if (isset($o['ContactName'])) $this->ContactName = $o['ContactName'];
if (isset($o['ContactNumber'])) $this->ContactNumber = $o['ContactNumber'];
if (isset($o['DeliveryInstructions'])) $this->DeliveryInstructions = $o['DeliveryInstructions'];
if (isset($o['Address'])) $this->Address = $o['Address'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->WaypointNumber)) $o['WaypointNumber'] = $this->WaypointNumber;
if (isset($this->Latitude)) $o['Latitude'] = $this->Latitude;
if (isset($this->Longitude)) $o['Longitude'] = $this->Longitude;
if (isset($this->ContactName)) $o['ContactName'] = $this->ContactName;
if (isset($this->ContactNumber)) $o['ContactNumber'] = $this->ContactNumber;
if (isset($this->DeliveryInstructions)) $o['DeliveryInstructions'] = $this->DeliveryInstructions;
if (isset($this->Address)) $o['Address'] = $this->Address;
return empty($o) ? new class(){} : $o;
}
}
enum ScheduleType : int
{
case NextAvailable = 0;
case SpecificTime = 1;
}
class RequestQuote extends ApiServiceRequest implements ILogRequest, JsonSerializable
{
/**
* @param string $ApiKey
*/
public function __construct(
string $ApiKey='',
/** @description Array of waypoints */
// @ApiMember(Description="Array of waypoints", IsRequired=true)
/** @var array<RequestQuoteWaypoint>|null */
public ?array $Waypoints=null,
/** @description Is this a scheduled order? */
// @ApiMember(Description="Is this a scheduled order?", IsRequired=true)
/** @var bool|null */
public ?bool $IsScheduled=null,
/** @description Specify the scheduling type, required if IsScheduled is true */
// @ApiMember(Description="Specify the scheduling type, required if IsScheduled is true")
/** @var ScheduleType|null */
public ?ScheduleType $ScheduleType=null,
/** @description Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime */
// @ApiMember(Description="Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime")
/** @var string|null */
public ?string $ScheduledDate=null,
/** @description Specify a quote Id to amend a quote. Required when amending an existing quote. */
// @ApiMember(Description="Specify a quote Id to amend a quote. Required when amending an existing quote.")
/** @var string */
public string $QuoteId='',
/** @description Set this to true to prevent creating the quote */
// @ApiMember(Description="Set this to true to prevent creating the quote", IsRequired=true)
/** @var bool|null */
public ?bool $Test=null
) {
parent::__construct($ApiKey);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Waypoints'])) $this->Waypoints = JsonConverters::fromArray('RequestQuoteWaypoint', $o['Waypoints']);
if (isset($o['IsScheduled'])) $this->IsScheduled = $o['IsScheduled'];
if (isset($o['ScheduleType'])) $this->ScheduleType = JsonConverters::from('ScheduleType', $o['ScheduleType']);
if (isset($o['ScheduledDate'])) $this->ScheduledDate = $o['ScheduledDate'];
if (isset($o['QuoteId'])) $this->QuoteId = $o['QuoteId'];
if (isset($o['Test'])) $this->Test = $o['Test'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Waypoints)) $o['Waypoints'] = JsonConverters::toArray('RequestQuoteWaypoint', $this->Waypoints);
if (isset($this->IsScheduled)) $o['IsScheduled'] = $this->IsScheduled;
if (isset($this->ScheduleType)) $o['ScheduleType'] = JsonConverters::to('ScheduleType', $this->ScheduleType);
if (isset($this->ScheduledDate)) $o['ScheduledDate'] = $this->ScheduledDate;
if (isset($this->QuoteId)) $o['QuoteId'] = $this->QuoteId;
if (isset($this->Test)) $o['Test'] = $this->Test;
return empty($o) ? new class(){} : $o;
}
}
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.)