| GET | /stock/{brand} | Get stock |
|---|
<?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 StockRequest implements JsonSerializable
{
public function __construct(
/** @description Brand */
// @ApiMember(Description="Brand", IsRequired=true)
/** @var string */
public string $brand='',
/** @description POS Legacy */
// @ApiMember(Description="POS Legacy")
/** @var array<string>|null */
public ?array $posCodes=null,
/** @description Article Codes */
// @ApiMember(Description="Article Codes")
/** @var array<string>|null */
public ?array $articleCodes=null,
/** @description Include Extra Info */
// @ApiMember(Description="Include Extra Info")
/** @var bool|null */
public ?bool $includeExtraInfo=null,
/** @description Cluster Id */
// @ApiMember(Description="Cluster Id")
/** @var array<string>|null */
public ?array $clusterIds=null,
/** @description Include Consignment NotAuthorized POS */
// @ApiMember(Description="Include Consignment NotAuthorized POS")
/** @var bool|null */
public ?bool $includeConsignmentNotAuthorizedPOS=null,
/** @description Include Retail Sales Price in the Output, by default: false */
// @ApiMember(Description="Include Retail Sales Price in the Output, by default: false")
/** @var bool|null */
public ?bool $includeRSP=null,
/** @description In Stock Since date from */
// @ApiMember(Description="In Stock Since date from ")
/** @var DateTime|null */
public ?DateTime $dateFrom=null,
/** @description In Stock Since date to */
// @ApiMember(Description="In Stock Since date to")
/** @var DateTime|null */
public ?DateTime $dateTo=null,
/** @description Item type, 'standard' OR 'consigned'. By default, all are coming */
// @ApiMember(Description="Item type, 'standard' OR 'consigned'. By default, all are coming")
/** @var string|null */
public ?string $type=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['brand'])) $this->brand = $o['brand'];
if (isset($o['posCodes'])) $this->posCodes = JsonConverters::fromArray('string', $o['posCodes']);
if (isset($o['articleCodes'])) $this->articleCodes = JsonConverters::fromArray('string', $o['articleCodes']);
if (isset($o['includeExtraInfo'])) $this->includeExtraInfo = $o['includeExtraInfo'];
if (isset($o['clusterIds'])) $this->clusterIds = JsonConverters::fromArray('string', $o['clusterIds']);
if (isset($o['includeConsignmentNotAuthorizedPOS'])) $this->includeConsignmentNotAuthorizedPOS = $o['includeConsignmentNotAuthorizedPOS'];
if (isset($o['includeRSP'])) $this->includeRSP = $o['includeRSP'];
if (isset($o['dateFrom'])) $this->dateFrom = JsonConverters::from('DateTime', $o['dateFrom']);
if (isset($o['dateTo'])) $this->dateTo = JsonConverters::from('DateTime', $o['dateTo']);
if (isset($o['type'])) $this->type = $o['type'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->brand)) $o['brand'] = $this->brand;
if (isset($this->posCodes)) $o['posCodes'] = JsonConverters::toArray('string', $this->posCodes);
if (isset($this->articleCodes)) $o['articleCodes'] = JsonConverters::toArray('string', $this->articleCodes);
if (isset($this->includeExtraInfo)) $o['includeExtraInfo'] = $this->includeExtraInfo;
if (isset($this->clusterIds)) $o['clusterIds'] = JsonConverters::toArray('string', $this->clusterIds);
if (isset($this->includeConsignmentNotAuthorizedPOS)) $o['includeConsignmentNotAuthorizedPOS'] = $this->includeConsignmentNotAuthorizedPOS;
if (isset($this->includeRSP)) $o['includeRSP'] = $this->includeRSP;
if (isset($this->dateFrom)) $o['dateFrom'] = JsonConverters::to('DateTime', $this->dateFrom);
if (isset($this->dateTo)) $o['dateTo'] = JsonConverters::to('DateTime', $this->dateTo);
if (isset($this->type)) $o['type'] = $this->type;
return empty($o) ? new class(){} : $o;
}
}
class Pos implements JsonSerializable
{
public function __construct(
/** @description Name of the POS */
// @ApiMember(Description="Name of the POS", IsRequired=true)
/** @var string */
public string $name='',
/** @description POS Code */
// @ApiMember(Description="POS Code", IsRequired=true)
/** @var string */
public string $posCode='',
/** @description Pos Code To Be Displayed */
// @ApiMember(Description="Pos Code To Be Displayed", IsRequired=true)
/** @var string */
public string $posCodeToBeDisplayed='',
/** @description Country of the POS */
// @ApiMember(Description="Country of the POS", IsRequired=true)
/** @var string */
public string $country='',
/** @description City of the POS */
// @ApiMember(Description="City of the POS", IsRequired=true)
/** @var string */
public string $city='',
/** @description Postal Code */
// @ApiMember(Description="Postal Code", IsRequired=true)
/** @var string */
public string $postalCode='',
/** @description State */
// @ApiMember(Description="State", IsRequired=true)
/** @var string */
public string $state='',
/** @description Street */
// @ApiMember(Description="Street", IsRequired=true)
/** @var string */
public string $street=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['posCode'])) $this->posCode = $o['posCode'];
if (isset($o['posCodeToBeDisplayed'])) $this->posCodeToBeDisplayed = $o['posCodeToBeDisplayed'];
if (isset($o['country'])) $this->country = $o['country'];
if (isset($o['city'])) $this->city = $o['city'];
if (isset($o['postalCode'])) $this->postalCode = $o['postalCode'];
if (isset($o['state'])) $this->state = $o['state'];
if (isset($o['street'])) $this->street = $o['street'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->posCode)) $o['posCode'] = $this->posCode;
if (isset($this->posCodeToBeDisplayed)) $o['posCodeToBeDisplayed'] = $this->posCodeToBeDisplayed;
if (isset($this->country)) $o['country'] = $this->country;
if (isset($this->city)) $o['city'] = $this->city;
if (isset($this->postalCode)) $o['postalCode'] = $this->postalCode;
if (isset($this->state)) $o['state'] = $this->state;
if (isset($this->street)) $o['street'] = $this->street;
return empty($o) ? new class(){} : $o;
}
}
class UnitNetAmount implements JsonSerializable
{
public function __construct(
/** @description Currency Iso Code */
// @ApiMember(Description="Currency Iso Code", IsRequired=true)
/** @var string */
public string $currencyIsoCode='',
/** @description Value */
// @ApiMember(Description="Value", IsRequired=true)
/** @var float */
public float $value=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['currencyIsoCode'])) $this->currencyIsoCode = $o['currencyIsoCode'];
if (isset($o['value'])) $this->value = $o['value'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->currencyIsoCode)) $o['currencyIsoCode'] = $this->currencyIsoCode;
if (isset($this->value)) $o['value'] = $this->value;
return empty($o) ? new class(){} : $o;
}
}
class StockPositionItem implements JsonSerializable
{
public function __construct(
/** @description Quantity */
// @ApiMember(Description="Quantity", IsRequired=true)
/** @var int */
public int $quantity=0,
/** @description Serial Number */
// @ApiMember(Description="Serial Number")
/** @var string|null */
public ?string $serialNumber=null,
/** @description Stock Date */
// @ApiMember(Description="Stock Date", IsRequired=true)
/** @var string */
public string $stockDate='',
/** @description Loaded On Date */
// @ApiMember(Description="Loaded On Date", IsRequired=true)
/** @var string */
public string $loadedOnDate='',
/** @description Type e.g. consignment or standard */
// @ApiMember(Description="Type e.g. consignment or standard", IsRequired=true)
/** @var string */
public string $type='',
/** @description Is Consignment Sellable */
// @ApiMember(Description="Is Consignment Sellable ", IsRequired=true)
/** @var bool|null */
public ?bool $isConsignmentSellable=null,
/** @description Sell-In Price. Disclaimer: this data will be arriving empty/null due to DealerCost project still being in test phase. */
// @ApiMember(Description="Sell-In Price. Disclaimer: this data will be arriving empty/null due to DealerCost project still being in test phase.")
/** @var UnitNetAmount|null */
public ?UnitNetAmount $unitNetAmount=null,
/** @description Retail Sales Price */
// @ApiMember(Description="Retail Sales Price")
/** @var UnitNetAmount|null */
public ?UnitNetAmount $retailSalesPrice=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['quantity'])) $this->quantity = $o['quantity'];
if (isset($o['serialNumber'])) $this->serialNumber = $o['serialNumber'];
if (isset($o['stockDate'])) $this->stockDate = $o['stockDate'];
if (isset($o['loadedOnDate'])) $this->loadedOnDate = $o['loadedOnDate'];
if (isset($o['type'])) $this->type = $o['type'];
if (isset($o['isConsignmentSellable'])) $this->isConsignmentSellable = $o['isConsignmentSellable'];
if (isset($o['unitNetAmount'])) $this->unitNetAmount = JsonConverters::from('UnitNetAmount', $o['unitNetAmount']);
if (isset($o['retailSalesPrice'])) $this->retailSalesPrice = JsonConverters::from('UnitNetAmount', $o['retailSalesPrice']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->quantity)) $o['quantity'] = $this->quantity;
if (isset($this->serialNumber)) $o['serialNumber'] = $this->serialNumber;
if (isset($this->stockDate)) $o['stockDate'] = $this->stockDate;
if (isset($this->loadedOnDate)) $o['loadedOnDate'] = $this->loadedOnDate;
if (isset($this->type)) $o['type'] = $this->type;
if (isset($this->isConsignmentSellable)) $o['isConsignmentSellable'] = $this->isConsignmentSellable;
if (isset($this->unitNetAmount)) $o['unitNetAmount'] = JsonConverters::to('UnitNetAmount', $this->unitNetAmount);
if (isset($this->retailSalesPrice)) $o['retailSalesPrice'] = JsonConverters::to('UnitNetAmount', $this->retailSalesPrice);
return empty($o) ? new class(){} : $o;
}
}
class StockItem implements JsonSerializable
{
public function __construct(
/** @description Article Code */
// @ApiMember(Description="Article Code", IsRequired=true)
/** @var string */
public string $articleCode='',
/** @description Current Stock Quantity */
// @ApiMember(Description="Current Stock Quantity", IsRequired=true)
/** @var int */
public int $currentStockQuantity=0,
/** @description Serial Numbers */
// @ApiMember(Description="Serial Numbers")
/** @var array<string>|null */
public ?array $serialNumbers=null,
/** @description Stock Item in Details */
// @ApiMember(Description="Stock Item in Details", IsRequired=true)
/** @var array<StockPositionItem>|null */
public ?array $stockPositions=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['articleCode'])) $this->articleCode = $o['articleCode'];
if (isset($o['currentStockQuantity'])) $this->currentStockQuantity = $o['currentStockQuantity'];
if (isset($o['serialNumbers'])) $this->serialNumbers = JsonConverters::fromArray('string', $o['serialNumbers']);
if (isset($o['stockPositions'])) $this->stockPositions = JsonConverters::fromArray('StockPositionItem', $o['stockPositions']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->articleCode)) $o['articleCode'] = $this->articleCode;
if (isset($this->currentStockQuantity)) $o['currentStockQuantity'] = $this->currentStockQuantity;
if (isset($this->serialNumbers)) $o['serialNumbers'] = JsonConverters::toArray('string', $this->serialNumbers);
if (isset($this->stockPositions)) $o['stockPositions'] = JsonConverters::toArray('StockPositionItem', $this->stockPositions);
return empty($o) ? new class(){} : $o;
}
}
class PosStockItem implements JsonSerializable
{
public function __construct(
/** @description Brand */
// @ApiMember(Description="Brand", IsRequired=true)
/** @var string */
public string $brand='',
/** @description Pos Code */
// @ApiMember(Description="Pos Code", IsRequired=true)
/** @var string */
public string $posCode='',
/** @description Shared Stock Location */
// @ApiMember(Description="Shared Stock Location", IsRequired=true)
/** @var Pos|null */
public ?Pos $sharedStockLocation=null,
/** @description Stock Items */
// @ApiMember(Description="Stock Items")
/** @var array<StockItem>|null */
public ?array $stockItems=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['brand'])) $this->brand = $o['brand'];
if (isset($o['posCode'])) $this->posCode = $o['posCode'];
if (isset($o['sharedStockLocation'])) $this->sharedStockLocation = JsonConverters::from('Pos', $o['sharedStockLocation']);
if (isset($o['stockItems'])) $this->stockItems = JsonConverters::fromArray('StockItem', $o['stockItems']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->brand)) $o['brand'] = $this->brand;
if (isset($this->posCode)) $o['posCode'] = $this->posCode;
if (isset($this->sharedStockLocation)) $o['sharedStockLocation'] = JsonConverters::to('Pos', $this->sharedStockLocation);
if (isset($this->stockItems)) $o['stockItems'] = JsonConverters::toArray('StockItem', $this->stockItems);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template array of PosStockItem
*/
class GetStockResponse extends \ArrayObject implements JsonSerializable
{
public function __construct(PosStockItem ...$items) {
parent::__construct($items, \ArrayObject::STD_PROP_LIST);
}
/** @throws \Exception */
public function append($value): void {
if ($value instanceof PosStockItem)
parent::append($value);
else
throw new \Exception("Can only append a PosStockItem to " . __CLASS__);
}
/** @throws Exception */
public function fromMap($o): void {
foreach ($o as $item) {
$el = new PosStockItem();
$el->fromMap($item);
$this->append($el);
}
}
/** @throws Exception */
public function jsonSerialize(): array {
return parent::getArrayCopy();
}
}
class GetStock extends StockRequest implements JsonSerializable
{
/**
* @param string $brand
* @param array<string>|null $posCodes
* @param array<string>|null $articleCodes
* @param bool|null $includeExtraInfo
* @param array<string>|null $clusterIds
* @param bool|null $includeConsignmentNotAuthorizedPOS
* @param bool|null $includeRSP
* @param DateTime|null $dateFrom
* @param DateTime|null $dateTo
* @param string|null $type
*/
public function __construct(
string $brand='',
?array $posCodes=null,
?array $articleCodes=null,
?bool $includeExtraInfo=null,
?array $clusterIds=null,
?bool $includeConsignmentNotAuthorizedPOS=null,
?bool $includeRSP=null,
?DateTime $dateFrom=null,
?DateTime $dateTo=null,
?string $type=null
) {
parent::__construct($brand,$posCodes,$articleCodes,$includeExtraInfo,$clusterIds,$includeConsignmentNotAuthorizedPOS,$includeRSP,$dateFrom,$dateTo,$type);
}
/** @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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /stock/{brand} HTTP/1.1
Host: dev-api-booster.richemont.com
Accept: text/csv
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length []