<?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 AlbumResult implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var string */
public string $name='',
/** @var string */
public string $slug='',
/** @var string */
public string $albumRef='',
/** @var string */
public string $ownerRef='',
/** @var int|null */
public ?int $primaryArtifactId=null,
/** @var int */
public int $score=0,
/** @var array<int>|null */
public ?array $artifactIds=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['slug'])) $this->slug = $o['slug'];
if (isset($o['albumRef'])) $this->albumRef = $o['albumRef'];
if (isset($o['ownerRef'])) $this->ownerRef = $o['ownerRef'];
if (isset($o['primaryArtifactId'])) $this->primaryArtifactId = $o['primaryArtifactId'];
if (isset($o['score'])) $this->score = $o['score'];
if (isset($o['artifactIds'])) $this->artifactIds = JsonConverters::fromArray('int', $o['artifactIds']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->slug)) $o['slug'] = $this->slug;
if (isset($this->albumRef)) $o['albumRef'] = $this->albumRef;
if (isset($this->ownerRef)) $o['ownerRef'] = $this->ownerRef;
if (isset($this->primaryArtifactId)) $o['primaryArtifactId'] = $this->primaryArtifactId;
if (isset($this->score)) $o['score'] = $this->score;
if (isset($this->artifactIds)) $o['artifactIds'] = JsonConverters::toArray('int', $this->artifactIds);
return empty($o) ? new class(){} : $o;
}
}
class AnonDataResponse implements JsonSerializable
{
public function __construct(
/** @var array<AlbumResult>|null */
public ?array $topAlbums=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['topAlbums'])) $this->topAlbums = JsonConverters::fromArray('AlbumResult', $o['topAlbums']);
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->topAlbums)) $o['topAlbums'] = JsonConverters::toArray('AlbumResult', $this->topAlbums);
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
class AnonData implements JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsv/reply/AnonData HTTP/1.1
Host: blazordiffusion.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { topAlbums: [ { id: 0, name: String, slug: String, albumRef: String, ownerRef: String, primaryArtifactId: 0, score: 0, artifactIds: [ 0 ] } ], responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } }