<?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 GetAlbumResultsResponse implements JsonSerializable
{
public function __construct(
/** @var array<AlbumResult>|null */
public ?array $results=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['results'])) $this->results = JsonConverters::fromArray('AlbumResult', $o['results']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->results)) $o['results'] = JsonConverters::toArray('AlbumResult', $this->results);
return empty($o) ? new class(){} : $o;
}
}
class GetAlbumResults implements JsonSerializable
{
public function __construct(
/** @var array<int>|null */
public ?array $ids=null,
/** @var array<string>|null */
public ?array $refIds=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ids'])) $this->ids = JsonConverters::fromArray('int', $o['ids']);
if (isset($o['refIds'])) $this->refIds = JsonConverters::fromArray('string', $o['refIds']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ids)) $o['ids'] = JsonConverters::toArray('int', $this->ids);
if (isset($this->refIds)) $o['refIds'] = JsonConverters::toArray('string', $this->refIds);
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/GetAlbumResults HTTP/1.1
Host: blazordiffusion.com
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"ids":[0],"refIds":["String"]}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"results":[{"id":0,"name":"String","slug":"String","albumRef":"String","ownerRef":"String","primaryArtifactId":0,"score":0,"artifactIds":[0]}]}