| POST,OPTIONS | /v1/projects/{ProjectID}/purchase-orders/{PurchaseOrderID}/issue |
|---|
<?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 PurchaseOrderResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
/** @var PurchaseOrder|null */
public ?PurchaseOrder $Order=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['Order'])) $this->Order = JsonConverters::from('PurchaseOrder', $o['Order']);
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->Order)) $o['Order'] = JsonConverters::to('PurchaseOrder', $this->Order);
if (isset($this->Summary)) $o['Summary'] = JsonConverters::to('PurchaseOrderBuyoutSummary', $this->Summary);
return empty($o) ? new class(){} : $o;
}
}
class PurchaseOrderIssueRequest implements JsonSerializable
{
public function __construct(
/** @var int */
public int $ProjectID=0,
/** @var int */
public int $PurchaseOrderID=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
if (isset($o['PurchaseOrderID'])) $this->PurchaseOrderID = $o['PurchaseOrderID'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
if (isset($this->PurchaseOrderID)) $o['PurchaseOrderID'] = $this->PurchaseOrderID;
return empty($o) ? new class(){} : $o;
}
}
PHP PurchaseOrderIssueRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /v1/projects/{ProjectID}/purchase-orders/{PurchaseOrderID}/issue HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<PurchaseOrderIssueRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<ProjectID>0</ProjectID>
<PurchaseOrderID>0</PurchaseOrderID>
</PurchaseOrderIssueRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<PurchaseOrderResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<Order>
<AmountUSD>0</AmountUSD>
<CostCode>String</CostCode>
<CreatedAt>0001-01-01T00:00:00</CreatedAt>
<CreatedBy>String</CreatedBy>
<DaysToNeed>0</DaysToNeed>
<FirstItem>String</FirstItem>
<IssuedAt>0001-01-01T00:00:00</IssuedAt>
<LineCount>0</LineCount>
<Lines>
<PurchaseOrderLine>
<CostCode>String</CostCode>
<Description>String</Description>
<MaterialID>0</MaterialID>
<PurchaseOrderID>0</PurchaseOrderID>
<PurchaseOrderLineID>0</PurchaseOrderLineID>
<Qty>0</Qty>
<QtyReceived>0</QtyReceived>
<SortOrder>0</SortOrder>
<Unit>String</Unit>
<UnitPrice>0</UnitPrice>
</PurchaseOrderLine>
</Lines>
<NeedByDate>0001-01-01T00:00:00</NeedByDate>
<Notes>String</Notes>
<PONumber>String</PONumber>
<ProjectID>0</ProjectID>
<PurchaseOrderID>0</PurchaseOrderID>
<PurchaseOrderUID>00000000-0000-0000-0000-000000000000</PurchaseOrderUID>
<ReceivedAt>0001-01-01T00:00:00</ReceivedAt>
<Status>String</Status>
<UpdatedAt>0001-01-01T00:00:00</UpdatedAt>
<Vendor>String</Vendor>
</Order>
<ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:Message>String</d2p1:Message>
<d2p1:StackTrace>String</d2p1:StackTrace>
<d2p1:Errors>
<d2p1:ResponseError>
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:FieldName>String</d2p1:FieldName>
<d2p1:Message>String</d2p1:Message>
<d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:KeyValueOfstringstring>
<d5p1:Key>String</d5p1:Key>
<d5p1:Value>String</d5p1:Value>
</d5p1:KeyValueOfstringstring>
</d2p1:Meta>
</d2p1:ResponseError>
</d2p1:Errors>
<d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d3p1:KeyValueOfstringstring>
<d3p1:Key>String</d3p1:Key>
<d3p1:Value>String</d3p1:Value>
</d3p1:KeyValueOfstringstring>
</d2p1:Meta>
</ResponseStatus>
<Summary>
<Committed>0</Committed>
<LatePOs>0</LatePOs>
<MaterialBudget>0</MaterialBudget>
<OpenPOs>0</OpenPOs>
<POCount>0</POCount>
<ProjectID>0</ProjectID>
<Received>0</Received>
<RemainingBuyout>0</RemainingBuyout>
</Summary>
</PurchaseOrderResponse>