<?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 CheckQuotaResponse implements JsonSerializable
{
public function __construct(
/** @var DateInterval|null */
public ?DateInterval $timeRemaining=null,
/** @var int */
public int $creditsUsed=0,
/** @var int */
public int $creditsRequested=0,
/** @var int */
public int $creditsRemaining=0,
/** @var int */
public int $dailyQuota=0,
/** @var string */
public string $requestedDetails=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['timeRemaining'])) $this->timeRemaining = JsonConverters::from('DateInterval', $o['timeRemaining']);
if (isset($o['creditsUsed'])) $this->creditsUsed = $o['creditsUsed'];
if (isset($o['creditsRequested'])) $this->creditsRequested = $o['creditsRequested'];
if (isset($o['creditsRemaining'])) $this->creditsRemaining = $o['creditsRemaining'];
if (isset($o['dailyQuota'])) $this->dailyQuota = $o['dailyQuota'];
if (isset($o['requestedDetails'])) $this->requestedDetails = $o['requestedDetails'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->timeRemaining)) $o['timeRemaining'] = JsonConverters::to('DateInterval', $this->timeRemaining);
if (isset($this->creditsUsed)) $o['creditsUsed'] = $this->creditsUsed;
if (isset($this->creditsRequested)) $o['creditsRequested'] = $this->creditsRequested;
if (isset($this->creditsRemaining)) $o['creditsRemaining'] = $this->creditsRemaining;
if (isset($this->dailyQuota)) $o['dailyQuota'] = $this->dailyQuota;
if (isset($this->requestedDetails)) $o['requestedDetails'] = $this->requestedDetails;
return empty($o) ? new class(){} : $o;
}
}
// @ValidateRequest(Validator="IsAuthenticated")
class CheckQuota implements JsonSerializable
{
public function __construct(
/** @var int */
public int $images=0,
/** @var int */
public int $width=0,
/** @var int */
public int $height=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['images'])) $this->images = $o['images'];
if (isset($o['width'])) $this->width = $o['width'];
if (isset($o['height'])) $this->height = $o['height'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->images)) $o['images'] = $this->images;
if (isset($this->width)) $o['width'] = $this->width;
if (isset($this->height)) $o['height'] = $this->height;
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/CheckQuota HTTP/1.1
Host: blazordiffusion.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
images: 0,
width: 0,
height: 0
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { timeRemaining: PT0S, creditsUsed: 0, creditsRequested: 0, creditsRemaining: 0, dailyQuota: 0, requestedDetails: String }