POST | /RegenerateLicenseKey |
---|
<?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};
enum LicenseType : string
{
case Free = 'Free';
case FreeIndividual = 'FreeIndividual';
case FreeOpenSource = 'FreeOpenSource';
case Indie = 'Indie';
case Business = 'Business';
case Enterprise = 'Enterprise';
case TextIndie = 'TextIndie';
case TextBusiness = 'TextBusiness';
case OrmLiteIndie = 'OrmLiteIndie';
case OrmLiteBusiness = 'OrmLiteBusiness';
case RedisIndie = 'RedisIndie';
case RedisBusiness = 'RedisBusiness';
case AwsIndie = 'AwsIndie';
case AwsBusiness = 'AwsBusiness';
case Trial = 'Trial';
case Site = 'Site';
case TextSite = 'TextSite';
case RedisSite = 'RedisSite';
case OrmLiteSite = 'OrmLiteSite';
}
class LicenseKey implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $ref=null,
/** @var string|null */
public ?string $name=null,
/** @var LicenseType|null */
public ?LicenseType $type=null,
/** @var int */
public int $meta=0,
/** @var string|null */
public ?string $hash=null,
/** @var string|null */
public ?string $halg=null,
/** @var DateTime */
public DateTime $expiry=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ref'])) $this->ref = $o['ref'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['type'])) $this->type = JsonConverters::from('LicenseType', $o['type']);
if (isset($o['meta'])) $this->meta = $o['meta'];
if (isset($o['hash'])) $this->hash = $o['hash'];
if (isset($o['halg'])) $this->halg = $o['halg'];
if (isset($o['expiry'])) $this->expiry = JsonConverters::from('DateTime', $o['expiry']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ref)) $o['ref'] = $this->ref;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->type)) $o['type'] = JsonConverters::to('LicenseType', $this->type);
if (isset($this->meta)) $o['meta'] = $this->meta;
if (isset($this->hash)) $o['hash'] = $this->hash;
if (isset($this->halg)) $o['halg'] = $this->halg;
if (isset($this->expiry)) $o['expiry'] = JsonConverters::to('DateTime', $this->expiry);
return empty($o) ? new class(){} : $o;
}
}
class RegenerateLicenseKeyResponse implements JsonSerializable
{
public function __construct(
/** @var LicenseKey|null */
public ?LicenseKey $licenseKey=null,
/** @var string|null */
public ?string $licenseKeyText=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['licenseKey'])) $this->licenseKey = JsonConverters::from('LicenseKey', $o['licenseKey']);
if (isset($o['licenseKeyText'])) $this->licenseKeyText = $o['licenseKeyText'];
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->licenseKey)) $o['licenseKey'] = JsonConverters::to('LicenseKey', $this->licenseKey);
if (isset($this->licenseKeyText)) $o['licenseKeyText'] = $this->licenseKeyText;
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
class RegenerateLicenseKey implements IPost, JsonSerializable
{
public function __construct(
// @Validate(Validator="NotEmpty")
/** @var string */
public string $licenseKey='',
// @Validate(Validator="NotEmpty")
/** @var string */
public string $halg=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['licenseKey'])) $this->licenseKey = $o['licenseKey'];
if (isset($o['halg'])) $this->halg = $o['halg'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->licenseKey)) $o['licenseKey'] = $this->licenseKey;
if (isset($this->halg)) $o['halg'] = $this->halg;
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 /RegenerateLicenseKey HTTP/1.1
Host: account.servicestack.net
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
licenseKey: String,
halg: String
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { licenseKey: { ref: String, name: String, type: Free, meta: 0, hash: String, halg: String, expiry: 0001-01-01 }, licenseKeyText: String, responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } }