PUT | /unit | ||
---|---|---|---|
PUT | /unit/{Id} | ||
GET POST | /UpdateUnit | ||
GET POST | /UpdateUnit/{Id} |
<?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 UpdateUnitResponse implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class UpdateUnit implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var string|null */
public ?string $id=null,
// @DataMember
/** @var string|null */
public ?string $name=null,
// @DataMember
/** @var string|null */
public ?string $referenceNumber=null,
// @DataMember
/** @var string|null */
public ?string $clientId=null,
// @DataMember
/** @var string|null */
public ?string $categoryId=null,
// @DataMember
/** @var string|null */
public ?string $vehicleType=null,
// @DataMember
/** @var float|null */
public ?float $preKm=null,
// @DataMember
/** @var float|null */
public ?float $preRun1=null,
// @DataMember
/** @var float|null */
public ?float $preRun2=null,
// @DataMember
/** @var string|null */
public ?string $note=null,
// @DataMember
/** @var bool|null */
public ?bool $isActive=null,
// @DataMember
/** @var string|null */
public ?string $input1Name=null,
// @DataMember
/** @var string|null */
public ?string $input2Name=null,
// @DataMember
/** @var string|null */
public ?string $input3Name=null,
// @DataMember
/** @var string|null */
public ?string $input4Name=null,
// @DataMember
/** @var bool|null */
public ?bool $lock=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['referenceNumber'])) $this->referenceNumber = $o['referenceNumber'];
if (isset($o['clientId'])) $this->clientId = $o['clientId'];
if (isset($o['categoryId'])) $this->categoryId = $o['categoryId'];
if (isset($o['vehicleType'])) $this->vehicleType = $o['vehicleType'];
if (isset($o['preKm'])) $this->preKm = $o['preKm'];
if (isset($o['preRun1'])) $this->preRun1 = $o['preRun1'];
if (isset($o['preRun2'])) $this->preRun2 = $o['preRun2'];
if (isset($o['note'])) $this->note = $o['note'];
if (isset($o['isActive'])) $this->isActive = $o['isActive'];
if (isset($o['input1Name'])) $this->input1Name = $o['input1Name'];
if (isset($o['input2Name'])) $this->input2Name = $o['input2Name'];
if (isset($o['input3Name'])) $this->input3Name = $o['input3Name'];
if (isset($o['input4Name'])) $this->input4Name = $o['input4Name'];
if (isset($o['lock'])) $this->lock = $o['lock'];
}
/** @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->referenceNumber)) $o['referenceNumber'] = $this->referenceNumber;
if (isset($this->clientId)) $o['clientId'] = $this->clientId;
if (isset($this->categoryId)) $o['categoryId'] = $this->categoryId;
if (isset($this->vehicleType)) $o['vehicleType'] = $this->vehicleType;
if (isset($this->preKm)) $o['preKm'] = $this->preKm;
if (isset($this->preRun1)) $o['preRun1'] = $this->preRun1;
if (isset($this->preRun2)) $o['preRun2'] = $this->preRun2;
if (isset($this->note)) $o['note'] = $this->note;
if (isset($this->isActive)) $o['isActive'] = $this->isActive;
if (isset($this->input1Name)) $o['input1Name'] = $this->input1Name;
if (isset($this->input2Name)) $o['input2Name'] = $this->input2Name;
if (isset($this->input3Name)) $o['input3Name'] = $this->input3Name;
if (isset($this->input4Name)) $o['input4Name'] = $this->input4Name;
if (isset($this->lock)) $o['lock'] = $this->lock;
return empty($o) ? new class(){} : $o;
}
}
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 /UpdateUnit HTTP/1.1
Host: api.trackunit.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UpdateUnit xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
<CategoryId>String</CategoryId>
<ClientId>String</ClientId>
<Id>String</Id>
<Input1Name>String</Input1Name>
<Input2Name>String</Input2Name>
<Input3Name>String</Input3Name>
<Input4Name>String</Input4Name>
<IsActive>false</IsActive>
<Lock>false</Lock>
<Name>String</Name>
<Note>String</Note>
<PreKm>0</PreKm>
<PreRun1>0</PreRun1>
<PreRun2>0</PreRun2>
<ReferenceNumber>String</ReferenceNumber>
<VehicleType>String</VehicleType>
</UpdateUnit>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <UpdateUnitResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types"> <ResponseStatus> <ErrorCode>String</ErrorCode> <Message>String</Message> <StackTrace>String</StackTrace> <Errors> <ResponseError> <ErrorCode>String</ErrorCode> <FieldName>String</FieldName> <Message>String</Message> <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> </Meta> </ResponseError> </Errors> <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> </Meta> </ResponseStatus> </UpdateUnitResponse>