<?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 JsonDto implements JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
class GetJsonPicklistItems extends JsonDto implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $TemplateGuid=null,
/** @var string|null */
public ?string $Guid=null,
/** @var array<string,string>|null */
public ?array $Answers=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['TemplateGuid'])) $this->TemplateGuid = $o['TemplateGuid'];
if (isset($o['Guid'])) $this->Guid = $o['Guid'];
if (isset($o['Answers'])) $this->Answers = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Answers']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->TemplateGuid)) $o['TemplateGuid'] = $this->TemplateGuid;
if (isset($this->Guid)) $o['Guid'] = $this->Guid;
if (isset($this->Answers)) $o['Answers'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Answers);
return empty($o) ? new class(){} : $o;
}
}
class JsonPicklistItemsResponse extends JsonDto implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Guid=null,
/** @var JsonPicklistItem[]|null */
public ?array $Items=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Guid'])) $this->Guid = $o['Guid'];
if (isset($o['Items'])) $this->Items = JsonConverters::fromArray('JsonPicklistItem', $o['Items']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Guid)) $o['Guid'] = $this->Guid;
if (isset($this->Items)) $o['Items'] = JsonConverters::toArray('JsonPicklistItem', $this->Items);
return empty($o) ? new class(){} : $o;
}
}
class JsonPicklistItem implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Key=null,
/** @var string|null */
public ?string $Value=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Key'])) $this->Key = $o['Key'];
if (isset($o['Value'])) $this->Value = $o['Value'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Key)) $o['Key'] = $this->Key;
if (isset($this->Value)) $o['Value'] = $this->Value;
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 /csv/reply/GetJsonPicklistItems HTTP/1.1
Host: buildmax.org
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"TemplateGuid":"String","Guid":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{Unable to show example output for type 'JsonPicklistItemsResponse' using the custom 'csv' filter}No parameterless constructor defined for this object.