<?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 AuditBase implements JsonSerializable
{
public function __construct(
// @DataMember(Order=1)
/** @var DateTime */
public DateTime $createdDate=new DateTime(),
// @DataMember(Order=2)
// @Required()
/** @var string */
public string $createdBy='',
// @DataMember(Order=3)
/** @var DateTime */
public DateTime $modifiedDate=new DateTime(),
// @DataMember(Order=4)
// @Required()
/** @var string */
public string $modifiedBy='',
// @DataMember(Order=5)
/** @var DateTime|null */
public ?DateTime $deletedDate=null,
// @DataMember(Order=6)
/** @var string|null */
public ?string $deletedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
if (isset($o['modifiedDate'])) $this->modifiedDate = JsonConverters::from('DateTime', $o['modifiedDate']);
if (isset($o['modifiedBy'])) $this->modifiedBy = $o['modifiedBy'];
if (isset($o['deletedDate'])) $this->deletedDate = JsonConverters::from('DateTime', $o['deletedDate']);
if (isset($o['deletedBy'])) $this->deletedBy = $o['deletedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
if (isset($this->modifiedDate)) $o['modifiedDate'] = JsonConverters::to('DateTime', $this->modifiedDate);
if (isset($this->modifiedBy)) $o['modifiedBy'] = $this->modifiedBy;
if (isset($this->deletedDate)) $o['deletedDate'] = JsonConverters::to('DateTime', $this->deletedDate);
if (isset($this->deletedBy)) $o['deletedBy'] = $this->deletedBy;
return empty($o) ? new class(){} : $o;
}
}
class Artifact extends AuditBase implements JsonSerializable
{
/**
* @param DateTime $createdDate
* @param string $createdBy
* @param DateTime $modifiedDate
* @param string $modifiedBy
* @param DateTime|null $deletedDate
* @param string|null $deletedBy
*/
public function __construct(
DateTime $createdDate=new DateTime(),
string $createdBy='',
DateTime $modifiedDate=new DateTime(),
string $modifiedBy='',
?DateTime $deletedDate=null,
?string $deletedBy=null,
/** @var int */
public int $id=0,
// @References("typeof(BlazorDiffusion.ServiceModel.Creative)")
/** @var int */
public int $creativeId=0,
/** @var string */
public string $fileName='',
/** @var string */
public string $filePath='',
/** @var string */
public string $contentType='',
/** @var int */
public int $contentLength=0,
/** @var int */
public int $width=0,
/** @var int */
public int $height=0,
/** @var int */
public int $seed=0,
/** @var string */
public string $prompt='',
/** @var bool|null */
public ?bool $nsfw=null,
/** @var int|null */
public ?int $averageHash=null,
/** @var int|null */
public ?int $perceptualHash=null,
/** @var int|null */
public ?int $differenceHash=null,
/** @var string|null */
public ?string $background=null,
/** @var string|null */
public ?string $lqip=null,
/** @var int */
public int $quality=0,
/** @var int */
public int $likesCount=0,
/** @var int */
public int $albumsCount=0,
/** @var int */
public int $downloadsCount=0,
/** @var int */
public int $searchCount=0,
/** @var int */
public int $temporalScore=0,
/** @var int */
public int $score=0,
/** @var int */
public int $rank=0,
/** @var string */
public string $refId='',
/** @var array<string,string>|null */
public ?array $versions=null
) {
parent::__construct($createdDate,$createdBy,$modifiedDate,$modifiedBy,$deletedDate,$deletedBy);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['creativeId'])) $this->creativeId = $o['creativeId'];
if (isset($o['fileName'])) $this->fileName = $o['fileName'];
if (isset($o['filePath'])) $this->filePath = $o['filePath'];
if (isset($o['contentType'])) $this->contentType = $o['contentType'];
if (isset($o['contentLength'])) $this->contentLength = $o['contentLength'];
if (isset($o['width'])) $this->width = $o['width'];
if (isset($o['height'])) $this->height = $o['height'];
if (isset($o['seed'])) $this->seed = $o['seed'];
if (isset($o['prompt'])) $this->prompt = $o['prompt'];
if (isset($o['nsfw'])) $this->nsfw = $o['nsfw'];
if (isset($o['averageHash'])) $this->averageHash = $o['averageHash'];
if (isset($o['perceptualHash'])) $this->perceptualHash = $o['perceptualHash'];
if (isset($o['differenceHash'])) $this->differenceHash = $o['differenceHash'];
if (isset($o['background'])) $this->background = $o['background'];
if (isset($o['lqip'])) $this->lqip = $o['lqip'];
if (isset($o['quality'])) $this->quality = $o['quality'];
if (isset($o['likesCount'])) $this->likesCount = $o['likesCount'];
if (isset($o['albumsCount'])) $this->albumsCount = $o['albumsCount'];
if (isset($o['downloadsCount'])) $this->downloadsCount = $o['downloadsCount'];
if (isset($o['searchCount'])) $this->searchCount = $o['searchCount'];
if (isset($o['temporalScore'])) $this->temporalScore = $o['temporalScore'];
if (isset($o['score'])) $this->score = $o['score'];
if (isset($o['rank'])) $this->rank = $o['rank'];
if (isset($o['refId'])) $this->refId = $o['refId'];
if (isset($o['versions'])) $this->versions = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['versions']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->creativeId)) $o['creativeId'] = $this->creativeId;
if (isset($this->fileName)) $o['fileName'] = $this->fileName;
if (isset($this->filePath)) $o['filePath'] = $this->filePath;
if (isset($this->contentType)) $o['contentType'] = $this->contentType;
if (isset($this->contentLength)) $o['contentLength'] = $this->contentLength;
if (isset($this->width)) $o['width'] = $this->width;
if (isset($this->height)) $o['height'] = $this->height;
if (isset($this->seed)) $o['seed'] = $this->seed;
if (isset($this->prompt)) $o['prompt'] = $this->prompt;
if (isset($this->nsfw)) $o['nsfw'] = $this->nsfw;
if (isset($this->averageHash)) $o['averageHash'] = $this->averageHash;
if (isset($this->perceptualHash)) $o['perceptualHash'] = $this->perceptualHash;
if (isset($this->differenceHash)) $o['differenceHash'] = $this->differenceHash;
if (isset($this->background)) $o['background'] = $this->background;
if (isset($this->lqip)) $o['lqip'] = $this->lqip;
if (isset($this->quality)) $o['quality'] = $this->quality;
if (isset($this->likesCount)) $o['likesCount'] = $this->likesCount;
if (isset($this->albumsCount)) $o['albumsCount'] = $this->albumsCount;
if (isset($this->downloadsCount)) $o['downloadsCount'] = $this->downloadsCount;
if (isset($this->searchCount)) $o['searchCount'] = $this->searchCount;
if (isset($this->temporalScore)) $o['temporalScore'] = $this->temporalScore;
if (isset($this->score)) $o['score'] = $this->score;
if (isset($this->rank)) $o['rank'] = $this->rank;
if (isset($this->refId)) $o['refId'] = $this->refId;
if (isset($this->versions)) $o['versions'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->versions);
return empty($o) ? new class(){} : $o;
}
}
enum ReportType : string
{
case Nsfw = 'Nsfw';
case Malformed = 'Malformed';
case Blurred = 'Blurred';
case LowQuality = 'LowQuality';
case Other = 'Other';
}
class ArtifactReport implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
// @References("typeof(BlazorDiffusion.ServiceModel.Artifact)")
/** @var int */
public int $artifactId=0,
/** @var int */
public int $appUserId=0,
/** @var Artifact|null */
public ?Artifact $artifact=null,
/** @var ReportType|null */
public ?ReportType $type=null,
/** @var string|null */
public ?string $description=null,
/** @var DateTime */
public DateTime $createdDate=new DateTime(),
/** @var string|null */
public ?string $notes=null,
/** @var DateTime|null */
public ?DateTime $actionedDate=null,
/** @var string|null */
public ?string $actionedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['artifactId'])) $this->artifactId = $o['artifactId'];
if (isset($o['appUserId'])) $this->appUserId = $o['appUserId'];
if (isset($o['artifact'])) $this->artifact = JsonConverters::from('Artifact', $o['artifact']);
if (isset($o['type'])) $this->type = JsonConverters::from('ReportType', $o['type']);
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
if (isset($o['notes'])) $this->notes = $o['notes'];
if (isset($o['actionedDate'])) $this->actionedDate = JsonConverters::from('DateTime', $o['actionedDate']);
if (isset($o['actionedBy'])) $this->actionedBy = $o['actionedBy'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->artifactId)) $o['artifactId'] = $this->artifactId;
if (isset($this->appUserId)) $o['appUserId'] = $this->appUserId;
if (isset($this->artifact)) $o['artifact'] = JsonConverters::to('Artifact', $this->artifact);
if (isset($this->type)) $o['type'] = JsonConverters::to('ReportType', $this->type);
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
if (isset($this->notes)) $o['notes'] = $this->notes;
if (isset($this->actionedDate)) $o['actionedDate'] = JsonConverters::to('DateTime', $this->actionedDate);
if (isset($this->actionedBy)) $o['actionedBy'] = $this->actionedBy;
return empty($o) ? new class(){} : $o;
}
}
// @ValidateRequest(Validator="IsAuthenticated")
/**
* @template ICreateDb of ArtifactReport
*/
class CreateArtifactReport implements ICreateDb, JsonSerializable
{
public function __construct(
// @Validate(Validator="GreaterThan(0)")
/** @var int */
public int $artifactId=0,
/** @var ReportType|null */
public ?ReportType $type=null,
/** @var string|null */
public ?string $description=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['artifactId'])) $this->artifactId = $o['artifactId'];
if (isset($o['type'])) $this->type = JsonConverters::from('ReportType', $o['type']);
if (isset($o['description'])) $this->description = $o['description'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->artifactId)) $o['artifactId'] = $this->artifactId;
if (isset($this->type)) $o['type'] = JsonConverters::to('ReportType', $this->type);
if (isset($this->description)) $o['description'] = $this->description;
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/CreateArtifactReport HTTP/1.1
Host: blazordiffusion.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
artifactId: 0,
type: Nsfw,
description: String
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { id: 0, artifactId: 0, appUserId: 0, artifact: { id: 0, creativeId: 0, fileName: String, filePath: String, contentType: String, contentLength: 0, width: 0, height: 0, seed: 0, prompt: String, nsfw: False, averageHash: 0, perceptualHash: 0, differenceHash: 0, background: String, lqip: String, quality: 0, likesCount: 0, albumsCount: 0, downloadsCount: 0, searchCount: 0, temporalScore: 0, score: 0, rank: 0, refId: String, versions: { String: String }, createdDate: 0001-01-01, createdBy: String, modifiedDate: 0001-01-01, modifiedBy: String, deletedDate: 0001-01-01, deletedBy: String }, type: Nsfw, description: String, createdDate: 0001-01-01, notes: String, actionedDate: 0001-01-01, actionedBy: String }