| Requires any of the roles: | Agent, Administrator, Agent, Administrator, Agent, Administrator |
| GET,POST,PUT,OPTIONS | /v1/Ticket | ||
|---|---|---|---|
| GET | /v1/Ticket/{AgentId}/{Status} |
<?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 Ticket implements JsonSerializable
{
public function __construct(
/** @var int */
public int $TicketId=0,
/** @var DateTime */
public DateTime $CreatedDate=new DateTime(),
/** @var string */
public string $CreatedBy='',
/** @var string|null */
public ?string $Description=null,
/** @var string|null */
public ?string $Resolution=null,
/** @var bool|null */
public ?bool $IsClosed=null,
/** @var bool|null */
public ?bool $IsFollowup=null,
/** @var int */
public int $TicketTypeId=0,
/** @var DateTime */
public DateTime $ModifiedDate=new DateTime(),
/** @var string|null */
public ?string $ModifiedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['TicketId'])) $this->TicketId = $o['TicketId'];
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
if (isset($o['CreatedBy'])) $this->CreatedBy = $o['CreatedBy'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Resolution'])) $this->Resolution = $o['Resolution'];
if (isset($o['IsClosed'])) $this->IsClosed = $o['IsClosed'];
if (isset($o['IsFollowup'])) $this->IsFollowup = $o['IsFollowup'];
if (isset($o['TicketTypeId'])) $this->TicketTypeId = $o['TicketTypeId'];
if (isset($o['ModifiedDate'])) $this->ModifiedDate = JsonConverters::from('DateTime', $o['ModifiedDate']);
if (isset($o['ModifiedBy'])) $this->ModifiedBy = $o['ModifiedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->TicketId)) $o['TicketId'] = $this->TicketId;
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
if (isset($this->CreatedBy)) $o['CreatedBy'] = $this->CreatedBy;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Resolution)) $o['Resolution'] = $this->Resolution;
if (isset($this->IsClosed)) $o['IsClosed'] = $this->IsClosed;
if (isset($this->IsFollowup)) $o['IsFollowup'] = $this->IsFollowup;
if (isset($this->TicketTypeId)) $o['TicketTypeId'] = $this->TicketTypeId;
if (isset($this->ModifiedDate)) $o['ModifiedDate'] = JsonConverters::to('DateTime', $this->ModifiedDate);
if (isset($this->ModifiedBy)) $o['ModifiedBy'] = $this->ModifiedBy;
return empty($o) ? new class(){} : $o;
}
}
class TicketExtended extends Ticket implements JsonSerializable
{
/**
* @param int $TicketId
* @param DateTime $CreatedDate
* @param string $CreatedBy
* @param string|null $Description
* @param string|null $Resolution
* @param bool|null $IsClosed
* @param bool|null $IsFollowup
* @param int $TicketTypeId
* @param DateTime $ModifiedDate
* @param string|null $ModifiedBy
*/
public function __construct(
int $TicketId=0,
DateTime $CreatedDate=new DateTime(),
string $CreatedBy='',
?string $Description=null,
?string $Resolution=null,
?bool $IsClosed=null,
?bool $IsFollowup=null,
int $TicketTypeId=0,
DateTime $ModifiedDate=new DateTime(),
?string $ModifiedBy=null,
/** @var string|null */
public ?string $AgentName=null,
/** @var string|null */
public ?string $TicketType=null,
/** @var bool|null */
public ?bool $AgentHasRead=null,
/** @var bool|null */
public ?bool $AdminHasRead=null
) {
parent::__construct($TicketId,$CreatedDate,$CreatedBy,$Description,$Resolution,$IsClosed,$IsFollowup,$TicketTypeId,$ModifiedDate,$ModifiedBy);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['AgentName'])) $this->AgentName = $o['AgentName'];
if (isset($o['TicketType'])) $this->TicketType = $o['TicketType'];
if (isset($o['AgentHasRead'])) $this->AgentHasRead = $o['AgentHasRead'];
if (isset($o['AdminHasRead'])) $this->AdminHasRead = $o['AdminHasRead'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->AgentName)) $o['AgentName'] = $this->AgentName;
if (isset($this->TicketType)) $o['TicketType'] = $this->TicketType;
if (isset($this->AgentHasRead)) $o['AgentHasRead'] = $this->AgentHasRead;
if (isset($this->AdminHasRead)) $o['AdminHasRead'] = $this->AdminHasRead;
return empty($o) ? new class(){} : $o;
}
}
class TicketResponse implements JsonSerializable
{
public function __construct(
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null,
/** @var array<TicketExtended>|null */
public ?array $Ticket=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
if (isset($o['Ticket'])) $this->Ticket = JsonConverters::fromArray('TicketExtended', $o['Ticket']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
if (isset($this->Ticket)) $o['Ticket'] = JsonConverters::toArray('TicketExtended', $this->Ticket);
return empty($o) ? new class(){} : $o;
}
}
class TicketRequest implements JsonSerializable
{
public function __construct(
/** @var array<TicketExtended>|null */
public ?array $Ticket=null,
/** @var int */
public int $AgentId=0,
/** @var string|null */
public ?string $Status=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Ticket'])) $this->Ticket = JsonConverters::fromArray('TicketExtended', $o['Ticket']);
if (isset($o['AgentId'])) $this->AgentId = $o['AgentId'];
if (isset($o['Status'])) $this->Status = $o['Status'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Ticket)) $o['Ticket'] = JsonConverters::toArray('TicketExtended', $this->Ticket);
if (isset($this->AgentId)) $o['AgentId'] = $this->AgentId;
if (isset($this->Status)) $o['Status'] = $this->Status;
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.
POST /v1/Ticket HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Ticket:
[
{
AgentName: String,
TicketType: String,
AgentHasRead: False,
AdminHasRead: False,
TicketId: 0,
CreatedDate: 0001-01-01,
CreatedBy: 00000000000000000000000000000000,
Description: String,
Resolution: String,
IsClosed: False,
IsFollowup: False,
TicketTypeId: 0,
ModifiedDate: 0001-01-01,
ModifiedBy: String
}
],
AgentId: 0,
Status: String
}
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
}
},
Ticket:
[
{
AgentName: String,
TicketType: String,
AgentHasRead: False,
AdminHasRead: False,
TicketId: 0,
CreatedDate: 0001-01-01,
CreatedBy: 00000000000000000000000000000000,
Description: String,
Resolution: String,
IsClosed: False,
IsFollowup: False,
TicketTypeId: 0,
ModifiedDate: 0001-01-01,
ModifiedBy: String
}
]
}