| POST | /dealers/order | Places a new order with the specified items. |
|---|
<?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 AuthenticatedRequest implements JsonSerializable
{
public function __construct(
/** @description Session token received from successful authentication. */
// @ApiMember(Description="Session token received from successful authentication.", IsRequired=true, ParameterType="query")
/** @var string */
public string $SessionToken=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['SessionToken'])) $this->SessionToken = $o['SessionToken'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->SessionToken)) $o['SessionToken'] = $this->SessionToken;
return empty($o) ? new class(){} : $o;
}
}
class NewOrderResult implements JsonSerializable
{
public function __construct(
/** @description Number for the order that has been placed. */
// @ApiMember(Description="Number for the order that has been placed.", ParameterType="model")
/** @var string|null */
public ?string $OrderNumber=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['OrderNumber'])) $this->OrderNumber = $o['OrderNumber'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->OrderNumber)) $o['OrderNumber'] = $this->OrderNumber;
return empty($o) ? new class(){} : $o;
}
}
class OperationResult implements JsonSerializable
{
public function __construct(
/** @description Specifies if the operation was successful. */
// @ApiMember(Description="Specifies if the operation was successful.", ParameterType="model")
/** @var bool|null */
public ?bool $IsSuccessful=null,
/** @description States error message in case of unsuccessful operation. */
// @ApiMember(Description="States error message in case of unsuccessful operation.", ParameterType="model")
/** @var string|null */
public ?string $ErrorMessage=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['IsSuccessful'])) $this->IsSuccessful = $o['IsSuccessful'];
if (isset($o['ErrorMessage'])) $this->ErrorMessage = $o['ErrorMessage'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->IsSuccessful)) $o['IsSuccessful'] = $this->IsSuccessful;
if (isset($this->ErrorMessage)) $o['ErrorMessage'] = $this->ErrorMessage;
return empty($o) ? new class(){} : $o;
}
}
class PartInfoResultImage implements JsonSerializable
{
public function __construct(
/** @description Image number */
// @ApiMember(Description="Image number")
/** @var int */
public int $ImageNumber=0,
/** @description Image URL */
// @ApiMember(Description="Image URL")
/** @var string|null */
public ?string $ImageUrl=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ImageNumber'])) $this->ImageNumber = $o['ImageNumber'];
if (isset($o['ImageUrl'])) $this->ImageUrl = $o['ImageUrl'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ImageNumber)) $o['ImageNumber'] = $this->ImageNumber;
if (isset($this->ImageUrl)) $o['ImageUrl'] = $this->ImageUrl;
return empty($o) ? new class(){} : $o;
}
}
class PartStockQuantity implements JsonSerializable
{
public function __construct(
/** @description Location ID */
// @ApiMember(Description="Location ID")
/** @var int */
public int $LocationId=0,
/** @description Location code */
// @ApiMember(Description="Location code")
/** @var string|null */
public ?string $LocationCode=null,
/** @description Stock quantity in location */
// @ApiMember(Description="Stock quantity in location")
/** @var int */
public int $StockQuantity=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['LocationId'])) $this->LocationId = $o['LocationId'];
if (isset($o['LocationCode'])) $this->LocationCode = $o['LocationCode'];
if (isset($o['StockQuantity'])) $this->StockQuantity = $o['StockQuantity'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->LocationId)) $o['LocationId'] = $this->LocationId;
if (isset($this->LocationCode)) $o['LocationCode'] = $this->LocationCode;
if (isset($this->StockQuantity)) $o['StockQuantity'] = $this->StockQuantity;
return empty($o) ? new class(){} : $o;
}
}
class PartInfoResult implements JsonSerializable
{
public function __construct(
/** @description Unique ID for the part. */
// @ApiMember(Description="Unique ID for the part.")
/** @var int */
public int $Id=0,
/** @description Part number. */
// @ApiMember(Description="Part number.")
/** @var string|null */
public ?string $PartNumber=null,
/** @description Description of the part. */
// @ApiMember(Description="Description of the part.")
/** @var string|null */
public ?string $Description=null,
/** @description Part manufacturer. */
// @ApiMember(Description="Part manufacturer.")
/** @var string|null */
public ?string $Manufacturer=null,
/** @description Determines if the part can be ordered. */
// @ApiMember(Description="Determines if the part can be ordered.")
/** @var bool|null */
public ?bool $CanBeOrdered=null,
/** @description Textual representation of the status of the part. */
// @ApiMember(Description="Textual representation of the status of the part.")
/** @var string|null */
public ?string $StatusText=null,
/** @description Available stock to order. */
// @ApiMember(Description="Available stock to order.")
/** @var int */
public int $AvailableStockQuantity=0,
/** @description Average days needed for delivery. */
// @ApiMember(Description="Average days needed for delivery.")
/** @var int|null */
public ?int $AverageDeliveryInDays=null,
/** @description Price of a single unit, excluding VAT. */
// @ApiMember(Description="Price of a single unit, excluding VAT.")
/** @var float|null */
public ?float $UnitPrice=null,
/** @description EAN number. */
// @ApiMember(Description="EAN number.")
/** @var string|null */
public ?string $EanNumber=null,
/** @description Images */
// @ApiMember(Description="Images")
/** @var array<PartInfoResultImage>|null */
public ?array $Images=null,
/** @description Secondary article numbers */
// @ApiMember(Description="Secondary article numbers")
/** @var array<string>|null */
public ?array $SecondaryArticleNumbers=null,
/** @description Replacement article numbers */
// @ApiMember(Description="Replacement article numbers")
/** @var array<string>|null */
public ?array $ReplacementArticleNumbers=null,
/** @description Stock quantities */
// @ApiMember(Description="Stock quantities")
/** @var array<PartStockQuantity>|null */
public ?array $StockQuantities=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['PartNumber'])) $this->PartNumber = $o['PartNumber'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Manufacturer'])) $this->Manufacturer = $o['Manufacturer'];
if (isset($o['CanBeOrdered'])) $this->CanBeOrdered = $o['CanBeOrdered'];
if (isset($o['StatusText'])) $this->StatusText = $o['StatusText'];
if (isset($o['AvailableStockQuantity'])) $this->AvailableStockQuantity = $o['AvailableStockQuantity'];
if (isset($o['AverageDeliveryInDays'])) $this->AverageDeliveryInDays = $o['AverageDeliveryInDays'];
if (isset($o['UnitPrice'])) $this->UnitPrice = $o['UnitPrice'];
if (isset($o['EanNumber'])) $this->EanNumber = $o['EanNumber'];
if (isset($o['Images'])) $this->Images = JsonConverters::fromArray('PartInfoResultImage', $o['Images']);
if (isset($o['SecondaryArticleNumbers'])) $this->SecondaryArticleNumbers = JsonConverters::fromArray('string', $o['SecondaryArticleNumbers']);
if (isset($o['ReplacementArticleNumbers'])) $this->ReplacementArticleNumbers = JsonConverters::fromArray('string', $o['ReplacementArticleNumbers']);
if (isset($o['StockQuantities'])) $this->StockQuantities = JsonConverters::fromArray('PartStockQuantity', $o['StockQuantities']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->PartNumber)) $o['PartNumber'] = $this->PartNumber;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Manufacturer)) $o['Manufacturer'] = $this->Manufacturer;
if (isset($this->CanBeOrdered)) $o['CanBeOrdered'] = $this->CanBeOrdered;
if (isset($this->StatusText)) $o['StatusText'] = $this->StatusText;
if (isset($this->AvailableStockQuantity)) $o['AvailableStockQuantity'] = $this->AvailableStockQuantity;
if (isset($this->AverageDeliveryInDays)) $o['AverageDeliveryInDays'] = $this->AverageDeliveryInDays;
if (isset($this->UnitPrice)) $o['UnitPrice'] = $this->UnitPrice;
if (isset($this->EanNumber)) $o['EanNumber'] = $this->EanNumber;
if (isset($this->Images)) $o['Images'] = JsonConverters::toArray('PartInfoResultImage', $this->Images);
if (isset($this->SecondaryArticleNumbers)) $o['SecondaryArticleNumbers'] = JsonConverters::toArray('string', $this->SecondaryArticleNumbers);
if (isset($this->ReplacementArticleNumbers)) $o['ReplacementArticleNumbers'] = JsonConverters::toArray('string', $this->ReplacementArticleNumbers);
if (isset($this->StockQuantities)) $o['StockQuantities'] = JsonConverters::toArray('PartStockQuantity', $this->StockQuantities);
return empty($o) ? new class(){} : $o;
}
}
class PartResults implements JsonSerializable
{
public function __construct(
/** @description Total number of parts available. */
// @ApiMember(Description="Total number of parts available.")
/** @var int */
public int $TotalNumberOfParts=0,
/** @description Indication if there are more parts to retrieve. */
// @ApiMember(Description="Indication if there are more parts to retrieve.")
/** @var bool|null */
public ?bool $HasMoreRecords=null,
/** @description Part records. */
// @ApiMember(Description="Part records.")
/** @var array<PartInfoResult>|null */
public ?array $Parts=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['TotalNumberOfParts'])) $this->TotalNumberOfParts = $o['TotalNumberOfParts'];
if (isset($o['HasMoreRecords'])) $this->HasMoreRecords = $o['HasMoreRecords'];
if (isset($o['Parts'])) $this->Parts = JsonConverters::fromArray('PartInfoResult', $o['Parts']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->TotalNumberOfParts)) $o['TotalNumberOfParts'] = $this->TotalNumberOfParts;
if (isset($this->HasMoreRecords)) $o['HasMoreRecords'] = $this->HasMoreRecords;
if (isset($this->Parts)) $o['Parts'] = JsonConverters::toArray('PartInfoResult', $this->Parts);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template T
*/
class OperationResult1 extends OperationResult implements JsonSerializable
{
public array $genericArgs = [];
public static function create(array $genericArgs=[]): OperationResult1 {
$to = new OperationResult1();
$to->genericArgs = $genericArgs;
return $to;
}
/**
* @param bool|null $IsSuccessful
* @param string|null $ErrorMessage
*/
public function __construct(
mixed $IsSuccessful=null,
mixed $ErrorMessage=null,
/** @description Result value */
// @ApiMember(Description="Result value", ParameterType="model")
/** @var PartResults|null */
public mixed $Result=null
) {
parent::__construct($IsSuccessful,$ErrorMessage);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Result'])) $this->Result = JsonConverters::from('PartResults', $o['Result']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Result)) $o['Result'] = JsonConverters::to('PartResults', $this->Result);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template OperationResult1 of NewOrderResult
*/
class NewOrderResponse extends OperationResult1 implements JsonSerializable
{
/**
* @param bool|null $IsSuccessful
* @param string|null $ErrorMessage
* @param PartResults|null $Result
*/
public function __construct(
?bool $IsSuccessful=null,
?string $ErrorMessage=null,
?PartResults $Result=null
) {
parent::__construct($IsSuccessful,$ErrorMessage,$Result);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
return empty($o) ? new class(){} : $o;
}
}
class NewOrderItem implements JsonSerializable
{
public function __construct(
/** @description Unique ID for the part. */
// @ApiMember(Description="Unique ID for the part.", IsRequired=true, ParameterType="body")
/** @var int */
public int $PartId=0,
/** @description Quantity to order. */
// @ApiMember(Description="Quantity to order.", IsRequired=true, ParameterType="body")
/** @var int */
public int $Quantity=0,
/** @description Custom reference. */
// @ApiMember(Description="Custom reference.", ParameterType="body")
/** @var string|null */
public ?string $Reference=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['PartId'])) $this->PartId = $o['PartId'];
if (isset($o['Quantity'])) $this->Quantity = $o['Quantity'];
if (isset($o['Reference'])) $this->Reference = $o['Reference'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->PartId)) $o['PartId'] = $this->PartId;
if (isset($this->Quantity)) $o['Quantity'] = $this->Quantity;
if (isset($this->Reference)) $o['Reference'] = $this->Reference;
return empty($o) ? new class(){} : $o;
}
}
/**
* @template array of NewOrderItem
*/
class NewOrderItemList extends \ArrayObject implements JsonSerializable
{
public function __construct(NewOrderItem ...$items) {
parent::__construct($items, \ArrayObject::STD_PROP_LIST);
}
/** @throws \Exception */
public function append($value): void {
if ($value instanceof NewOrderItem)
parent::append($value);
else
throw new \Exception("Can only append a NewOrderItem to " . __CLASS__);
}
/** @throws Exception */
public function fromMap($o): void {
foreach ($o as $item) {
$el = new NewOrderItem();
$el->fromMap($item);
$this->append($el);
}
}
/** @throws Exception */
public function jsonSerialize(): array {
return parent::getArrayCopy();
}
}
class NewOrderAddress implements IAddress, JsonSerializable
{
public function __construct(
/** @description Company name. */
// @ApiMember(Description="Company name.", ParameterType="body")
/** @var string|null */
public ?string $CompanyName=null,
/** @description First name. */
// @ApiMember(Description="First name.", ParameterType="body")
/** @var string|null */
public ?string $FirstName=null,
/** @description Last name. */
// @ApiMember(Description="Last name.", ParameterType="body")
/** @var string|null */
public ?string $LastName=null,
/** @description Street name. */
// @ApiMember(Description="Street name.", IsRequired=true, ParameterType="body")
/** @var string */
public string $StreetName='',
/** @description House number. */
// @ApiMember(Description="House number.", IsRequired=true, ParameterType="body")
/** @var string */
public string $HouseNumber='',
/** @description House number addition. */
// @ApiMember(Description="House number addition.", ParameterType="body")
/** @var string|null */
public ?string $HouseNumberAddition=null,
/** @description Postal code. */
// @ApiMember(Description="Postal code.", IsRequired=true, ParameterType="body")
/** @var string */
public string $PostalCode='',
/** @description City. */
// @ApiMember(Description="City.", IsRequired=true, ParameterType="body")
/** @var string */
public string $City='',
/** @description Country code. */
// @ApiMember(Description="Country code.", IsRequired=true, ParameterType="body")
/** @var string */
public string $CountryCode='',
/** @description Telephone number. */
// @ApiMember(Description="Telephone number.", ParameterType="body")
/** @var string|null */
public ?string $TelephoneNumber=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyName'])) $this->CompanyName = $o['CompanyName'];
if (isset($o['FirstName'])) $this->FirstName = $o['FirstName'];
if (isset($o['LastName'])) $this->LastName = $o['LastName'];
if (isset($o['StreetName'])) $this->StreetName = $o['StreetName'];
if (isset($o['HouseNumber'])) $this->HouseNumber = $o['HouseNumber'];
if (isset($o['HouseNumberAddition'])) $this->HouseNumberAddition = $o['HouseNumberAddition'];
if (isset($o['PostalCode'])) $this->PostalCode = $o['PostalCode'];
if (isset($o['City'])) $this->City = $o['City'];
if (isset($o['CountryCode'])) $this->CountryCode = $o['CountryCode'];
if (isset($o['TelephoneNumber'])) $this->TelephoneNumber = $o['TelephoneNumber'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyName)) $o['CompanyName'] = $this->CompanyName;
if (isset($this->FirstName)) $o['FirstName'] = $this->FirstName;
if (isset($this->LastName)) $o['LastName'] = $this->LastName;
if (isset($this->StreetName)) $o['StreetName'] = $this->StreetName;
if (isset($this->HouseNumber)) $o['HouseNumber'] = $this->HouseNumber;
if (isset($this->HouseNumberAddition)) $o['HouseNumberAddition'] = $this->HouseNumberAddition;
if (isset($this->PostalCode)) $o['PostalCode'] = $this->PostalCode;
if (isset($this->City)) $o['City'] = $this->City;
if (isset($this->CountryCode)) $o['CountryCode'] = $this->CountryCode;
if (isset($this->TelephoneNumber)) $o['TelephoneNumber'] = $this->TelephoneNumber;
return empty($o) ? new class(){} : $o;
}
}
class PostNewOrder extends AuthenticatedRequest implements JsonSerializable
{
/**
* @param string $SessionToken
*/
public function __construct(
string $SessionToken='',
/** @description Items to order. */
// @ApiMember(Description="Items to order.", IsRequired=true, ParameterType="body")
/** @var NewOrderItemList|null */
public ?NewOrderItemList $Items=null,
/** @description Dropshipment indication. */
// @ApiMember(Description="Dropshipment indication.", ParameterType="body")
/** @var bool|null */
public ?bool $UseDropshipment=null,
/** @description Delivery address. */
// @ApiMember(Description="Delivery address.", ParameterType="body")
/** @var NewOrderAddress|null */
public ?NewOrderAddress $DeliveryAddress=null
) {
parent::__construct($SessionToken);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Items'])) $this->Items = JsonConverters::from('NewOrderItemList', $o['Items']);
if (isset($o['UseDropshipment'])) $this->UseDropshipment = $o['UseDropshipment'];
if (isset($o['DeliveryAddress'])) $this->DeliveryAddress = JsonConverters::from('NewOrderAddress', $o['DeliveryAddress']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Items)) $o['Items'] = JsonConverters::to('NewOrderItemList', $this->Items);
if (isset($this->UseDropshipment)) $o['UseDropshipment'] = $this->UseDropshipment;
if (isset($this->DeliveryAddress)) $o['DeliveryAddress'] = JsonConverters::to('NewOrderAddress', $this->DeliveryAddress);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /dealers/order HTTP/1.1
Host: services.acct.2service.nl
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<PostNewOrder xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers">
<SessionToken>String</SessionToken>
<DeliveryAddress>
<City>String</City>
<CompanyName>String</CompanyName>
<CountryCode>String</CountryCode>
<FirstName>String</FirstName>
<HouseNumber>String</HouseNumber>
<HouseNumberAddition>String</HouseNumberAddition>
<LastName>String</LastName>
<PostalCode>String</PostalCode>
<StreetName>String</StreetName>
<TelephoneNumber>String</TelephoneNumber>
</DeliveryAddress>
<Items>
<NewOrderItem>
<PartId>0</PartId>
<Quantity>0</Quantity>
<Reference>String</Reference>
</NewOrderItem>
</Items>
<UseDropshipment>false</UseDropshipment>
</PostNewOrder>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<NewOrderResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers">
<ErrorMessage xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">String</ErrorMessage>
<IsSuccessful xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">false</IsSuccessful>
<Result xmlns:d2p1="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel.Dealers" xmlns="http://schemas.datacontract.org/2004/07/_2Service.Webservices.ServiceModel">
<d2p1:OrderNumber>String</d2p1:OrderNumber>
</Result>
</NewOrderResponse>