| GET,POST,PUT,DELETE,OPTIONS | /v1/Project/Invoice/{ProjectID}/{InvoiceStartDate}/{InvoiceEndDate} |
|---|
<?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 ProjectInvoice implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $CostType=null,
/** @var string|null */
public ?string $CostName=null,
/** @var float */
public float $CostToDate=0.0,
/** @var int */
public int $JobID=0,
/** @var float */
public float $Rate=0.0,
/** @var int */
public int $Hours=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CostType'])) $this->CostType = $o['CostType'];
if (isset($o['CostName'])) $this->CostName = $o['CostName'];
if (isset($o['CostToDate'])) $this->CostToDate = $o['CostToDate'];
if (isset($o['JobID'])) $this->JobID = $o['JobID'];
if (isset($o['Rate'])) $this->Rate = $o['Rate'];
if (isset($o['Hours'])) $this->Hours = $o['Hours'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CostType)) $o['CostType'] = $this->CostType;
if (isset($this->CostName)) $o['CostName'] = $this->CostName;
if (isset($this->CostToDate)) $o['CostToDate'] = $this->CostToDate;
if (isset($this->JobID)) $o['JobID'] = $this->JobID;
if (isset($this->Rate)) $o['Rate'] = $this->Rate;
if (isset($this->Hours)) $o['Hours'] = $this->Hours;
return empty($o) ? new class(){} : $o;
}
}
class ProjectInvoiceResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
/** @var array<ProjectInvoice>|null */
public ?array $ProjectInvoice=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
if (isset($o['ProjectInvoice'])) $this->ProjectInvoice = JsonConverters::fromArray('ProjectInvoice', $o['ProjectInvoice']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
if (isset($this->ProjectInvoice)) $o['ProjectInvoice'] = JsonConverters::toArray('ProjectInvoice', $this->ProjectInvoice);
return empty($o) ? new class(){} : $o;
}
}
class ProjectInvoiceRequest implements JsonSerializable
{
public function __construct(
/** @var int */
public int $ProjectID=0,
/** @var DateTime */
public DateTime $InvoiceStartDate=new DateTime(),
/** @var DateTime */
public DateTime $InvoiceEndDate=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ProjectID'])) $this->ProjectID = $o['ProjectID'];
if (isset($o['InvoiceStartDate'])) $this->InvoiceStartDate = JsonConverters::from('DateTime', $o['InvoiceStartDate']);
if (isset($o['InvoiceEndDate'])) $this->InvoiceEndDate = JsonConverters::from('DateTime', $o['InvoiceEndDate']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ProjectID)) $o['ProjectID'] = $this->ProjectID;
if (isset($this->InvoiceStartDate)) $o['InvoiceStartDate'] = JsonConverters::to('DateTime', $this->InvoiceStartDate);
if (isset($this->InvoiceEndDate)) $o['InvoiceEndDate'] = JsonConverters::to('DateTime', $this->InvoiceEndDate);
return empty($o) ? new class(){} : $o;
}
}
PHP ProjectInvoiceRequest 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/Project/Invoice/{ProjectID}/{InvoiceStartDate}/{InvoiceEndDate} HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<ProjectInvoiceRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<InvoiceEndDate>0001-01-01T00:00:00</InvoiceEndDate>
<InvoiceStartDate>0001-01-01T00:00:00</InvoiceStartDate>
<ProjectID>0</ProjectID>
</ProjectInvoiceRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<ProjectInvoiceResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<ProjectInvoice>
<ProjectInvoice>
<CostName>String</CostName>
<CostToDate>0</CostToDate>
<CostType>String</CostType>
<Hours>0</Hours>
<JobID>0</JobID>
<Rate>0</Rate>
</ProjectInvoice>
</ProjectInvoice>
<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>
</ProjectInvoiceResponse>