<?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 .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /xml/reply/SetDocumentComment HTTP/1.1
Host: test-dogw.klokgroep.nl
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<SetDocumentComment xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.DTO.Document.Operations">
<Comment>String</Comment>
<ID>00000000-0000-0000-0000-000000000000</ID>
</SetDocumentComment>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <DocumentComment xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/IDB.API.DTO.Document"> <Date>0001-01-01T00:00:00</Date> <DocumentID>00000000-0000-0000-0000-000000000000</DocumentID> <ID>0</ID> <IsMine>false</IsMine> <Text>String</Text> <UserID>0</UserID> <Username>String</Username> </DocumentComment>