<?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 DocumentComment implements IComment, JsonSerializable
{
public function __construct(
/** @var int */
public int $ID=0,
/** @var string */
public string $DocumentID='',
/** @var int */
public int $UserID=0,
/** @var string|null */
public ?string $Username=null,
/** @var string|null */
public ?string $Text=null,
/** @var DateTime */
public DateTime $Date=new DateTime(),
/** @var bool|null */
public ?bool $IsMine=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ID'])) $this->ID = $o['ID'];
if (isset($o['DocumentID'])) $this->DocumentID = $o['DocumentID'];
if (isset($o['UserID'])) $this->UserID = $o['UserID'];
if (isset($o['Username'])) $this->Username = $o['Username'];
if (isset($o['Text'])) $this->Text = $o['Text'];
if (isset($o['Date'])) $this->Date = JsonConverters::from('DateTime', $o['Date']);
if (isset($o['IsMine'])) $this->IsMine = $o['IsMine'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ID)) $o['ID'] = $this->ID;
if (isset($this->DocumentID)) $o['DocumentID'] = $this->DocumentID;
if (isset($this->UserID)) $o['UserID'] = $this->UserID;
if (isset($this->Username)) $o['Username'] = $this->Username;
if (isset($this->Text)) $o['Text'] = $this->Text;
if (isset($this->Date)) $o['Date'] = JsonConverters::to('DateTime', $this->Date);
if (isset($this->IsMine)) $o['IsMine'] = $this->IsMine;
return empty($o) ? new class(){} : $o;
}
}
class SetDocumentComment implements JsonSerializable
{
public function __construct(
/** @var string */
public string $ID='',
/** @var string|null */
public ?string $Comment=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ID'])) $this->ID = $o['ID'];
if (isset($o['Comment'])) $this->Comment = $o['Comment'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ID)) $o['ID'] = $this->ID;
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 .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/reply/SetDocumentComment HTTP/1.1
Host: test-do-services.klokgroep.nl
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"ID":"00000000-0000-0000-0000-000000000000","Comment":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"ID":0,"DocumentID":"00000000-0000-0000-0000-000000000000","UserID":0,"Username":"String","Text":"String","Date":"0001-01-01T00:00:00.0000000","IsMine":false}