| GET,OPTIONS | /v1/projects/{ProjectID}/purchase-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};
class PurchaseOrderLine implements JsonSerializable
{
public function __construct(
/** @var int */
public int $PurchaseOrderLineID=0,
/** @var int */
public int $PurchaseOrderID=0,
/** @var int|null */
public ?int $MaterialID=null,
/** @var string|null */
public ?string $Description=null,
/** @var string|null */
public ?string $Unit=null,
/** @var float */
public float $Qty=0.0,
/** @var float */
public float $UnitPrice=0.0,
/** @var float */
public float $QtyReceived=0.0,
/** @var string|null */
public ?string $CostCode=null,
/** @var int */
public int $SortOrder=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['PurchaseOrderLineID'])) $this->PurchaseOrderLineID = $o['PurchaseOrderLineID'];
if (isset($o['PurchaseOrderID'])) $this->PurchaseOrderID = $o['PurchaseOrderID'];
if (isset($o['MaterialID'])) $this->MaterialID = $o['MaterialID'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Unit'])) $this->Unit = $o['Unit'];
if (isset($o['Qty'])) $this->Qty = $o['Qty'];
if (isset($o['UnitPrice'])) $this->UnitPrice = $o['UnitPrice'];
if (isset($o['QtyReceived'])) $this->QtyReceived = $o['QtyReceived'];
if (isset($o['CostCode'])) $this->CostCode = $o['CostCode'];
if (isset($o['SortOrder'])) $this->SortOrder = $o['SortOrder'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->PurchaseOrderLineID)) $o['PurchaseOrderLineID'] = $this->PurchaseOrderLineID;
if (isset($this->PurchaseOrderID)) $o['PurchaseOrderID'] = $this->PurchaseOrderID;
if (isset($this->MaterialID)) $o['MaterialID'] = $this->MaterialID;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Unit)) $o['Unit'] = $this->Unit;
if (isset($this->Qty)) $o['Qty'] = $this->Qty;
if (isset($this->UnitPrice)) $o['UnitPrice'] = $this->UnitPrice;
if (isset($this->QtyReceived)) $o['QtyReceived'] = $this->QtyReceived;
if (isset($this->CostCode)) $o['CostCode'] = $this->CostCode;
if (isset($this->SortOrder)) $o['SortOrder'] = $this->SortOrder;
return empty($o) ? new class(){} : $o;
}
}
class PurchaseOrder implements JsonSerializable
{
public function __construct(
/** @var int */
public int $PurchaseOrderID=0,
/** @var string */
public string $PurchaseOrderUID='',
/** @var int */
public int $ProjectID=0,
/** @var string|null */
public ?string $PONumber=null,
/** @var string|null */
public ?string $Vendor=null,
/** @var string|null */
public ?string $Status=null,
/** @var float */
public float $AmountUSD=0.0,
/** @var string|null */
public ?string $CostCode=null,
/** @var DateTime|null */
public ?DateTime $NeedByDate=null,
/** @var string|null */
public ?string $Notes=null,
/** @var DateTime|null */
public ?DateTime $IssuedAt=null,
/** @var DateTime|null */
public ?DateTime $ReceivedAt=null,
/** @var string|null */
public ?string $CreatedBy=null,
/** @var DateTime|null */
public ?DateTime $CreatedAt=null,
/** @var DateTime|null */
public ?DateTime $UpdatedAt=null,
/** @var int */
public int $LineCount=0,
/** @var string|null */
public ?string $FirstItem=null,
/** @var int */
public int $DaysToNeed=0,
/** @var array<PurchaseOrderLine>|null */
public ?array $Lines=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['PurchaseOrderID'])) $this->PurchaseOrderID = $o['PurchaseOrderID'];
if (isset($o['PurchaseOrderUID'])) $this->PurchaseOrderUID = $o['PurchaseOrderUID'];
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
if (isset($o['PONumber'])) $this->PONumber = $o['PONumber'];
if (isset($o['Vendor'])) $this->Vendor = $o['Vendor'];
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['AmountUSD'])) $this->AmountUSD = $o['AmountUSD'];
if (isset($o['CostCode'])) $this->CostCode = $o['CostCode'];
if (isset($o['NeedByDate'])) $this->NeedByDate = JsonConverters::from('DateTime', $o['NeedByDate']);
if (isset($o['Notes'])) $this->Notes = $o['Notes'];
if (isset($o['IssuedAt'])) $this->IssuedAt = JsonConverters::from('DateTime', $o['IssuedAt']);
if (isset($o['ReceivedAt'])) $this->ReceivedAt = JsonConverters::from('DateTime', $o['ReceivedAt']);
if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
if (isset($o['CreatedAt'])) $this->CreatedAt = JsonConverters::from('DateTime', $o['CreatedAt']);
if (isset($o['UpdatedAt'])) $this->UpdatedAt = JsonConverters::from('DateTime', $o['UpdatedAt']);
if (isset($o['LineCount'])) $this->LineCount = $o['LineCount'];
if (isset($o['FirstItem'])) $this->FirstItem = $o['FirstItem'];
if (isset($o['DaysToNeed'])) $this->DaysToNeed = $o['DaysToNeed'];
if (isset($o['Lines'])) $this->Lines = JsonConverters::fromArray('PurchaseOrderLine', $o['Lines']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->PurchaseOrderID)) $o['PurchaseOrderID'] = $this->PurchaseOrderID;
if (isset($this->PurchaseOrderUID)) $o['PurchaseOrderUID'] = $this->PurchaseOrderUID;
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
if (isset($this->PONumber)) $o['PONumber'] = $this->PONumber;
if (isset($this->Vendor)) $o['Vendor'] = $this->Vendor;
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->AmountUSD)) $o['AmountUSD'] = $this->AmountUSD;
if (isset($this->CostCode)) $o['CostCode'] = $this->CostCode;
if (isset($this->NeedByDate)) $o['NeedByDate'] = JsonConverters::to('DateTime', $this->NeedByDate);
if (isset($this->Notes)) $o['Notes'] = $this->Notes;
if (isset($this->IssuedAt)) $o['IssuedAt'] = JsonConverters::to('DateTime', $this->IssuedAt);
if (isset($this->ReceivedAt)) $o['ReceivedAt'] = JsonConverters::to('DateTime', $this->ReceivedAt);
if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
if (isset($this->CreatedAt)) $o['CreatedAt'] = JsonConverters::to('DateTime', $this->CreatedAt);
if (isset($this->UpdatedAt)) $o['UpdatedAt'] = JsonConverters::to('DateTime', $this->UpdatedAt);
if (isset($this->LineCount)) $o['LineCount'] = $this->LineCount;
if (isset($this->FirstItem)) $o['FirstItem'] = $this->FirstItem;
if (isset($this->DaysToNeed)) $o['DaysToNeed'] = $this->DaysToNeed;
if (isset($this->Lines)) $o['Lines'] = JsonConverters::toArray('PurchaseOrderLine', $this->Lines);
return empty($o) ? new class(){} : $o;
}
}
class PurchaseOrderBuyoutSummary implements JsonSerializable
{
public function __construct(
/** @var int */
public int $ProjectID=0,
/** @var float */
public float $MaterialBudget=0.0,
/** @var float */
public float $Committed=0.0,
/** @var float */
public float $Received=0.0,
/** @var int */
public int $OpenPOs=0,
/** @var int */
public int $LatePOs=0,
/** @var int */
public int $POCount=0,
/** @var float */
public float $RemainingBuyout=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
if (isset($o['MaterialBudget'])) $this->MaterialBudget = $o['MaterialBudget'];
if (isset($o['Committed'])) $this->Committed = $o['Committed'];
if (isset($o['Received'])) $this->Received = $o['Received'];
if (isset($o['OpenPOs'])) $this->OpenPOs = $o['OpenPOs'];
if (isset($o['LatePOs'])) $this->LatePOs = $o['LatePOs'];
if (isset($o['POCount'])) $this->POCount = $o['POCount'];
if (isset($o['RemainingBuyout'])) $this->RemainingBuyout = $o['RemainingBuyout'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
if (isset($this->MaterialBudget)) $o['MaterialBudget'] = $this->MaterialBudget;
if (isset($this->Committed)) $o['Committed'] = $this->Committed;
if (isset($this->Received)) $o['Received'] = $this->Received;
if (isset($this->OpenPOs)) $o['OpenPOs'] = $this->OpenPOs;
if (isset($this->LatePOs)) $o['LatePOs'] = $this->LatePOs;
if (isset($this->POCount)) $o['POCount'] = $this->POCount;
if (isset($this->RemainingBuyout)) $o['RemainingBuyout'] = $this->RemainingBuyout;
return empty($o) ? new class(){} : $o;
}
}
class PurchaseOrderListResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
/** @var int */
public int $ProjectID=0,
/** @var array<PurchaseOrder>|null */
public ?array $Orders=null,
/** @var PurchaseOrderBuyoutSummary|null */
public ?PurchaseOrderBuyoutSummary $Summary=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
if (isset($o['Orders'])) $this->Orders = JsonConverters::fromArray('PurchaseOrder', $o['Orders']);
if (isset($o['Summary'])) $this->Summary = JsonConverters::from('PurchaseOrderBuyoutSummary', $o['Summary']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
if (isset($this->Orders)) $o['Orders'] = JsonConverters::toArray('PurchaseOrder', $this->Orders);
if (isset($this->Summary)) $o['Summary'] = JsonConverters::to('PurchaseOrderBuyoutSummary', $this->Summary);
return empty($o) ? new class(){} : $o;
}
}
class PurchaseOrderListRequest implements JsonSerializable
{
public function __construct(
/** @var int */
public int $ProjectID=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
return empty($o) ? new class(){} : $o;
}
}
PHP PurchaseOrderListRequest DTOs
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 /v1/projects/{ProjectID}/purchase-orders HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
ResponseStatus:
{
ErrorCode: String,
Message: String,
StackTrace: String,
Errors:
[
{
ErrorCode: String,
FieldName: String,
Message: String,
Meta:
{
String: String
}
}
],
Meta:
{
String: String
}
},
ProjectID: 0,
Orders:
[
{
PurchaseOrderID: 0,
PurchaseOrderUID: 00000000000000000000000000000000,
ProjectID: 0,
PONumber: String,
Vendor: String,
Status: String,
AmountUSD: 0,
CostCode: String,
NeedByDate: 0001-01-01,
Notes: String,
IssuedAt: 0001-01-01,
ReceivedAt: 0001-01-01,
CreatedBy: String,
CreatedAt: 0001-01-01,
UpdatedAt: 0001-01-01,
LineCount: 0,
FirstItem: String,
DaysToNeed: 0,
Lines:
[
{
PurchaseOrderLineID: 0,
PurchaseOrderID: 0,
MaterialID: 0,
Description: String,
Unit: String,
Qty: 0,
UnitPrice: 0,
QtyReceived: 0,
CostCode: String,
SortOrder: 0
}
]
}
],
Summary:
{
ProjectID: 0,
MaterialBudget: 0,
Committed: 0,
Received: 0,
OpenPOs: 0,
LatePOs: 0,
POCount: 0,
RemainingBuyout: 0
}
}