| POST | /notificationcentre/comment |
|---|
<?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 ApiServiceRequest implements IServiceRequest, IHasApiKey, IHasDeviceInfo, JsonSerializable
{
public function __construct(
/** @description The API Key required for authentication */
// @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
/** @var string */
public string $apiKey='',
/** @description Latitude of the user making this request */
// @ApiMember(DataType="double", Description="Latitude of the user making this request")
/** @var float */
public float $latitude=0.0,
/** @description Longitude of the user making this request */
// @ApiMember(DataType="double", Description="Longitude of the user making this request")
/** @var float */
public float $longitude=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['apiKey'])) $this->apiKey = $o['apiKey'];
if (isset($o['latitude'])) $this->latitude = $o['latitude'];
if (isset($o['longitude'])) $this->longitude = $o['longitude'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->apiKey)) $o['apiKey'] = $this->apiKey;
if (isset($this->latitude)) $o['latitude'] = $this->latitude;
if (isset($this->longitude)) $o['longitude'] = $this->longitude;
return empty($o) ? new class(){} : $o;
}
}
class ApiServiceResponse implements IServiceResponse, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $description=null,
/** @var string|null */
public ?string $heading=null,
/** @var bool|null */
public ?bool $wasSuccessful=null,
/** @var Object|null */
public ?Object $modelState=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['heading'])) $this->heading = $o['heading'];
if (isset($o['wasSuccessful'])) $this->wasSuccessful = $o['wasSuccessful'];
if (isset($o['modelState'])) $this->modelState = JsonConverters::from('Object', $o['modelState']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->heading)) $o['heading'] = $this->heading;
if (isset($this->wasSuccessful)) $o['wasSuccessful'] = $this->wasSuccessful;
if (isset($this->modelState)) $o['modelState'] = JsonConverters::to('Object', $this->modelState);
return empty($o) ? new class(){} : $o;
}
}
class NotificationMessageAttachment implements JsonSerializable
{
public function __construct(
/** @var bool|null */
public ?bool $isImage=null,
/** @var bool|null */
public ?bool $isPdf=null,
/** @var bool|null */
public ?bool $isWord=null,
/** @var bool|null */
public ?bool $isExcel=null,
/** @var string|null */
public ?string $fileName=null,
/** @var string|null */
public ?string $thumbnailUrl=null,
/** @var string|null */
public ?string $fileUrl=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['isImage'])) $this->isImage = $o['isImage'];
if (isset($o['isPdf'])) $this->isPdf = $o['isPdf'];
if (isset($o['isWord'])) $this->isWord = $o['isWord'];
if (isset($o['isExcel'])) $this->isExcel = $o['isExcel'];
if (isset($o['fileName'])) $this->fileName = $o['fileName'];
if (isset($o['thumbnailUrl'])) $this->thumbnailUrl = $o['thumbnailUrl'];
if (isset($o['fileUrl'])) $this->fileUrl = $o['fileUrl'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->isImage)) $o['isImage'] = $this->isImage;
if (isset($this->isPdf)) $o['isPdf'] = $this->isPdf;
if (isset($this->isWord)) $o['isWord'] = $this->isWord;
if (isset($this->isExcel)) $o['isExcel'] = $this->isExcel;
if (isset($this->fileName)) $o['fileName'] = $this->fileName;
if (isset($this->thumbnailUrl)) $o['thumbnailUrl'] = $this->thumbnailUrl;
if (isset($this->fileUrl)) $o['fileUrl'] = $this->fileUrl;
return empty($o) ? new class(){} : $o;
}
}
class NotificationMessageData implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $title=null,
/** @var string|null */
public ?string $content=null,
/** @var string|null */
public ?string $sentBy=null,
/** @var int */
public int $systemUserMessageId=0,
/** @var string|null */
public ?string $dateSent=null,
/** @var string|null */
public ?string $comment=null,
/** @var bool|null */
public ?bool $hasComment=null,
/** @var string|null */
public ?string $commentDate=null,
/** @var bool|null */
public ?bool $hasAttachments=null,
/** @var array<NotificationMessageAttachment>|null */
public ?array $attachmentList=null,
/** @var bool|null */
public ?bool $hasRead=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['title'])) $this->title = $o['title'];
if (isset($o['content'])) $this->content = $o['content'];
if (isset($o['sentBy'])) $this->sentBy = $o['sentBy'];
if (isset($o['systemUserMessageId'])) $this->systemUserMessageId = $o['systemUserMessageId'];
if (isset($o['dateSent'])) $this->dateSent = $o['dateSent'];
if (isset($o['comment'])) $this->comment = $o['comment'];
if (isset($o['hasComment'])) $this->hasComment = $o['hasComment'];
if (isset($o['commentDate'])) $this->commentDate = $o['commentDate'];
if (isset($o['hasAttachments'])) $this->hasAttachments = $o['hasAttachments'];
if (isset($o['attachmentList'])) $this->attachmentList = JsonConverters::fromArray('NotificationMessageAttachment', $o['attachmentList']);
if (isset($o['hasRead'])) $this->hasRead = $o['hasRead'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->title)) $o['title'] = $this->title;
if (isset($this->content)) $o['content'] = $this->content;
if (isset($this->sentBy)) $o['sentBy'] = $this->sentBy;
if (isset($this->systemUserMessageId)) $o['systemUserMessageId'] = $this->systemUserMessageId;
if (isset($this->dateSent)) $o['dateSent'] = $this->dateSent;
if (isset($this->comment)) $o['comment'] = $this->comment;
if (isset($this->hasComment)) $o['hasComment'] = $this->hasComment;
if (isset($this->commentDate)) $o['commentDate'] = $this->commentDate;
if (isset($this->hasAttachments)) $o['hasAttachments'] = $this->hasAttachments;
if (isset($this->attachmentList)) $o['attachmentList'] = JsonConverters::toArray('NotificationMessageAttachment', $this->attachmentList);
if (isset($this->hasRead)) $o['hasRead'] = $this->hasRead;
return empty($o) ? new class(){} : $o;
}
}
class GetNotificationMessageResponse extends ApiServiceResponse implements JsonSerializable
{
/**
* @param string|null $description
* @param string|null $heading
* @param bool|null $wasSuccessful
* @param Object|null $modelState
*/
public function __construct(
?string $description=null,
?string $heading=null,
?bool $wasSuccessful=null,
?Object $modelState=null,
/** @var array<NotificationMessageData>|null */
public ?array $messages=null,
/** @var int */
public int $unreadCount=0
) {
parent::__construct($description,$heading,$wasSuccessful,$modelState);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['messages'])) $this->messages = JsonConverters::fromArray('NotificationMessageData', $o['messages']);
if (isset($o['unreadCount'])) $this->unreadCount = $o['unreadCount'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->messages)) $o['messages'] = JsonConverters::toArray('NotificationMessageData', $this->messages);
if (isset($this->unreadCount)) $o['unreadCount'] = $this->unreadCount;
return empty($o) ? new class(){} : $o;
}
}
class MessageComment extends ApiServiceRequest implements JsonSerializable
{
/**
* @param string $apiKey
* @param float $latitude
* @param float $longitude
*/
public function __construct(
string $apiKey='',
float $latitude=0.0,
float $longitude=0.0,
// @ApiMember(IsRequired=true)
/** @var int */
public int $systemUserMessageId=0,
// @ApiMember(IsRequired=true)
/** @var string */
public string $comment=''
) {
parent::__construct($apiKey,$latitude,$longitude);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['systemUserMessageId'])) $this->systemUserMessageId = $o['systemUserMessageId'];
if (isset($o['comment'])) $this->comment = $o['comment'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->systemUserMessageId)) $o['systemUserMessageId'] = $this->systemUserMessageId;
if (isset($this->comment)) $o['comment'] = $this->comment;
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 /notificationcentre/comment HTTP/1.1
Host: cochraneplus-api-dev.happen.zone
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
systemUserMessageId: 0,
comment: String,
apiKey: String,
latitude: 0,
longitude: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
messages:
[
{
}
],
unreadCount: 0,
description: String,
heading: String,
wasSuccessful: False,
modelState: {}
}