1Fetch Client API

<back to all web services

Order

The following routes are available for this service:
GET/orderGet order information.If you do not specify an OrderId, the results will be paged.
<?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;
    }
}

enum OrderStatus : int
{
    case AwaitingPayment = 0;
    case ProcessingPayment = 1;
    case AwaitingDispatch = 2;
    case DriverDispatched = 3;
    case PackageEnRoute = 4;
    case Completed = 5;
    case Cancelled = 6;
    case DeliveryFailed = 7;
}

class ScanDetail implements JsonSerializable
{
    public function __construct(
        /** @description List of URLs for images captured at the waypoint */
        // @ApiMember(Description="List of URLs for images captured at the waypoint")
        /** @var array<string>|null */
        public ?array $PhotoUrls=null,

        /** @description List of URLs for images of signatures captured at the waypoint */
        // @ApiMember(Description="List of URLs for images of signatures captured at the waypoint")
        /** @var array<string>|null */
        public ?array $SignatureUrls=null,

        /** @description Name of person the driver interacted with at the waypoint */
        // @ApiMember(Description="Name of person the driver interacted with at the waypoint")
        /** @var string|null */
        public ?string $ReceivedBy=null,

        /** @description The date the driver interacted with the person */
        // @ApiMember(Description="The date the driver interacted with the person")
        /** @var string|null */
        public ?string $ReceivedDate=null,

        /** @description Number of packages collected by the driver */
        // @ApiMember(Description="Number of packages collected by the driver")
        /** @var int */
        public int $PackagesCollected=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['PhotoUrls'])) $this->PhotoUrls = JsonConverters::fromArray('string', $o['PhotoUrls']);
        if (isset($o['SignatureUrls'])) $this->SignatureUrls = JsonConverters::fromArray('string', $o['SignatureUrls']);
        if (isset($o['ReceivedBy'])) $this->ReceivedBy = $o['ReceivedBy'];
        if (isset($o['ReceivedDate'])) $this->ReceivedDate = $o['ReceivedDate'];
        if (isset($o['PackagesCollected'])) $this->PackagesCollected = $o['PackagesCollected'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->PhotoUrls)) $o['PhotoUrls'] = JsonConverters::toArray('string', $this->PhotoUrls);
        if (isset($this->SignatureUrls)) $o['SignatureUrls'] = JsonConverters::toArray('string', $this->SignatureUrls);
        if (isset($this->ReceivedBy)) $o['ReceivedBy'] = $this->ReceivedBy;
        if (isset($this->ReceivedDate)) $o['ReceivedDate'] = $this->ReceivedDate;
        if (isset($this->PackagesCollected)) $o['PackagesCollected'] = $this->PackagesCollected;
        return empty($o) ? new class(){} : $o;
    }
}

class OrderItemWaypoint implements JsonSerializable
{
    public function __construct(
        /** @description Has the driver completed this waypoint */
        // @ApiMember(Description="Has the driver completed this waypoint")
        /** @var bool|null */
        public ?bool $Completed=null,

        /** @var float */
        public float $Latitude=0.0,
        /** @var float */
        public float $Longitude=0.0,
        /** @var string|null */
        public ?string $Address=null,
        /** @var string|null */
        public ?string $ContactName=null,
        /** @var string|null */
        public ?string $ContactNumber=null,
        /** @var string|null */
        public ?string $DeliveryInstructions=null,
        /** @description Details captured at waypoint */
        // @ApiMember(Description="Details captured at waypoint")
        /** @var ScanDetail|null */
        public ?ScanDetail $ScanDetail=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Completed'])) $this->Completed = $o['Completed'];
        if (isset($o['Latitude'])) $this->Latitude = $o['Latitude'];
        if (isset($o['Longitude'])) $this->Longitude = $o['Longitude'];
        if (isset($o['Address'])) $this->Address = $o['Address'];
        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['ScanDetail'])) $this->ScanDetail = JsonConverters::from('ScanDetail', $o['ScanDetail']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Completed)) $o['Completed'] = $this->Completed;
        if (isset($this->Latitude)) $o['Latitude'] = $this->Latitude;
        if (isset($this->Longitude)) $o['Longitude'] = $this->Longitude;
        if (isset($this->Address)) $o['Address'] = $this->Address;
        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->ScanDetail)) $o['ScanDetail'] = JsonConverters::to('ScanDetail', $this->ScanDetail);
        return empty($o) ? new class(){} : $o;
    }
}

class OrderTransitPoint implements JsonSerializable
{
    public function __construct(
        /** @description Origin waypoint number */
        // @ApiMember(Description="Origin waypoint number")
        /** @var int */
        public int $FromWaypointNumber=0,

        /** @description Destination waypoint number */
        // @ApiMember(Description="Destination waypoint number")
        /** @var int */
        public int $ToWaypointNumber=0,

        /** @description Distance between waypoints */
        // @ApiMember(Description="Distance between waypoints")
        /** @var float */
        public float $Distance=0.0,

        /** @description Distance between waypoints rounded and converted to a string */
        // @ApiMember(Description="Distance between waypoints rounded and converted to a string")
        /** @var string|null */
        public ?string $DistanceValue=null,

        /** @description Price calculated between waypoints */
        // @ApiMember(Description="Price calculated between waypoints")
        /** @var float */
        public float $Price=0.0,

        /** @description Price calculated between waypoints formatted as ZA currency */
        // @ApiMember(Description="Price calculated between waypoints formatted as ZA currency")
        /** @var string|null */
        public ?string $PriceValue=null
    ) {
    }

    /** @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['Distance'])) $this->Distance = $o['Distance'];
        if (isset($o['DistanceValue'])) $this->DistanceValue = $o['DistanceValue'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['PriceValue'])) $this->PriceValue = $o['PriceValue'];
    }
    
    /** @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->Distance)) $o['Distance'] = $this->Distance;
        if (isset($this->DistanceValue)) $o['DistanceValue'] = $this->DistanceValue;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->PriceValue)) $o['PriceValue'] = $this->PriceValue;
        return empty($o) ? new class(){} : $o;
    }
}

class EventDetail implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Description=null,
        /** @var string|null */
        public ?string $Time=null,
        /** @var DateTime */
        public DateTime $EventDateTime=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['Time'])) $this->Time = $o['Time'];
        if (isset($o['EventDateTime'])) $this->EventDateTime = JsonConverters::from('DateTime', $o['EventDateTime']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->Time)) $o['Time'] = $this->Time;
        if (isset($this->EventDateTime)) $o['EventDateTime'] = JsonConverters::to('DateTime', $this->EventDateTime);
        return empty($o) ? new class(){} : $o;
    }
}

class OrderDetail implements JsonSerializable
{
    public function __construct(
        /** @description ID of quote attached to the order */
        // @ApiMember(Description="ID of quote attached to the order")
        /** @var string */
        public string $QuoteId='',

        /** @description ID of order */
        // @ApiMember(Description="ID of order")
        /** @var string */
        public string $OrderId='',

        /** @description User friendly order identifier */
        // @ApiMember(Description="User friendly order identifier")
        /** @var string|null */
        public ?string $Waybill=null,

        /** @description Invoice number for the order */
        // @ApiMember(Description="Invoice number for the order")
        /** @var string|null */
        public ?string $InvoiceNumber=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 Order status number */
        // @ApiMember(Description="Order status number")
        /** @var OrderStatus|null */
        public ?OrderStatus $OrderStatus=null,

        /** @description String value of order status */
        // @ApiMember(Description="String value of order status")
        /** @var string|null */
        public ?string $OrderStatusValue=null,

        /** @description List of waypoints for this order */
        // @ApiMember(Description="List of waypoints for this order")
        /** @var array<OrderItemWaypoint>|null */
        public ?array $Waypoints=null,

        /** @description List of sections between waypoints */
        // @ApiMember(Description="List of sections between waypoints")
        /** @var array<OrderTransitPoint>|null */
        public ?array $TransitPoints=null,

        /** @description Order Final price including VAT */
        // @ApiMember(Description="Order Final price including VAT")
        /** @var float */
        public float $FinalPrice=0.0,

        /** @description Final price formatted as ZA currency */
        // @ApiMember(Description="Final price formatted as ZA currency")
        /** @var string|null */
        public ?string $FinalPriceValue=null,

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

        /** @description Total distance for the order formatted as a string */
        // @ApiMember(Description="Total distance for the order formatted as a string")
        /** @var string|null */
        public ?string $TotalDistanceValue=null,

        /** @description Date order was placed */
        // @ApiMember(Description="Date order was placed")
        /** @var string|null */
        public ?string $Date=null,

        /** @description Google encoded maps polyline path for drawing route on a google map */
        // @ApiMember(Description="Google encoded maps polyline path for drawing route on a google map")
        /** @var string|null */
        public ?string $EncodedPolyPath=null,

        /** @description List of events as they occurred while the order was in progress */
        // @ApiMember(Description="List of events as they occurred while the order was in progress")
        /** @var array<EventDetail>|null */
        public ?array $Events=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['QuoteId'])) $this->QuoteId = $o['QuoteId'];
        if (isset($o['OrderId'])) $this->OrderId = $o['OrderId'];
        if (isset($o['Waybill'])) $this->Waybill = $o['Waybill'];
        if (isset($o['InvoiceNumber'])) $this->InvoiceNumber = $o['InvoiceNumber'];
        if (isset($o['ScheduledDate'])) $this->ScheduledDate = $o['ScheduledDate'];
        if (isset($o['OrderStatus'])) $this->OrderStatus = JsonConverters::from('OrderStatus', $o['OrderStatus']);
        if (isset($o['OrderStatusValue'])) $this->OrderStatusValue = $o['OrderStatusValue'];
        if (isset($o['Waypoints'])) $this->Waypoints = JsonConverters::fromArray('OrderItemWaypoint', $o['Waypoints']);
        if (isset($o['TransitPoints'])) $this->TransitPoints = JsonConverters::fromArray('OrderTransitPoint', $o['TransitPoints']);
        if (isset($o['FinalPrice'])) $this->FinalPrice = $o['FinalPrice'];
        if (isset($o['FinalPriceValue'])) $this->FinalPriceValue = $o['FinalPriceValue'];
        if (isset($o['TotalDistance'])) $this->TotalDistance = $o['TotalDistance'];
        if (isset($o['TotalDistanceValue'])) $this->TotalDistanceValue = $o['TotalDistanceValue'];
        if (isset($o['Date'])) $this->Date = $o['Date'];
        if (isset($o['EncodedPolyPath'])) $this->EncodedPolyPath = $o['EncodedPolyPath'];
        if (isset($o['Events'])) $this->Events = JsonConverters::fromArray('EventDetail', $o['Events']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->QuoteId)) $o['QuoteId'] = $this->QuoteId;
        if (isset($this->OrderId)) $o['OrderId'] = $this->OrderId;
        if (isset($this->Waybill)) $o['Waybill'] = $this->Waybill;
        if (isset($this->InvoiceNumber)) $o['InvoiceNumber'] = $this->InvoiceNumber;
        if (isset($this->ScheduledDate)) $o['ScheduledDate'] = $this->ScheduledDate;
        if (isset($this->OrderStatus)) $o['OrderStatus'] = JsonConverters::to('OrderStatus', $this->OrderStatus);
        if (isset($this->OrderStatusValue)) $o['OrderStatusValue'] = $this->OrderStatusValue;
        if (isset($this->Waypoints)) $o['Waypoints'] = JsonConverters::toArray('OrderItemWaypoint', $this->Waypoints);
        if (isset($this->TransitPoints)) $o['TransitPoints'] = JsonConverters::toArray('OrderTransitPoint', $this->TransitPoints);
        if (isset($this->FinalPrice)) $o['FinalPrice'] = $this->FinalPrice;
        if (isset($this->FinalPriceValue)) $o['FinalPriceValue'] = $this->FinalPriceValue;
        if (isset($this->TotalDistance)) $o['TotalDistance'] = $this->TotalDistance;
        if (isset($this->TotalDistanceValue)) $o['TotalDistanceValue'] = $this->TotalDistanceValue;
        if (isset($this->Date)) $o['Date'] = $this->Date;
        if (isset($this->EncodedPolyPath)) $o['EncodedPolyPath'] = $this->EncodedPolyPath;
        if (isset($this->Events)) $o['Events'] = JsonConverters::toArray('EventDetail', $this->Events);
        return empty($o) ? new class(){} : $o;
    }
}

class OrderResponse 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 List with order details, will only contain one item if requested with order id */
        // @ApiMember(Description="List with order details, will only contain one item if requested with order id")
        /** @var array<OrderDetail>|null */
        public ?array $OrderItems=null,

        /** @description Total number of items in order collection */
        // @ApiMember(Description="Total number of items in order collection")
        /** @var int */
        public int $TotalCount=0,

        /** @description Used to indicate if there are more items available */
        // @ApiMember(Description="Used to indicate if there are more items available")
        /** @var bool|null */
        public ?bool $LastPage=null
    ) {
        parent::__construct($Description,$Heading,$WasSuccessful);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['OrderItems'])) $this->OrderItems = JsonConverters::fromArray('OrderDetail', $o['OrderItems']);
        if (isset($o['TotalCount'])) $this->TotalCount = $o['TotalCount'];
        if (isset($o['LastPage'])) $this->LastPage = $o['LastPage'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->OrderItems)) $o['OrderItems'] = JsonConverters::toArray('OrderDetail', $this->OrderItems);
        if (isset($this->TotalCount)) $o['TotalCount'] = $this->TotalCount;
        if (isset($this->LastPage)) $o['LastPage'] = $this->LastPage;
        return empty($o) ? new class(){} : $o;
    }
}

class Order extends ApiServiceRequest implements ILogRequest, JsonSerializable
{
    /**
     * @param string $ApiKey
     */
    public function __construct(
        string $ApiKey='',
        /** @description The ID if getting specific order */
        // @ApiMember(Description="The ID if getting specific order")
        /** @var string|null */
        public ?string $OrderId=null,

        /** @description The amount of elements to offset the index by */
        // @ApiMember(Description="The amount of elements to offset the index by")
        /** @var int */
        public int $Offset=0,

        /** @description The number of elements to be returned, defaults to 10 */
        // @ApiMember(Description="The number of elements to be returned, defaults to 10")
        /** @var int */
        public int $Count=0
    ) {
        parent::__construct($ApiKey);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['OrderId'])) $this->OrderId = $o['OrderId'];
        if (isset($o['Offset'])) $this->Offset = $o['Offset'];
        if (isset($o['Count'])) $this->Count = $o['Count'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->OrderId)) $o['OrderId'] = $this->OrderId;
        if (isset($this->Offset)) $o['Offset'] = $this->Offset;
        if (isset($this->Count)) $o['Count'] = $this->Count;
        return empty($o) ? new class(){} : $o;
    }
}

PHP Order 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.

GET /order HTTP/1.1 
Host: 1fetch.api.client.prod.86degrees.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	OrderItems: 
	[
		{
			QuoteId: 00000000-0000-0000-0000-000000000000,
			OrderId: 00000000-0000-0000-0000-000000000000,
			Waybill: String,
			InvoiceNumber: String,
			ScheduledDate: String,
			OrderStatus: 0,
			OrderStatusValue: String,
			Waypoints: 
			[
				{
					
				}
			],
			TransitPoints: 
			[
				{
					
				}
			],
			FinalPrice: 0,
			FinalPriceValue: String,
			TotalDistance: 0,
			TotalDistanceValue: String,
			Date: String,
			EncodedPolyPath: String,
			Events: 
			[
				{
					
				}
			]
		}
	],
	TotalCount: 0,
	LastPage: False,
	Description: String,
	Heading: String,
	WasSuccessful: False
}