| GET,OPTIONS | /v1/rates |
|---|
<?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 ResourceRateComponentDto implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Label=null,
/** @var float */
public float $Amount=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Label'])) $this->Label = $o['Label'];
if (isset($o['Amount'])) $this->Amount = $o['Amount'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Label)) $o['Label'] = $this->Label;
if (isset($this->Amount)) $o['Amount'] = $this->Amount;
return empty($o) ? new class(){} : $o;
}
}
class ResourceRateHistoryRow implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $From=null,
/** @var float */
public float $Cost=0.0,
/** @var float */
public float $Bill=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['From'])) $this->From = $o['From'];
if (isset($o['Cost'])) $this->Cost = $o['Cost'];
if (isset($o['Bill'])) $this->Bill = $o['Bill'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->From)) $o['From'] = $this->From;
if (isset($this->Cost)) $o['Cost'] = $this->Cost;
if (isset($this->Bill)) $o['Bill'] = $this->Bill;
return empty($o) ? new class(){} : $o;
}
}
class ResourceRateResource implements JsonSerializable
{
public function __construct(
/** @var string */
public string $Id='',
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Meta=null,
/** @var string|null */
public ?string $Unit=null,
/** @var float */
public float $CostRate=0.0,
/** @var float */
public float $BillRate=0.0,
/** @var string|null */
public ?string $EffectiveFrom=null,
/** @var bool|null */
public ?bool $HasCard=null,
/** @var array<ResourceRateComponentDto>|null */
public ?array $Composition=null,
/** @var float|null */
public ?float $PrevailingFloor=null,
/** @var array<ResourceRateHistoryRow>|null */
public ?array $History=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Meta'])) $this->Meta = $o['Meta'];
if (isset($o['Unit'])) $this->Unit = $o['Unit'];
if (isset($o['CostRate'])) $this->CostRate = $o['CostRate'];
if (isset($o['BillRate'])) $this->BillRate = $o['BillRate'];
if (isset($o['EffectiveFrom'])) $this->EffectiveFrom = $o['EffectiveFrom'];
if (isset($o['HasCard'])) $this->HasCard = $o['HasCard'];
if (isset($o['Composition'])) $this->Composition = JsonConverters::fromArray('ResourceRateComponentDto', $o['Composition']);
if (isset($o['PrevailingFloor'])) $this->PrevailingFloor = $o['PrevailingFloor'];
if (isset($o['History'])) $this->History = JsonConverters::fromArray('ResourceRateHistoryRow', $o['History']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Meta)) $o['Meta'] = $this->Meta;
if (isset($this->Unit)) $o['Unit'] = $this->Unit;
if (isset($this->CostRate)) $o['CostRate'] = $this->CostRate;
if (isset($this->BillRate)) $o['BillRate'] = $this->BillRate;
if (isset($this->EffectiveFrom)) $o['EffectiveFrom'] = $this->EffectiveFrom;
if (isset($this->HasCard)) $o['HasCard'] = $this->HasCard;
if (isset($this->Composition)) $o['Composition'] = JsonConverters::toArray('ResourceRateComponentDto', $this->Composition);
if (isset($this->PrevailingFloor)) $o['PrevailingFloor'] = $this->PrevailingFloor;
if (isset($this->History)) $o['History'] = JsonConverters::toArray('ResourceRateHistoryRow', $this->History);
return empty($o) ? new class(){} : $o;
}
}
class ResourceRatesResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
/** @var string|null */
public ?string $Type=null,
/** @var string|null */
public ?string $AsOf=null,
/** @var array<ResourceRateResource>|null */
public ?array $Resources=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
if (isset($o['Type'])) $this->Type = $o['Type'];
if (isset($o['AsOf'])) $this->AsOf = $o['AsOf'];
if (isset($o['Resources'])) $this->Resources = JsonConverters::fromArray('ResourceRateResource', $o['Resources']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
if (isset($this->Type)) $o['Type'] = $this->Type;
if (isset($this->AsOf)) $o['AsOf'] = $this->AsOf;
if (isset($this->Resources)) $o['Resources'] = JsonConverters::toArray('ResourceRateResource', $this->Resources);
return empty($o) ? new class(){} : $o;
}
}
class ResourceRatesRequest implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Type=null,
/** @var string|null */
public ?string $AsOf=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Type'])) $this->Type = $o['Type'];
if (isset($o['AsOf'])) $this->AsOf = $o['AsOf'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Type)) $o['Type'] = $this->Type;
if (isset($this->AsOf)) $o['AsOf'] = $this->AsOf;
return empty($o) ? new class(){} : $o;
}
}
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/rates 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
}
},
Type: String,
AsOf: String,
Resources:
[
{
Id: 00000000000000000000000000000000,
Name: String,
Meta: String,
Unit: String,
CostRate: 0,
BillRate: 0,
EffectiveFrom: String,
HasCard: False,
Composition:
[
{
Label: String,
Amount: 0
}
],
PrevailingFloor: 0,
History:
[
{
From: String,
Cost: 0,
Bill: 0
}
]
}
]
}