All Verbs | /query/orders |
---|
<?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};
// @DataContract
class QueryBase implements JsonSerializable
{
public function __construct(
// @DataMember(Order=1)
/** @var int|null */
public ?int $skip=null,
// @DataMember(Order=2)
/** @var int|null */
public ?int $take=null,
// @DataMember(Order=3)
/** @var string|null */
public ?string $orderBy=null,
// @DataMember(Order=4)
/** @var string|null */
public ?string $orderByDesc=null,
// @DataMember(Order=5)
/** @var string|null */
public ?string $include=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $fields=null,
// @DataMember(Order=7)
/** @var array<string,string>|null */
public ?array $meta=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['skip'])) $this->skip = $o['skip'];
if (isset($o['take'])) $this->take = $o['take'];
if (isset($o['orderBy'])) $this->orderBy = $o['orderBy'];
if (isset($o['orderByDesc'])) $this->orderByDesc = $o['orderByDesc'];
if (isset($o['include'])) $this->include = $o['include'];
if (isset($o['fields'])) $this->fields = $o['fields'];
if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->skip)) $o['skip'] = $this->skip;
if (isset($this->take)) $o['take'] = $this->take;
if (isset($this->orderBy)) $o['orderBy'] = $this->orderBy;
if (isset($this->orderByDesc)) $o['orderByDesc'] = $this->orderByDesc;
if (isset($this->include)) $o['include'] = $this->include;
if (isset($this->fields)) $o['fields'] = $this->fields;
if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template T
*/
class QueryDb extends QueryBase implements JsonSerializable
{
public array $genericArgs = [];
public static function create(array $genericArgs=[]): QueryDb {
$to = new QueryDb();
$to->genericArgs = $genericArgs;
return $to;
}
/**
* @param int|null $skip
* @param int|null $take
* @param string|null $orderBy
* @param string|null $orderByDesc
* @param string|null $include
* @param string|null $fields
* @param array<string,string>|null $meta
*/
public function __construct(
mixed $skip=null,
mixed $take=null,
mixed $orderBy=null,
mixed $orderByDesc=null,
mixed $include=null,
mixed $fields=null,
mixed $meta=null
) {
parent::__construct($skip,$take,$orderBy,$orderByDesc,$include,$fields,$meta);
}
/** @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;
}
}
// @DataContract
class Order implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var int */
public int $id=0,
// @DataMember
/** @var string */
public string $customerId='',
// @DataMember
/** @var int */
public int $employeeId=0,
// @DataMember
/** @var DateTime|null */
public ?DateTime $orderDate=null,
// @DataMember
/** @var DateTime|null */
public ?DateTime $requiredDate=null,
// @DataMember
/** @var DateTime|null */
public ?DateTime $shippedDate=null,
// @DataMember
/** @var int|null */
public ?int $shipVia=null,
// @DataMember
/** @var float */
public float $freight=0.0,
// @DataMember
/** @var string */
public string $shipName='',
// @DataMember
/** @var string */
public string $shipAddress='',
// @DataMember
/** @var string */
public string $shipCity='',
// @DataMember
/** @var string */
public string $shipRegion='',
// @DataMember
/** @var string */
public string $shipPostalCode='',
// @DataMember
/** @var string */
public string $shipCountry=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['customerId'])) $this->customerId = $o['customerId'];
if (isset($o['employeeId'])) $this->employeeId = $o['employeeId'];
if (isset($o['orderDate'])) $this->orderDate = JsonConverters::from('DateTime', $o['orderDate']);
if (isset($o['requiredDate'])) $this->requiredDate = JsonConverters::from('DateTime', $o['requiredDate']);
if (isset($o['shippedDate'])) $this->shippedDate = JsonConverters::from('DateTime', $o['shippedDate']);
if (isset($o['shipVia'])) $this->shipVia = $o['shipVia'];
if (isset($o['freight'])) $this->freight = $o['freight'];
if (isset($o['shipName'])) $this->shipName = $o['shipName'];
if (isset($o['shipAddress'])) $this->shipAddress = $o['shipAddress'];
if (isset($o['shipCity'])) $this->shipCity = $o['shipCity'];
if (isset($o['shipRegion'])) $this->shipRegion = $o['shipRegion'];
if (isset($o['shipPostalCode'])) $this->shipPostalCode = $o['shipPostalCode'];
if (isset($o['shipCountry'])) $this->shipCountry = $o['shipCountry'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->customerId)) $o['customerId'] = $this->customerId;
if (isset($this->employeeId)) $o['employeeId'] = $this->employeeId;
if (isset($this->orderDate)) $o['orderDate'] = JsonConverters::to('DateTime', $this->orderDate);
if (isset($this->requiredDate)) $o['requiredDate'] = JsonConverters::to('DateTime', $this->requiredDate);
if (isset($this->shippedDate)) $o['shippedDate'] = JsonConverters::to('DateTime', $this->shippedDate);
if (isset($this->shipVia)) $o['shipVia'] = $this->shipVia;
if (isset($this->freight)) $o['freight'] = $this->freight;
if (isset($this->shipName)) $o['shipName'] = $this->shipName;
if (isset($this->shipAddress)) $o['shipAddress'] = $this->shipAddress;
if (isset($this->shipCity)) $o['shipCity'] = $this->shipCity;
if (isset($this->shipRegion)) $o['shipRegion'] = $this->shipRegion;
if (isset($this->shipPostalCode)) $o['shipPostalCode'] = $this->shipPostalCode;
if (isset($this->shipCountry)) $o['shipCountry'] = $this->shipCountry;
return empty($o) ? new class(){} : $o;
}
}
/**
* @template QueryDb of Order
*/
class QueryOrders extends QueryDb implements JsonSerializable
{
/**
* @param int|null $skip
* @param int|null $take
* @param string|null $orderBy
* @param string|null $orderByDesc
* @param string|null $include
* @param string|null $fields
* @param array<string,string>|null $meta
*/
public function __construct(
?int $skip=null,
?int $take=null,
?string $orderBy=null,
?string $orderByDesc=null,
?string $include=null,
?string $fields=null,
?array $meta=null,
/** @var float|null */
public ?float $freight=null
) {
parent::__construct($skip,$take,$orderBy,$orderByDesc,$include,$fields,$meta);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['freight'])) $this->freight = $o['freight'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->freight)) $o['freight'] = $this->freight;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class Customer implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var string */
public string $id='',
// @DataMember
/** @var string */
public string $companyName='',
// @DataMember
/** @var string */
public string $contactName='',
// @DataMember
/** @var string */
public string $contactTitle='',
// @DataMember
/** @var string */
public string $address='',
// @DataMember
/** @var string */
public string $city='',
// @DataMember
/** @var string */
public string $region='',
// @DataMember
/** @var string */
public string $postalCode='',
// @DataMember
/** @var string */
public string $country='',
// @DataMember
/** @var string */
public string $phone='',
// @DataMember
/** @var string */
public string $fax=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['companyName'])) $this->companyName = $o['companyName'];
if (isset($o['contactName'])) $this->contactName = $o['contactName'];
if (isset($o['contactTitle'])) $this->contactTitle = $o['contactTitle'];
if (isset($o['address'])) $this->address = $o['address'];
if (isset($o['city'])) $this->city = $o['city'];
if (isset($o['region'])) $this->region = $o['region'];
if (isset($o['postalCode'])) $this->postalCode = $o['postalCode'];
if (isset($o['country'])) $this->country = $o['country'];
if (isset($o['phone'])) $this->phone = $o['phone'];
if (isset($o['fax'])) $this->fax = $o['fax'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->companyName)) $o['companyName'] = $this->companyName;
if (isset($this->contactName)) $o['contactName'] = $this->contactName;
if (isset($this->contactTitle)) $o['contactTitle'] = $this->contactTitle;
if (isset($this->address)) $o['address'] = $this->address;
if (isset($this->city)) $o['city'] = $this->city;
if (isset($this->region)) $o['region'] = $this->region;
if (isset($this->postalCode)) $o['postalCode'] = $this->postalCode;
if (isset($this->country)) $o['country'] = $this->country;
if (isset($this->phone)) $o['phone'] = $this->phone;
if (isset($this->fax)) $o['fax'] = $this->fax;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
/**
* @template T
*/
class QueryResponse implements JsonSerializable
{
public array $genericArgs = [];
public static function create(array $genericArgs=[]): QueryResponse {
$to = new QueryResponse();
$to->genericArgs = $genericArgs;
return $to;
}
public function __construct(
// @DataMember(Order=1)
/** @var int */
public mixed $offset=0,
// @DataMember(Order=2)
/** @var int */
public mixed $total=0,
// @DataMember(Order=3)
/** @var array<Customer>|null */
public mixed $results=null,
// @DataMember(Order=4)
/** @var array<string,string>|null */
public mixed $meta=null,
// @DataMember(Order=5)
/** @var ResponseStatus|null */
public mixed $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['offset'])) $this->offset = $o['offset'];
if (isset($o['total'])) $this->total = $o['total'];
if (isset($o['results'])) $this->results = JsonConverters::fromArray('Customer', $o['results']);
if (isset($o['meta'])) $this->meta = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['meta']);
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->offset)) $o['offset'] = $this->offset;
if (isset($this->total)) $o['total'] = $this->total;
if (isset($this->results)) $o['results'] = JsonConverters::toArray('Customer', $this->results);
if (isset($this->meta)) $o['meta'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->meta);
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
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.
POST /query/orders HTTP/1.1
Host: northwind.netcore.io
Accept: application/json
Content-Type: application/json
Content-Length: length
{"freight":0,"skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"offset":0,"total":0,"results":[{"id":0,"customerId":"String","employeeId":0,"orderDate":"\/Date(-62135596800000-0000)\/","requiredDate":"\/Date(-62135596800000-0000)\/","shippedDate":"\/Date(-62135596800000-0000)\/","shipVia":0,"freight":0,"shipName":"String","shipAddress":"String","shipCity":"String","shipRegion":"String","shipPostalCode":"String","shipCountry":"String"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}