| GET | /price/{brand} | Get the list of prices of the requested 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 DealerCostPrice implements JsonSerializable
{
public function __construct(
/** @description Currency of the Dealer Cost Price */
// @ApiMember(Description="Currency of the Dealer Cost Price", IsRequired=true)
/** @var string */
public string $currency='',
/** @description Dealer Cost Price of the item */
// @ApiMember(Description="Dealer Cost Price of the item", IsRequired=true)
/** @var float */
public float $price=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['currency'])) $this->currency = $o['currency'];
if (isset($o['price'])) $this->price = $o['price'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->currency)) $o['currency'] = $this->currency;
if (isset($this->price)) $o['price'] = $this->price;
return empty($o) ? new class(){} : $o;
}
}
class Price implements JsonSerializable
{
public function __construct(
/** @description Reference Code of the item */
// @ApiMember(Description="Reference Code of the item", IsRequired=true)
/** @var string */
public string $articleCode='',
/** @description Currency of the price */
// @ApiMember(Description="Currency of the price", IsRequired=true)
/** @var string */
public string $currency='',
/** @description Retail price of the item */
// @ApiMember(Description="Retail price of the item")
/** @var float */
public float $retailSalePrice=0.0,
/** @description Code of currency applied */
// @ApiMember(Description="Code of currency applied", IsRequired=true)
/** @var string */
public string $priceListCode='',
/** @description Dealer Cost Price */
// @ApiMember(Description="Dealer Cost Price")
/** @var DealerCostPrice|null */
public ?DealerCostPrice $dealerCostPrice=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['articleCode'])) $this->articleCode = $o['articleCode'];
if (isset($o['currency'])) $this->currency = $o['currency'];
if (isset($o['retailSalePrice'])) $this->retailSalePrice = $o['retailSalePrice'];
if (isset($o['priceListCode'])) $this->priceListCode = $o['priceListCode'];
if (isset($o['dealerCostPrice'])) $this->dealerCostPrice = JsonConverters::from('DealerCostPrice', $o['dealerCostPrice']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->articleCode)) $o['articleCode'] = $this->articleCode;
if (isset($this->currency)) $o['currency'] = $this->currency;
if (isset($this->retailSalePrice)) $o['retailSalePrice'] = $this->retailSalePrice;
if (isset($this->priceListCode)) $o['priceListCode'] = $this->priceListCode;
if (isset($this->dealerCostPrice)) $o['dealerCostPrice'] = JsonConverters::to('DealerCostPrice', $this->dealerCostPrice);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template array of Price
*/
class GetPriceResponse extends \ArrayObject implements JsonSerializable
{
public function __construct(Price ...$items) {
parent::__construct($items, \ArrayObject::STD_PROP_LIST);
}
/** @throws \Exception */
public function append($value): void {
if ($value instanceof Price)
parent::append($value);
else
throw new \Exception("Can only append a Price to " . __CLASS__);
}
/** @throws Exception */
public function fromMap($o): void {
foreach ($o as $item) {
$el = new Price();
$el->fromMap($item);
$this->append($el);
}
}
/** @throws Exception */
public function jsonSerialize(): array {
return parent::getArrayCopy();
}
}
class GetPrice implements JsonSerializable
{
public function __construct(
/** @description Brand */
// @ApiMember(Description="Brand", IsRequired=true)
/** @var string */
public string $brand='',
/** @description POS Legacy */
// @ApiMember(Description="POS Legacy", IsRequired=true)
/** @var string */
public string $posCode='',
/** @description List of Article Codes */
// @ApiMember(Description="List of Article Codes", IsRequired=true)
/** @var array<string>|null */
public ?array $articleCodes=null,
/** @description Include Dealer Cost Price in the response */
// @ApiMember(Description="Include Dealer Cost Price in the response", IsRequired=true)
/** @var bool|null */
public ?bool $includeDealerCostPrice=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['articleCodes'])) $this->articleCodes = JsonConverters::fromArray('string', $o['articleCodes']);
if (isset($o['includeDealerCostPrice'])) $this->includeDealerCostPrice = $o['includeDealerCostPrice'];
}
/** @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->articleCodes)) $o['articleCodes'] = JsonConverters::toArray('string', $this->articleCodes);
if (isset($this->includeDealerCostPrice)) $o['includeDealerCostPrice'] = $this->includeDealerCostPrice;
return empty($o) ? new class(){} : $o;
}
}
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.
GET /price/{brand} HTTP/1.1
Host: dev-api-booster.richemont.com
Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length [ ]