POST | /references | Add reference | Add reference |
---|
<?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 ReferenceQueryResponse implements JsonSerializable
{
public function __construct(
/** @var string */
public string $CompanyId='',
/** @var string */
public string $Id='',
/** @var string */
public string $OwnerId='',
/** @var string */
public string $ReferenceType='',
/** @var int */
public int $ReferenceTypeId=0,
/** @var string */
public string $ExternalData='',
/** @var DateTime */
public DateTime $Updated=new DateTime(),
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @var string */
public string $CreatedBy='',
/** @var string */
public string $UpdatedBy='',
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['OwnerId'])) $this->OwnerId = $o['OwnerId'];
if (isset($o['ReferenceType'])) $this->ReferenceType = $o['ReferenceType'];
if (isset($o['ReferenceTypeId'])) $this->ReferenceTypeId = $o['ReferenceTypeId'];
if (isset($o['ExternalData'])) $this->ExternalData = $o['ExternalData'];
if (isset($o['Updated'])) $this->Updated = JsonConverters::from('DateTime', $o['Updated']);
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
if (isset($o['UpdatedBy'])) $this->UpdatedBy = $o['UpdatedBy'];
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->OwnerId)) $o['OwnerId'] = $this->OwnerId;
if (isset($this->ReferenceType)) $o['ReferenceType'] = $this->ReferenceType;
if (isset($this->ReferenceTypeId)) $o['ReferenceTypeId'] = $this->ReferenceTypeId;
if (isset($this->ExternalData)) $o['ExternalData'] = $this->ExternalData;
if (isset($this->Updated)) $o['Updated'] = JsonConverters::to('DateTime', $this->Updated);
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
if (isset($this->UpdatedBy)) $o['UpdatedBy'] = $this->UpdatedBy;
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
class AddReference implements ICompany, JsonSerializable
{
public function __construct(
/** @description The company id, if empty will use the company id for the user you are logged in with. */
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
/** @var string|null */
public ?string $CompanyId=null,
/** @description Internal Id of the reference. Example could be the Booking Id */
// @ApiMember(Description="Internal Id of the reference. Example could be the Booking Id")
/** @var string */
public string $OwnerId='',
/** @description The type of reference, you can name this parameter what you like. Example could be system_bookingid where the system is the external system */
// @ApiMember(Description="The type of reference, you can name this parameter what you like. Example could be system_bookingid where the system is the external system")
/** @var string */
public string $ReferenceType='',
/** @description External reference type id - can we fetched from /externalreferencestypes endpoint */
// @ApiMember(Description="External reference type id - can we fetched from /externalreferencestypes endpoint")
/** @var int|null */
public ?int $ReferenceTypeId=null,
/** @description The external data. Could be a Id or a JSON object or anything */
// @ApiMember(Description="The external data. Could be a Id or a JSON object or anything")
/** @var string */
public string $ExternalData='',
/** @description Will show who created the reference. */
// @ApiMember(DataType="datetime", Description="Will show who created the reference.")
/** @var string */
public string $CreatedBy=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['OwnerId'])) $this->OwnerId = $o['OwnerId'];
if (isset($o['ReferenceType'])) $this->ReferenceType = $o['ReferenceType'];
if (isset($o['ReferenceTypeId'])) $this->ReferenceTypeId = $o['ReferenceTypeId'];
if (isset($o['ExternalData'])) $this->ExternalData = $o['ExternalData'];
if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->OwnerId)) $o['OwnerId'] = $this->OwnerId;
if (isset($this->ReferenceType)) $o['ReferenceType'] = $this->ReferenceType;
if (isset($this->ReferenceTypeId)) $o['ReferenceTypeId'] = $this->ReferenceTypeId;
if (isset($this->ExternalData)) $o['ExternalData'] = $this->ExternalData;
if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /references HTTP/1.1
Host: testapi.bokamera.se
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","ReferenceType":"String","ReferenceTypeId":0,"ExternalData":"String","CreatedBy":"String"}
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"ReferenceType":"String","ReferenceTypeId":0,"ExternalData":"String","CreatedBy":"String","UpdatedBy":"String","ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}