1Fetch Client API

<back to all web services

PlaceOrder

The following routes are available for this service:
POST/orderProvide waypoints for a route and place an order. This will bill the order to your account.
<?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 PlaceOrderResponse 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 The ID of the order. */
        // @ApiMember(Description="The ID of the order.")
        /** @var string */
        public string $OrderId='',

        /** @description Were there any validation issues for any waypoints */
        // @ApiMember(Description="Were there any validation issues for any waypoints")
        /** @var bool|null */
        public ?bool $WaypointIssue=null,

        /** @description The total distance for the order */
        // @ApiMember(Description="The total distance for the order")
        /** @var float */
        public float $TotalDistance=0.0,

        /** @description The total distance for the order, formatted as a string */
        // @ApiMember(Description="The total distance for the order, 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 a problem with a scheduled order */
        // @ApiMember(Description="Will contain a message if there a problem with a scheduled order")
        /** @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 User friendly waybill number */
        // @ApiMember(Description="User friendly waybill number")
        /** @var string|null */
        public ?string $WayBill=null,

        /** @description List of order information for pricing etc between each waypoint */
        // @ApiMember(Description="List of order 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['OrderId'])) $this->OrderId = $o['OrderId'];
        if (isset($o['WaypointIssue'])) $this->WaypointIssue = $o['WaypointIssue'];
        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['WayBill'])) $this->WayBill = $o['WayBill'];
        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->OrderId)) $o['OrderId'] = $this->OrderId;
        if (isset($this->WaypointIssue)) $o['WaypointIssue'] = $this->WaypointIssue;
        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->WayBill)) $o['WayBill'] = $this->WayBill;
        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 PlaceOrder extends ApiServiceRequest implements ILogRequest, JsonSerializable
{
    /**
     * @param string $ApiKey
     */
    public function __construct(
        string $ApiKey='',
        /** @description Optionally provide your own reference identifier */
        // @ApiMember(Description="Optionally provide your own reference identifier")
        /** @var string|null */
        public ?string $ClientReference=null,

        /** @description Optionally provide a reference for the customer/business */
        // @ApiMember(Description="Optionally provide a reference for the customer/business")
        /** @var string|null */
        public ?string $CustomerReference=null,

        /** @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 Set this to true to prevent creating an order and billing for it */
        // @ApiMember(Description="Set this to true to prevent creating an order and billing for it", IsRequired=true)
        /** @var bool|null */
        public ?bool $Test=null,

        /** @description Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent. */
        // @ApiMember(Description="Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.")
        /** @var bool|null */
        public ?bool $IsUrgent=null
    ) {
        parent::__construct($ApiKey);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['ClientReference'])) $this->ClientReference = $o['ClientReference'];
        if (isset($o['CustomerReference'])) $this->CustomerReference = $o['CustomerReference'];
        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['Test'])) $this->Test = $o['Test'];
        if (isset($o['IsUrgent'])) $this->IsUrgent = $o['IsUrgent'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->ClientReference)) $o['ClientReference'] = $this->ClientReference;
        if (isset($this->CustomerReference)) $o['CustomerReference'] = $this->CustomerReference;
        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->Test)) $o['Test'] = $this->Test;
        if (isset($this->IsUrgent)) $o['IsUrgent'] = $this->IsUrgent;
        return empty($o) ? new class(){} : $o;
    }
}

PHP PlaceOrder DTOs

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

HTTP + OTHER

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

POST /order HTTP/1.1 
Host: api.1fetch.co.za 
Accept: text/jsonl
Content-Type: text/jsonl
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: text/jsonl
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}