POST | /RestApi/reviews-api |
---|
<?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 GroupCreateRequest implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Key=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Description=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['Description'])) $this->Description = $o['Description'];
}
/** @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->Description)) $o['Description'] = $this->Description;
return empty($o) ? new class(){} : $o;
}
}
class ThreadCreateRequest implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Key=null,
/** @var string|null */
public ?string $Type=null,
/** @var string|null */
public ?string $Behavior=null,
/** @var string|null */
public ?string $Title=null,
/** @var string|null */
public ?string $Language=null,
/** @var string|null */
public ?string $DataSource=null,
/** @var string|null */
public ?string $GroupKey=null,
/** @var GroupCreateRequest|null */
public ?GroupCreateRequest $Group=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Key'])) $this->Key = $o['Key'];
if (isset($o['Type'])) $this->Type = $o['Type'];
if (isset($o['Behavior'])) $this->Behavior = $o['Behavior'];
if (isset($o['Title'])) $this->Title = $o['Title'];
if (isset($o['Language'])) $this->Language = $o['Language'];
if (isset($o['DataSource'])) $this->DataSource = $o['DataSource'];
if (isset($o['GroupKey'])) $this->GroupKey = $o['GroupKey'];
if (isset($o['Group'])) $this->Group = JsonConverters::from('GroupCreateRequest', $o['Group']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Key)) $o['Key'] = $this->Key;
if (isset($this->Type)) $o['Type'] = $this->Type;
if (isset($this->Behavior)) $o['Behavior'] = $this->Behavior;
if (isset($this->Title)) $o['Title'] = $this->Title;
if (isset($this->Language)) $o['Language'] = $this->Language;
if (isset($this->DataSource)) $o['DataSource'] = $this->DataSource;
if (isset($this->GroupKey)) $o['GroupKey'] = $this->GroupKey;
if (isset($this->Group)) $o['Group'] = JsonConverters::to('GroupCreateRequest', $this->Group);
return empty($o) ? new class(){} : $o;
}
}
class CaptchaInfo implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Answer=null,
/** @var string|null */
public ?string $CorrectAnswer=null,
/** @var string|null */
public ?string $InitializationVector=null,
/** @var string|null */
public ?string $Key=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Answer'])) $this->Answer = $o['Answer'];
if (isset($o['CorrectAnswer'])) $this->CorrectAnswer = $o['CorrectAnswer'];
if (isset($o['InitializationVector'])) $this->InitializationVector = $o['InitializationVector'];
if (isset($o['Key'])) $this->Key = $o['Key'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Answer)) $o['Answer'] = $this->Answer;
if (isset($this->CorrectAnswer)) $o['CorrectAnswer'] = $this->CorrectAnswer;
if (isset($this->InitializationVector)) $o['InitializationVector'] = $this->InitializationVector;
if (isset($this->Key)) $o['Key'] = $this->Key;
return empty($o) ? new class(){} : $o;
}
}
class ReviewCreateRequest implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Message=null,
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Email=null,
/** @var string|null */
public ?string $CustomData=null,
/** @var string|null */
public ?string $ThreadKey=null,
/** @var ThreadCreateRequest|null */
public ?ThreadCreateRequest $Thread=null,
/** @var CaptchaInfo|null */
public ?CaptchaInfo $Captcha=null,
/** @var float|null */
public ?float $Rating=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Message'])) $this->Message = $o['Message'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Email'])) $this->Email = $o['Email'];
if (isset($o['CustomData'])) $this->CustomData = $o['CustomData'];
if (isset($o['ThreadKey'])) $this->ThreadKey = $o['ThreadKey'];
if (isset($o['Thread'])) $this->Thread = JsonConverters::from('ThreadCreateRequest', $o['Thread']);
if (isset($o['Captcha'])) $this->Captcha = JsonConverters::from('CaptchaInfo', $o['Captcha']);
if (isset($o['Rating'])) $this->Rating = $o['Rating'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Message)) $o['Message'] = $this->Message;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Email)) $o['Email'] = $this->Email;
if (isset($this->CustomData)) $o['CustomData'] = $this->CustomData;
if (isset($this->ThreadKey)) $o['ThreadKey'] = $this->ThreadKey;
if (isset($this->Thread)) $o['Thread'] = JsonConverters::to('ThreadCreateRequest', $this->Thread);
if (isset($this->Captcha)) $o['Captcha'] = JsonConverters::to('CaptchaInfo', $this->Captcha);
if (isset($this->Rating)) $o['Rating'] = $this->Rating;
return empty($o) ? new class(){} : $o;
}
}
class ReviewViewModel 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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /RestApi/reviews-api HTTP/1.1
Host: www.asg.com.au
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"Message":"String","Name":"String","Email":"String","CustomData":"String","ThreadKey":"String","Thread":{"Key":"String","Type":"String","Behavior":"String","Title":"String","Language":"String","DataSource":"String","GroupKey":"String","Group":{"Key":"String","Name":"String","Description":"String"}},"Captcha":{"Answer":"String","CorrectAnswer":"String","InitializationVector":"String","Key":"String"},"Rating":0}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"Key":"String","Name":"String","Message":"String","DateCreated":"\/Date(-62135596800000-0000)\/","ProfilePictureUrl":"String","ProfilePictureThumbnailUrl":"String","Status":"String","Email":"String","ThreadKey":"String","AuthorIpAddress":"String","CustomData":"String","Rating":0}