| POST | /picup/createshipment |
|---|
<?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 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 PicUpCreateShipmentResponse implements JsonSerializable
{
public function __construct(
// @DataMember(Name="is_success")
/** @var bool|null */
public ?bool $is_success=null,
// @DataMember(Name="courier_reference")
/** @var string|null */
public ?string $courier_reference=null,
// @DataMember(Name="error")
/** @var string|null */
public ?string $error=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,
/** @description The 1Fetch Waybill reference for the shipment */
// @ApiMember(Description="The 1Fetch Waybill reference for the shipment")
/** @var string|null */
public ?string $Waybill=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['is_success'])) $this->is_success = $o['is_success'];
if (isset($o['courier_reference'])) $this->courier_reference = $o['courier_reference'];
if (isset($o['error'])) $this->error = $o['error'];
if (isset($o['Waypoints'])) $this->Waypoints = JsonConverters::fromArray('WaypointQuoteInformation', $o['Waypoints']);
if (isset($o['WaypointValidations'])) $this->WaypointValidations = JsonConverters::fromArray('WaypointValidationInformation', $o['WaypointValidations']);
if (isset($o['Waybill'])) $this->Waybill = $o['Waybill'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->is_success)) $o['is_success'] = $this->is_success;
if (isset($this->courier_reference)) $o['courier_reference'] = $this->courier_reference;
if (isset($this->error)) $o['error'] = $this->error;
if (isset($this->Waypoints)) $o['Waypoints'] = JsonConverters::toArray('WaypointQuoteInformation', $this->Waypoints);
if (isset($this->WaypointValidations)) $o['WaypointValidations'] = JsonConverters::toArray('WaypointValidationInformation', $this->WaypointValidations);
if (isset($this->Waybill)) $o['Waybill'] = $this->Waybill;
return empty($o) ? new class(){} : $o;
}
}
class BucketDetails implements JsonSerializable
{
public function __construct(
// @DataMember(Name="delivery_date")
/** @var DateTime */
public DateTime $delivery_date=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['delivery_date'])) $this->delivery_date = JsonConverters::from('DateTime', $o['delivery_date']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->delivery_date)) $o['delivery_date'] = JsonConverters::to('DateTime', $this->delivery_date);
return empty($o) ? new class(){} : $o;
}
}
class CourierRequest implements JsonSerializable
{
public function __construct(
// @DataMember(Name="bucket_details")
/** @var BucketDetails|null */
public ?BucketDetails $bucket_details=null,
// @DataMember(Name="shipments")
/** @var Shipment[]|null */
public ?array $shipments=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['bucket_details'])) $this->bucket_details = JsonConverters::from('BucketDetails', $o['bucket_details']);
if (isset($o['shipments'])) $this->shipments = JsonConverters::fromArray('Shipment', $o['shipments']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->bucket_details)) $o['bucket_details'] = JsonConverters::to('BucketDetails', $this->bucket_details);
if (isset($this->shipments)) $o['shipments'] = JsonConverters::toArray('Shipment', $this->shipments);
return empty($o) ? new class(){} : $o;
}
}
class PicUpCreateShipmentRequest implements IHasApiKey, ILogRequest, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $ApiKey=null,
// @DataMember(Name="courier_request")
/** @var CourierRequest|null */
public ?CourierRequest $courier_request=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApiKey'])) $this->ApiKey = $o['ApiKey'];
if (isset($o['courier_request'])) $this->courier_request = JsonConverters::from('CourierRequest', $o['courier_request']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApiKey)) $o['ApiKey'] = $this->ApiKey;
if (isset($this->courier_request)) $o['courier_request'] = JsonConverters::to('CourierRequest', $this->courier_request);
return empty($o) ? new class(){} : $o;
}
}
class Address implements JsonSerializable
{
public function __construct(
// @DataMember(Name="address_line_1")
/** @var string|null */
public ?string $address_line_1=null,
// @DataMember(Name="address_line_2")
/** @var string|null */
public ?string $address_line_2=null,
// @DataMember(Name="address_line_3")
/** @var string|null */
public ?string $address_line_3=null,
// @DataMember(Name="address_line_4")
/** @var string|null */
public ?string $address_line_4=null,
// @DataMember(Name="city")
/** @var string|null */
public ?string $city=null,
// @DataMember(Name="formatted_address")
/** @var string|null */
public ?string $formatted_address=null,
// @DataMember(Name="latitude")
/** @var float */
public float $latitude=0.0,
// @DataMember(Name="longitude")
/** @var float */
public float $longitude=0.0,
// @DataMember(Name="postal_code")
/** @var string|null */
public ?string $postal_code=null,
// @DataMember(Name="suburb")
/** @var string|null */
public ?string $suburb=null,
// @DataMember(Name="unit")
/** @var string|null */
public ?string $unit=null,
// @DataMember(Name="building")
/** @var string|null */
public ?string $building=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['address_line_1'])) $this->address_line_1 = $o['address_line_1'];
if (isset($o['address_line_2'])) $this->address_line_2 = $o['address_line_2'];
if (isset($o['address_line_3'])) $this->address_line_3 = $o['address_line_3'];
if (isset($o['address_line_4'])) $this->address_line_4 = $o['address_line_4'];
if (isset($o['city'])) $this->city = $o['city'];
if (isset($o['formatted_address'])) $this->formatted_address = $o['formatted_address'];
if (isset($o['latitude'])) $this->latitude = $o['latitude'];
if (isset($o['longitude'])) $this->longitude = $o['longitude'];
if (isset($o['postal_code'])) $this->postal_code = $o['postal_code'];
if (isset($o['suburb'])) $this->suburb = $o['suburb'];
if (isset($o['unit'])) $this->unit = $o['unit'];
if (isset($o['building'])) $this->building = $o['building'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->address_line_1)) $o['address_line_1'] = $this->address_line_1;
if (isset($this->address_line_2)) $o['address_line_2'] = $this->address_line_2;
if (isset($this->address_line_3)) $o['address_line_3'] = $this->address_line_3;
if (isset($this->address_line_4)) $o['address_line_4'] = $this->address_line_4;
if (isset($this->city)) $o['city'] = $this->city;
if (isset($this->formatted_address)) $o['formatted_address'] = $this->formatted_address;
if (isset($this->latitude)) $o['latitude'] = $this->latitude;
if (isset($this->longitude)) $o['longitude'] = $this->longitude;
if (isset($this->postal_code)) $o['postal_code'] = $this->postal_code;
if (isset($this->suburb)) $o['suburb'] = $this->suburb;
if (isset($this->unit)) $o['unit'] = $this->unit;
if (isset($this->building)) $o['building'] = $this->building;
return empty($o) ? new class(){} : $o;
}
}
class Contact implements JsonSerializable
{
public function __construct(
// @DataMember(Name="customer_name")
/** @var string|null */
public ?string $customer_name=null,
// @DataMember(Name="customer_phone")
/** @var string|null */
public ?string $customer_phone=null,
// @DataMember(Name="email_address")
/** @var string|null */
public ?string $email_address=null,
// @DataMember(Name="special_instructions")
/** @var string|null */
public ?string $special_instructions=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['customer_name'])) $this->customer_name = $o['customer_name'];
if (isset($o['customer_phone'])) $this->customer_phone = $o['customer_phone'];
if (isset($o['email_address'])) $this->email_address = $o['email_address'];
if (isset($o['special_instructions'])) $this->special_instructions = $o['special_instructions'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->customer_name)) $o['customer_name'] = $this->customer_name;
if (isset($this->customer_phone)) $o['customer_phone'] = $this->customer_phone;
if (isset($this->email_address)) $o['email_address'] = $this->email_address;
if (isset($this->special_instructions)) $o['special_instructions'] = $this->special_instructions;
return empty($o) ? new class(){} : $o;
}
}
class Sender implements JsonSerializable
{
public function __construct(
// @DataMember(Name="address")
/** @var Address|null */
public ?Address $address=null,
// @DataMember(Name="contact")
/** @var Contact|null */
public ?Contact $contact=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['address'])) $this->address = JsonConverters::from('Address', $o['address']);
if (isset($o['contact'])) $this->contact = JsonConverters::from('Contact', $o['contact']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->address)) $o['address'] = JsonConverters::to('Address', $this->address);
if (isset($this->contact)) $o['contact'] = JsonConverters::to('Contact', $this->contact);
return empty($o) ? new class(){} : $o;
}
}
class Receiver implements JsonSerializable
{
public function __construct(
// @DataMember(Name="parcels")
/** @var Parcel[]|null */
public ?array $parcels=null,
// @DataMember(Name="address")
/** @var Address|null */
public ?Address $address=null,
// @DataMember(Name="contact")
/** @var Contact|null */
public ?Contact $contact=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['parcels'])) $this->parcels = JsonConverters::fromArray('Parcel', $o['parcels']);
if (isset($o['address'])) $this->address = JsonConverters::from('Address', $o['address']);
if (isset($o['contact'])) $this->contact = JsonConverters::from('Contact', $o['contact']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->parcels)) $o['parcels'] = JsonConverters::toArray('Parcel', $this->parcels);
if (isset($this->address)) $o['address'] = JsonConverters::to('Address', $this->address);
if (isset($this->contact)) $o['contact'] = JsonConverters::to('Contact', $this->contact);
return empty($o) ? new class(){} : $o;
}
}
class Shipment implements JsonSerializable
{
public function __construct(
// @DataMember(Name="waybill_number")
/** @var string|null */
public ?string $waybill_number=null,
// @DataMember(Name="business_reference")
/** @var string|null */
public ?string $business_reference=null,
// @DataMember(Name="service_type")
/** @var string|null */
public ?string $service_type=null,
// @DataMember(Name="sender")
/** @var Sender|null */
public ?Sender $sender=null,
// @DataMember(Name="receiver")
/** @var Receiver|null */
public ?Receiver $receiver=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['waybill_number'])) $this->waybill_number = $o['waybill_number'];
if (isset($o['business_reference'])) $this->business_reference = $o['business_reference'];
if (isset($o['service_type'])) $this->service_type = $o['service_type'];
if (isset($o['sender'])) $this->sender = JsonConverters::from('Sender', $o['sender']);
if (isset($o['receiver'])) $this->receiver = JsonConverters::from('Receiver', $o['receiver']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->waybill_number)) $o['waybill_number'] = $this->waybill_number;
if (isset($this->business_reference)) $o['business_reference'] = $this->business_reference;
if (isset($this->service_type)) $o['service_type'] = $this->service_type;
if (isset($this->sender)) $o['sender'] = JsonConverters::to('Sender', $this->sender);
if (isset($this->receiver)) $o['receiver'] = JsonConverters::to('Receiver', $this->receiver);
return empty($o) ? new class(){} : $o;
}
}
class Parcel implements JsonSerializable
{
public function __construct(
// @DataMember(Name="parcel_waybill")
/** @var string|null */
public ?string $parcel_waybill=null,
// @DataMember(Name="parcel_reference")
/** @var string|null */
public ?string $parcel_reference=null,
// @DataMember(Name="tracking_number")
/** @var string|null */
public ?string $tracking_number=null,
// @DataMember(Name="length_mm")
/** @var int */
public int $length_mm=0,
// @DataMember(Name="width_mm")
/** @var int */
public int $width_mm=0,
// @DataMember(Name="height_mm")
/** @var int */
public int $height_mm=0,
// @DataMember(Name="weight_kg")
/** @var int */
public int $weight_kg=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['parcel_waybill'])) $this->parcel_waybill = $o['parcel_waybill'];
if (isset($o['parcel_reference'])) $this->parcel_reference = $o['parcel_reference'];
if (isset($o['tracking_number'])) $this->tracking_number = $o['tracking_number'];
if (isset($o['length_mm'])) $this->length_mm = $o['length_mm'];
if (isset($o['width_mm'])) $this->width_mm = $o['width_mm'];
if (isset($o['height_mm'])) $this->height_mm = $o['height_mm'];
if (isset($o['weight_kg'])) $this->weight_kg = $o['weight_kg'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->parcel_waybill)) $o['parcel_waybill'] = $this->parcel_waybill;
if (isset($this->parcel_reference)) $o['parcel_reference'] = $this->parcel_reference;
if (isset($this->tracking_number)) $o['tracking_number'] = $this->tracking_number;
if (isset($this->length_mm)) $o['length_mm'] = $this->length_mm;
if (isset($this->width_mm)) $o['width_mm'] = $this->width_mm;
if (isset($this->height_mm)) $o['height_mm'] = $this->height_mm;
if (isset($this->weight_kg)) $o['weight_kg'] = $this->weight_kg;
return empty($o) ? new class(){} : $o;
}
}
PHP PicUpCreateShipmentRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /picup/createshipment HTTP/1.1
Host: 1fetch.api.client.prod.86degrees.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
ApiKey: String,
courier_request:
{
bucket_details:
{
delivery_date: 0001-01-01T00:00:00.0000000+00:00
},
shipments:
[
{
waybill_number: String,
business_reference: String,
service_type: String,
sender:
{
address:
{
address_line_1: String,
address_line_2: String,
address_line_3: String,
address_line_4: String,
city: String,
formatted_address: String,
latitude: 0,
longitude: 0,
postal_code: String,
suburb: String,
unit: String,
building: String
},
contact:
{
customer_name: String,
customer_phone: String,
email_address: String,
special_instructions: String
}
},
receiver:
{
parcels:
[
{
parcel_waybill: String,
parcel_reference: String,
tracking_number: String,
length_mm: 0,
width_mm: 0,
height_mm: 0,
weight_kg: 0
}
],
address:
{
address_line_1: String,
address_line_2: String,
address_line_3: String,
address_line_4: String,
city: String,
formatted_address: String,
latitude: 0,
longitude: 0,
postal_code: String,
suburb: String,
unit: String,
building: String
},
contact:
{
customer_name: String,
customer_phone: String,
email_address: String,
special_instructions: String
}
}
}
]
}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
is_success: False,
courier_reference: String,
error: String,
Waypoints:
[
{
}
],
WaypointValidations:
[
{
}
],
Waybill: String
}