<?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 JsonRequestDto extends JsonDto implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $ClientCode=null,
/** @var string|null */
public ?string $ClientRegistrationCode=null,
/** @var string|null */
public ?string $Token=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['ClientCode'])) $this->ClientCode = $o['ClientCode'];
if (isset($o['ClientRegistrationCode'])) $this->ClientRegistrationCode = $o['ClientRegistrationCode'];
if (isset($o['Token'])) $this->Token = $o['Token'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->ClientCode)) $o['ClientCode'] = $this->ClientCode;
if (isset($this->ClientRegistrationCode)) $o['ClientRegistrationCode'] = $this->ClientRegistrationCode;
if (isset($this->Token)) $o['Token'] = $this->Token;
return empty($o) ? new class(){} : $o;
}
}
class JsonBrowseRequest extends JsonRequestDto implements JsonSerializable
{
/**
* @param string|null $ClientCode
* @param string|null $ClientRegistrationCode
* @param string|null $Token
*/
public function __construct(
?string $ClientCode=null,
?string $ClientRegistrationCode=null,
?string $Token=null,
/** @var string|null */
public ?string $Path=null
) {
parent::__construct($ClientCode,$ClientRegistrationCode,$Token);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Path'])) $this->Path = $o['Path'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Path)) $o['Path'] = $this->Path;
return empty($o) ? new class(){} : $o;
}
}
class JsonBrowsePicklistRequest extends JsonBrowseRequest implements JsonSerializable
{
/**
* @param string|null $ClientCode
* @param string|null $ClientRegistrationCode
* @param string|null $Token
* @param string|null $Path
*/
public function __construct(
?string $ClientCode=null,
?string $ClientRegistrationCode=null,
?string $Token=null,
?string $Path=null,
/** @var string|null */
public ?string $TemplateGuid=null,
/** @var string|null */
public ?string $PicklistGuid=null,
/** @var array<string,string>|null */
public ?array $Answers=null
) {
parent::__construct($ClientCode,$ClientRegistrationCode,$Token,$Path);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['TemplateGuid'])) $this->TemplateGuid = $o['TemplateGuid'];
if (isset($o['PicklistGuid'])) $this->PicklistGuid = $o['PicklistGuid'];
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->PicklistGuid)) $o['PicklistGuid'] = $this->PicklistGuid;
if (isset($this->Answers)) $o['Answers'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Answers);
return empty($o) ? new class(){} : $o;
}
}
class JsonBrowseResponse implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Path=null,
/** @var string[]|null */
public ?array $Folders=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Path'])) $this->Path = $o['Path'];
if (isset($o['Folders'])) $this->Folders = JsonConverters::fromArray('string', $o['Folders']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Path)) $o['Path'] = $this->Path;
if (isset($this->Folders)) $o['Folders'] = JsonConverters::toArray('string', $this->Folders);
return empty($o) ? new class(){} : $o;
}
}
PHP JsonBrowsePicklistRequest DTOs
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/JsonBrowsePicklistRequest HTTP/1.1
Host: buildmax.org
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"TemplateGuid":"String","PicklistGuid":"String","Path":"String","ClientCode":"String","ClientRegistrationCode":"String","Token":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"Path":"String","Folders":["String"]}