<?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};
// @DataContract
class Translation implements ITranslation, JsonSerializable
{
public function __construct(
// @DataMember
/** @var string|null */
public ?string $Key=null,
// @DataMember
/** @var string|null */
public ?string $NL=null,
// @DataMember
/** @var string|null */
public ?string $EN=null,
// @DataMember
/** @var string|null */
public ?string $DE=null,
// @DataMember
/** @var string|null */
public ?string $FR=null,
// @DataMember
/** @var string|null */
public ?string $C1=null,
// @DataMember
/** @var string|null */
public ?string $C2=null,
// @DataMember
/** @var string|null */
public ?string $C3=null,
// @DataMember
/** @var string|null */
public ?string $C4=null,
// @DataMember
/** @var string|null */
public ?string $C5=null,
// @DataMember
/** @var string|null */
public ?string $C6=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Key'])) $this->Key = $o['Key'];
if (isset($o['NL'])) $this->NL = $o['NL'];
if (isset($o['EN'])) $this->EN = $o['EN'];
if (isset($o['DE'])) $this->DE = $o['DE'];
if (isset($o['FR'])) $this->FR = $o['FR'];
if (isset($o['C1'])) $this->C1 = $o['C1'];
if (isset($o['C2'])) $this->C2 = $o['C2'];
if (isset($o['C3'])) $this->C3 = $o['C3'];
if (isset($o['C4'])) $this->C4 = $o['C4'];
if (isset($o['C5'])) $this->C5 = $o['C5'];
if (isset($o['C6'])) $this->C6 = $o['C6'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Key)) $o['Key'] = $this->Key;
if (isset($this->NL)) $o['NL'] = $this->NL;
if (isset($this->EN)) $o['EN'] = $this->EN;
if (isset($this->DE)) $o['DE'] = $this->DE;
if (isset($this->FR)) $o['FR'] = $this->FR;
if (isset($this->C1)) $o['C1'] = $this->C1;
if (isset($this->C2)) $o['C2'] = $this->C2;
if (isset($this->C3)) $o['C3'] = $this->C3;
if (isset($this->C4)) $o['C4'] = $this->C4;
if (isset($this->C5)) $o['C5'] = $this->C5;
if (isset($this->C6)) $o['C6'] = $this->C6;
return empty($o) ? new class(){} : $o;
}
}
// @DataContract
class GetTranslationsResponse implements JsonSerializable
{
public function __construct(
// @DataMember
/** @var array<Translation>|null */
public ?array $Translations=null,
// @DataMember
/** @var string|null */
public ?string $PreferredLanguage=null,
// @DataMember
/** @var string|null */
public ?string $PreferredLanguageShort=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Translations'])) $this->Translations = JsonConverters::fromArray('Translation', $o['Translations']);
if (isset($o['PreferredLanguage'])) $this->PreferredLanguage = $o['PreferredLanguage'];
if (isset($o['PreferredLanguageShort'])) $this->PreferredLanguageShort = $o['PreferredLanguageShort'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Translations)) $o['Translations'] = JsonConverters::toArray('Translation', $this->Translations);
if (isset($this->PreferredLanguage)) $o['PreferredLanguage'] = $this->PreferredLanguage;
if (isset($this->PreferredLanguageShort)) $o['PreferredLanguageShort'] = $this->PreferredLanguageShort;
return empty($o) ? new class(){} : $o;
}
}
class GetTranslations implements JsonSerializable
{
public function __construct(
/** @var array<string>|null */
public ?array $TranslateKeys=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['TranslateKeys'])) $this->TranslateKeys = JsonConverters::fromArray('string', $o['TranslateKeys']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->TranslateKeys)) $o['TranslateKeys'] = JsonConverters::toArray('string', $this->TranslateKeys);
return empty($o) ? new class(){} : $o;
}
}
class GetUserTranslations extends GetTranslations implements JsonSerializable
{
/**
* @param array<string>|null $TranslateKeys
*/
public function __construct(
?array $TranslateKeys=null
) {
parent::__construct($TranslateKeys);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
return empty($o) ? new class(){} : $o;
}
}
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 /json/reply/GetUserTranslations HTTP/1.1
Host: dogw.klokgroep.nl
Accept: application/json
Content-Type: application/json
Content-Length: length
{"TranslateKeys":["String"]}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"Translations":[{"Key":"String","NL":"String","EN":"String","DE":"String","FR":"String","C1":"String","C2":"String","C3":"String","C4":"String","C5":"String","C6":"String"}],"PreferredLanguage":"String","PreferredLanguageShort":"String"}