POST | /RestApi/comments-api/comments/filter |
---|
<?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 CommentResponse implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Key=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Message=null,
/** @var DateTime */
public DateTime $DateCreated=new DateTime(),
/** @var string|null */
public ?string $ProfilePictureUrl=null,
/** @var string|null */
public ?string $ProfilePictureThumbnailUrl=null,
/** @var string|null */
public ?string $Status=null,
/** @var string|null */
public ?string $Email=null,
/** @var string|null */
public ?string $ThreadKey=null,
/** @var string|null */
public ?string $AuthorIpAddress=null,
/** @var string|null */
public ?string $CustomData=null,
/** @var float|null */
public ?float $Rating=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Key'])) $this->Key = $o['Key'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Message'])) $this->Message = $o['Message'];
if (isset($o['DateCreated'])) $this->DateCreated = JsonConverters::from('DateTime', $o['DateCreated']);
if (isset($o['ProfilePictureUrl'])) $this->ProfilePictureUrl = $o['ProfilePictureUrl'];
if (isset($o['ProfilePictureThumbnailUrl'])) $this->ProfilePictureThumbnailUrl = $o['ProfilePictureThumbnailUrl'];
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['ThreadKey'])) $this->ThreadKey = $o['ThreadKey'];
if (isset($o['AuthorIpAddress'])) $this->AuthorIpAddress = $o['AuthorIpAddress'];
if (isset($o['CustomData'])) $this->CustomData = $o['CustomData'];
if (isset($o['Rating'])) $this->Rating = $o['Rating'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Key)) $o['Key'] = $this->Key;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Message)) $o['Message'] = $this->Message;
if (isset($this->DateCreated)) $o['DateCreated'] = JsonConverters::to('DateTime', $this->DateCreated);
if (isset($this->ProfilePictureUrl)) $o['ProfilePictureUrl'] = $this->ProfilePictureUrl;
if (isset($this->ProfilePictureThumbnailUrl)) $o['ProfilePictureThumbnailUrl'] = $this->ProfilePictureThumbnailUrl;
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->ThreadKey)) $o['ThreadKey'] = $this->ThreadKey;
if (isset($this->AuthorIpAddress)) $o['AuthorIpAddress'] = $this->AuthorIpAddress;
if (isset($this->CustomData)) $o['CustomData'] = $this->CustomData;
if (isset($this->Rating)) $o['Rating'] = $this->Rating;
return empty($o) ? new class(){} : $o;
}
}
class CommentsFilterExtended implements JsonSerializable
{
public function __construct(
/** @var array<string>|null */
public ?array $CommentKey=null,
/** @var array<string>|null */
public ?array $ThreadKey=null,
/** @var array<string>|null */
public ?array $Language=null,
/** @var array<string>|null */
public ?array $AuthorKey=null,
/** @var array<string>|null */
public ?array $Status=null,
/** @var array<string>|null */
public ?array $ThreadType=null,
/** @var array<string>|null */
public ?array $Behavior=null,
/** @var array<string>|null */
public ?array $GroupKey=null,
/** @var int */
public int $Skip=0,
/** @var int */
public int $Take=0,
/** @var bool|null */
public ?bool $SortDescending=null,
/** @var DateTime */
public DateTime $NewerThan=new DateTime(),
/** @var DateTime */
public DateTime $OlderThan=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CommentKey'])) $this->CommentKey = JsonConverters::fromArray('string', $o['CommentKey']);
if (isset($o['ThreadKey'])) $this->ThreadKey = JsonConverters::fromArray('string', $o['ThreadKey']);
if (isset($o['Language'])) $this->Language = JsonConverters::fromArray('string', $o['Language']);
if (isset($o['AuthorKey'])) $this->AuthorKey = JsonConverters::fromArray('string', $o['AuthorKey']);
if (isset($o['Status'])) $this->Status = JsonConverters::fromArray('string', $o['Status']);
if (isset($o['ThreadType'])) $this->ThreadType = JsonConverters::fromArray('string', $o['ThreadType']);
if (isset($o['Behavior'])) $this->Behavior = JsonConverters::fromArray('string', $o['Behavior']);
if (isset($o['GroupKey'])) $this->GroupKey = JsonConverters::fromArray('string', $o['GroupKey']);
if (isset($o['Skip'])) $this->Skip = $o['Skip'];
if (isset($o['Take'])) $this->Take = $o['Take'];
if (isset($o['SortDescending'])) $this->SortDescending = $o['SortDescending'];
if (isset($o['NewerThan'])) $this->NewerThan = JsonConverters::from('DateTime', $o['NewerThan']);
if (isset($o['OlderThan'])) $this->OlderThan = JsonConverters::from('DateTime', $o['OlderThan']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CommentKey)) $o['CommentKey'] = JsonConverters::toArray('string', $this->CommentKey);
if (isset($this->ThreadKey)) $o['ThreadKey'] = JsonConverters::toArray('string', $this->ThreadKey);
if (isset($this->Language)) $o['Language'] = JsonConverters::toArray('string', $this->Language);
if (isset($this->AuthorKey)) $o['AuthorKey'] = JsonConverters::toArray('string', $this->AuthorKey);
if (isset($this->Status)) $o['Status'] = JsonConverters::toArray('string', $this->Status);
if (isset($this->ThreadType)) $o['ThreadType'] = JsonConverters::toArray('string', $this->ThreadType);
if (isset($this->Behavior)) $o['Behavior'] = JsonConverters::toArray('string', $this->Behavior);
if (isset($this->GroupKey)) $o['GroupKey'] = JsonConverters::toArray('string', $this->GroupKey);
if (isset($this->Skip)) $o['Skip'] = $this->Skip;
if (isset($this->Take)) $o['Take'] = $this->Take;
if (isset($this->SortDescending)) $o['SortDescending'] = $this->SortDescending;
if (isset($this->NewerThan)) $o['NewerThan'] = JsonConverters::to('DateTime', $this->NewerThan);
if (isset($this->OlderThan)) $o['OlderThan'] = JsonConverters::to('DateTime', $this->OlderThan);
return empty($o) ? new class(){} : $o;
}
}
/**
* @template CommentResponse
*/
class CollectionResponse implements JsonSerializable
{
public array $genericArgs = [];
public static function create(array $genericArgs=[]): CollectionResponse {
$to = new CollectionResponse();
$to->genericArgs = $genericArgs;
return $to;
}
public function __construct(
/** @var int */
public mixed $TotalCount=0,
/** @var array<CommentResponse>|null */
public mixed $Items=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['TotalCount'])) $this->TotalCount = $o['TotalCount'];
if (isset($o['Items'])) $this->Items = JsonConverters::fromArray($this->genericArgs[0], $o['Items']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->TotalCount)) $o['TotalCount'] = $this->TotalCount;
if (isset($this->Items)) $o['Items'] = JsonConverters::toArray($this->genericArgs[0], $this->Items);
return empty($o) ? new class(){} : $o;
}
}
PHP CommentsFilterExtended DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /RestApi/comments-api/comments/filter HTTP/1.1
Host: www.asg.com.au
Accept: application/json
Content-Type: application/json
Content-Length: length
{"CommentKey":["String"],"ThreadKey":["String"],"Language":["String"],"AuthorKey":["String"],"Status":["String"],"ThreadType":["String"],"Behavior":["String"],"GroupKey":["String"],"Skip":0,"Take":0,"SortDescending":false,"NewerThan":"\/Date(-62135596800000-0000)\/","OlderThan":"\/Date(-62135596800000-0000)\/"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"TotalCount":0}