GET | /conversations |
---|
<?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};
enum MessageDirections : string
{
case Incoming = 'Incoming';
case Outgoing = 'Outgoing';
}
class MessageInfo implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var string|null */
public ?string $accountId=null,
/** @var string|null */
public ?string $customerId=null,
/** @var string|null */
public ?string $endpointId=null,
/** @var string|null */
public ?string $endpointDisplayName=null,
/** @var string|null */
public ?string $date=null,
/** @var MessageDirections|null */
public ?MessageDirections $direction=null,
/** @var string|null */
public ?string $otherAddress=null,
/** @var string|null */
public ?string $sender=null,
/** @var string|null */
public ?string $text=null,
/** @var bool|null */
public ?bool $isUnread=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['accountId'])) $this->accountId = $o['accountId'];
if (isset($o['customerId'])) $this->customerId = $o['customerId'];
if (isset($o['endpointId'])) $this->endpointId = $o['endpointId'];
if (isset($o['endpointDisplayName'])) $this->endpointDisplayName = $o['endpointDisplayName'];
if (isset($o['date'])) $this->date = $o['date'];
if (isset($o['direction'])) $this->direction = JsonConverters::from('MessageDirections', $o['direction']);
if (isset($o['otherAddress'])) $this->otherAddress = $o['otherAddress'];
if (isset($o['sender'])) $this->sender = $o['sender'];
if (isset($o['text'])) $this->text = $o['text'];
if (isset($o['isUnread'])) $this->isUnread = $o['isUnread'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->accountId)) $o['accountId'] = $this->accountId;
if (isset($this->customerId)) $o['customerId'] = $this->customerId;
if (isset($this->endpointId)) $o['endpointId'] = $this->endpointId;
if (isset($this->endpointDisplayName)) $o['endpointDisplayName'] = $this->endpointDisplayName;
if (isset($this->date)) $o['date'] = $this->date;
if (isset($this->direction)) $o['direction'] = JsonConverters::to('MessageDirections', $this->direction);
if (isset($this->otherAddress)) $o['otherAddress'] = $this->otherAddress;
if (isset($this->sender)) $o['sender'] = $this->sender;
if (isset($this->text)) $o['text'] = $this->text;
if (isset($this->isUnread)) $o['isUnread'] = $this->isUnread;
return empty($o) ? new class(){} : $o;
}
}
class ConversationInfo implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var string|null */
public ?string $endpointId=null,
/** @var string|null */
public ?string $otherAddress=null,
/** @var MessageInfo|null */
public ?MessageInfo $mostRecentMessage=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['endpointId'])) $this->endpointId = $o['endpointId'];
if (isset($o['otherAddress'])) $this->otherAddress = $o['otherAddress'];
if (isset($o['mostRecentMessage'])) $this->mostRecentMessage = JsonConverters::from('MessageInfo', $o['mostRecentMessage']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->endpointId)) $o['endpointId'] = $this->endpointId;
if (isset($this->otherAddress)) $o['otherAddress'] = $this->otherAddress;
if (isset($this->mostRecentMessage)) $o['mostRecentMessage'] = JsonConverters::to('MessageInfo', $this->mostRecentMessage);
return empty($o) ? new class(){} : $o;
}
}
class ListConversationsResponse implements JsonSerializable
{
public function __construct(
/** @var array<ConversationInfo>|null */
public ?array $conversations=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['conversations'])) $this->conversations = JsonConverters::fromArray('ConversationInfo', $o['conversations']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->conversations)) $o['conversations'] = JsonConverters::toArray('ConversationInfo', $this->conversations);
return empty($o) ? new class(){} : $o;
}
}
class ListConversations implements JsonSerializable
{
public function __construct(
/** @description The IDs of the account whose conversations you want to retrieve */
// @ApiMember(Description="The IDs of the account whose conversations you want to retrieve")
/** @var array<string>|null */
public ?array $accountIds=null,
/** @description The list of endpoint IDs whose conversations you want to retrieve */
// @ApiMember(Description="The list of endpoint IDs whose conversations you want to retrieve")
/** @var array<string>|null */
public ?array $endpointIds=null,
/** @description The list of customer IDs whose conversations you want to retrieve */
// @ApiMember(Description="The list of customer IDs whose conversations you want to retrieve")
/** @var array<string>|null */
public ?array $customerIds=null,
/** @description The start date for the conversations you want to retrieve */
// @ApiMember(Description="The start date for the conversations you want to retrieve")
/** @var string|null */
public ?string $afterDate=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['accountIds'])) $this->accountIds = JsonConverters::fromArray('string', $o['accountIds']);
if (isset($o['endpointIds'])) $this->endpointIds = JsonConverters::fromArray('string', $o['endpointIds']);
if (isset($o['customerIds'])) $this->customerIds = JsonConverters::fromArray('string', $o['customerIds']);
if (isset($o['afterDate'])) $this->afterDate = $o['afterDate'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->accountIds)) $o['accountIds'] = JsonConverters::toArray('string', $this->accountIds);
if (isset($this->endpointIds)) $o['endpointIds'] = JsonConverters::toArray('string', $this->endpointIds);
if (isset($this->customerIds)) $o['customerIds'] = JsonConverters::toArray('string', $this->customerIds);
if (isset($this->afterDate)) $o['afterDate'] = $this->afterDate;
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 /conversations HTTP/1.1 Host: team.evovoice.io Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { conversations: [ { id: String, endpointId: String, otherAddress: String, mostRecentMessage: { id: String, accountId: String, customerId: String, endpointId: String, endpointDisplayName: String, date: String, direction: Incoming, otherAddress: String, sender: String, text: String, isUnread: False } } ] }