| GET | /stock/{brand}/movement | Get movements |
|---|
<?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 MovementsRequest 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 array<string>|null */
public ?array $posCodes=null,
/** @description Movement Type Ids */
// @ApiMember(Description="Movement Type Ids")
/** @var array<int>|null */
public ?array $movementTypeIds=null,
/** @description Search Key (Article or SerialNumber) */
// @ApiMember(Description="Search Key (Article or SerialNumber)")
/** @var string|null */
public ?string $searchKey=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 Sort by date could be: 'DateDESC' or 'DateASC' (default is descending) */
// @ApiMember(Description="Sort by date could be: 'DateDESC' or 'DateASC' (default is descending) ")
/** @var string|null */
public ?string $sortBy=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['movementTypeIds'])) $this->movementTypeIds = JsonConverters::fromArray('int', $o['movementTypeIds']);
if (isset($o['searchKey'])) $this->searchKey = $o['searchKey'];
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['sortBy'])) $this->sortBy = $o['sortBy'];
}
/** @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->movementTypeIds)) $o['movementTypeIds'] = JsonConverters::toArray('int', $this->movementTypeIds);
if (isset($this->searchKey)) $o['searchKey'] = $this->searchKey;
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->sortBy)) $o['sortBy'] = $this->sortBy;
return empty($o) ? new class(){} : $o;
}
}
class Movement implements JsonSerializable
{
public function __construct(
/** @description Movement Id */
// @ApiMember(Description="Movement Id", IsRequired=true)
/** @var int */
public int $movementId=0,
/** @description Pos Code */
// @ApiMember(Description="Pos Code", IsRequired=true)
/** @var string */
public string $posCode='',
/** @description Pos Name */
// @ApiMember(Description="Pos Name", IsRequired=true)
/** @var string */
public string $posName='',
/** @description Created By */
// @ApiMember(Description="Created By", IsRequired=true)
/** @var string */
public string $createdBy='',
/** @description Movement Date */
// @ApiMember(Description="Movement Date", IsRequired=true)
/** @var string */
public string $movementDate='',
/** @description Article Code */
// @ApiMember(Description="Article Code", IsRequired=true)
/** @var string */
public string $articleCode='',
/** @description Serial Number */
// @ApiMember(Description="Serial Number", IsRequired=true)
/** @var string */
public string $serialNumber='',
/** @description Quantity */
// @ApiMember(Description="Quantity", IsRequired=true)
/** @var int */
public int $quantity=0,
/** @description Movement Type Id */
// @ApiMember(Description="Movement Type Id", IsRequired=true)
/** @var int */
public int $movementTypeId=0,
/** @description Comments */
// @ApiMember(Description="Comments", IsRequired=true)
/** @var string */
public string $comments=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['movementId'])) $this->movementId = $o['movementId'];
if (isset($o['posCode'])) $this->posCode = $o['posCode'];
if (isset($o['posName'])) $this->posName = $o['posName'];
if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
if (isset($o['movementDate'])) $this->movementDate = $o['movementDate'];
if (isset($o['articleCode'])) $this->articleCode = $o['articleCode'];
if (isset($o['serialNumber'])) $this->serialNumber = $o['serialNumber'];
if (isset($o['quantity'])) $this->quantity = $o['quantity'];
if (isset($o['movementTypeId'])) $this->movementTypeId = $o['movementTypeId'];
if (isset($o['comments'])) $this->comments = $o['comments'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->movementId)) $o['movementId'] = $this->movementId;
if (isset($this->posCode)) $o['posCode'] = $this->posCode;
if (isset($this->posName)) $o['posName'] = $this->posName;
if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
if (isset($this->movementDate)) $o['movementDate'] = $this->movementDate;
if (isset($this->articleCode)) $o['articleCode'] = $this->articleCode;
if (isset($this->serialNumber)) $o['serialNumber'] = $this->serialNumber;
if (isset($this->quantity)) $o['quantity'] = $this->quantity;
if (isset($this->movementTypeId)) $o['movementTypeId'] = $this->movementTypeId;
if (isset($this->comments)) $o['comments'] = $this->comments;
return empty($o) ? new class(){} : $o;
}
}
class GetMovementsResponse implements JsonSerializable
{
public function __construct(
/** @description Total Pages */
// @ApiMember(Description="Total Pages", IsRequired=true)
/** @var int */
public int $totalPages=0,
/** @description Total Results */
// @ApiMember(Description="Total Results", IsRequired=true)
/** @var int */
public int $totalResults=0,
/** @description Index of the result set returned */
// @ApiMember(Description="Index of the result set returned", IsRequired=true)
/** @var int */
public int $page=0,
/** @description Size of the result set returned */
// @ApiMember(Description="Size of the result set returned", IsRequired=true)
/** @var int */
public int $items=0,
/** @description List of movements */
// @ApiMember(Description="List of movements", IsRequired=true)
/** @var array<Movement>|null */
public ?array $elements=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['totalPages'])) $this->totalPages = $o['totalPages'];
if (isset($o['totalResults'])) $this->totalResults = $o['totalResults'];
if (isset($o['page'])) $this->page = $o['page'];
if (isset($o['items'])) $this->items = $o['items'];
if (isset($o['elements'])) $this->elements = JsonConverters::fromArray('Movement', $o['elements']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->totalPages)) $o['totalPages'] = $this->totalPages;
if (isset($this->totalResults)) $o['totalResults'] = $this->totalResults;
if (isset($this->page)) $o['page'] = $this->page;
if (isset($this->items)) $o['items'] = $this->items;
if (isset($this->elements)) $o['elements'] = JsonConverters::toArray('Movement', $this->elements);
return empty($o) ? new class(){} : $o;
}
}
class GetMovements extends MovementsRequest implements IPagedRequest, JsonSerializable
{
/**
* @param string $brand
* @param array<string>|null $posCodes
* @param array<int>|null $movementTypeIds
* @param string|null $searchKey
* @param DateTime|null $dateFrom
* @param DateTime|null $dateTo
* @param string|null $sortBy
*/
public function __construct(
string $brand='',
?array $posCodes=null,
?array $movementTypeIds=null,
?string $searchKey=null,
?DateTime $dateFrom=null,
?DateTime $dateTo=null,
?string $sortBy=null,
/** @description Index of the result set returned */
// @ApiMember(Description="Index of the result set returned")
/** @var int */
public int $page=0,
/** @description Size of the result set returned */
// @ApiMember(Description="Size of the result set returned")
/** @var int */
public int $items=0,
/** @description Omit precise record count - save on performance */
// @ApiMember(Description="Omit precise record count - save on performance")
/** @var bool|null */
public ?bool $noCount=null
) {
parent::__construct($brand,$posCodes,$movementTypeIds,$searchKey,$dateFrom,$dateTo,$sortBy);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['page'])) $this->page = $o['page'];
if (isset($o['items'])) $this->items = $o['items'];
if (isset($o['noCount'])) $this->noCount = $o['noCount'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->page)) $o['page'] = $this->page;
if (isset($this->items)) $o['items'] = $this->items;
if (isset($this->noCount)) $o['noCount'] = $this->noCount;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /stock/{brand}/movement HTTP/1.1
Host: dev-api-booster.richemont.com
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"totalPages":0,"totalResults":0,"page":0,"items":0}