Trendsic Platform Service

<back to all web services

CourierAvailabilityRequest

Requires Authentication
The following routes are available for this service:
GET,OPTIONS/v1/dispatch/courier/profiles/{Id}/availability
<?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 LevelOffer implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Code=null,
        /** @var string|null */
        public ?string $Name=null,
        /** @var bool|null */
        public ?bool $Ok=null,
        /** @var string|null */
        public ?string $Why=null,
        /** @var string|null */
        public ?string $Promise=null,
        /** @var float */
        public float $Surcharge=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Code'])) $this->Code = $o['Code'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Ok'])) $this->Ok = $o['Ok'];
        if (isset($o['Why'])) $this->Why = $o['Why'];
        if (isset($o['Promise'])) $this->Promise = $o['Promise'];
        if (isset($o['Surcharge'])) $this->Surcharge = $o['Surcharge'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Code)) $o['Code'] = $this->Code;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Ok)) $o['Ok'] = $this->Ok;
        if (isset($this->Why)) $o['Why'] = $this->Why;
        if (isset($this->Promise)) $o['Promise'] = $this->Promise;
        if (isset($this->Surcharge)) $o['Surcharge'] = $this->Surcharge;
        return empty($o) ? new class(){} : $o;
    }
}

class Window implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Id=null,
        /** @var int */
        public int $DayIx=0,
        /** @var int */
        public int $StartMin=0,
        /** @var int */
        public int $EndMin=0,
        /** @var string|null */
        public ?string $Label=null,
        /** @var bool|null */
        public ?bool $Asap=null,
        /** @var array<LevelOffer>|null */
        public ?array $Levels=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['DayIx'])) $this->DayIx = $o['DayIx'];
        if (isset($o['StartMin'])) $this->StartMin = $o['StartMin'];
        if (isset($o['EndMin'])) $this->EndMin = $o['EndMin'];
        if (isset($o['Label'])) $this->Label = $o['Label'];
        if (isset($o['Asap'])) $this->Asap = $o['Asap'];
        if (isset($o['Levels'])) $this->Levels = JsonConverters::fromArray('LevelOffer', $o['Levels']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->DayIx)) $o['DayIx'] = $this->DayIx;
        if (isset($this->StartMin)) $o['StartMin'] = $this->StartMin;
        if (isset($this->EndMin)) $o['EndMin'] = $this->EndMin;
        if (isset($this->Label)) $o['Label'] = $this->Label;
        if (isset($this->Asap)) $o['Asap'] = $this->Asap;
        if (isset($this->Levels)) $o['Levels'] = JsonConverters::toArray('LevelOffer', $this->Levels);
        return empty($o) ? new class(){} : $o;
    }
}

class Availability implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $InArea=null,
        /** @var bool|null */
        public ?bool $ZipChecked=null,
        /** @var bool|null */
        public ?bool $Closed=null,
        /** @var array<Window>|null */
        public ?array $Windows=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['InArea'])) $this->InArea = $o['InArea'];
        if (isset($o['ZipChecked'])) $this->ZipChecked = $o['ZipChecked'];
        if (isset($o['Closed'])) $this->Closed = $o['Closed'];
        if (isset($o['Windows'])) $this->Windows = JsonConverters::fromArray('Window', $o['Windows']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->InArea)) $o['InArea'] = $this->InArea;
        if (isset($this->ZipChecked)) $o['ZipChecked'] = $this->ZipChecked;
        if (isset($this->Closed)) $o['Closed'] = $this->Closed;
        if (isset($this->Windows)) $o['Windows'] = JsonConverters::toArray('Window', $this->Windows);
        return empty($o) ? new class(){} : $o;
    }
}

class CourierAvailabilityResponse implements JsonSerializable
{
    public function __construct(
        /** @var Availability|null */
        public ?Availability $Availability=null,
        /** @var string|null */
        public ?string $Date=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

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

class CourierAvailabilityRequest implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Date=null,
        /** @var string|null */
        public ?string $Zip=null
    ) {
    }

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

PHP CourierAvailabilityRequest 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 /v1/dispatch/courier/profiles/{Id}/availability HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Availability: 
	{
		InArea: False,
		ZipChecked: False,
		Closed: False,
		Windows: 
		[
			{
				Id: String,
				DayIx: 0,
				StartMin: 0,
				EndMin: 0,
				Label: String,
				Asap: False,
				Levels: 
				[
					{
						Code: String,
						Name: String,
						Ok: False,
						Why: String,
						Promise: String,
						Surcharge: 0
					}
				]
			}
		]
	},
	Date: String,
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}