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 .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<RegenerateLicenseKey xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceInterface">
<Halg>String</Halg>
<LicenseKey>String</LicenseKey>
</RegenerateLicenseKey>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <RegenerateLicenseKeyResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceInterface"> <LicenseKey xmlns:d2p1="http://schemas.datacontract.org/2004/07/ServiceStack"> <d2p1:Expiry>0001-01-01T00:00:00</d2p1:Expiry> <d2p1:Halg>String</d2p1:Halg> <d2p1:Hash>String</d2p1:Hash> <d2p1:Meta>0</d2p1:Meta> <d2p1:Name>String</d2p1:Name> <d2p1:Ref>String</d2p1:Ref> <d2p1:Type>Free</d2p1:Type> </LicenseKey> <LicenseKeyText>String</LicenseKeyText> <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types"> <d2p1:ErrorCode>String</d2p1:ErrorCode> <d2p1:Message>String</d2p1:Message> <d2p1:StackTrace>String</d2p1:StackTrace> <d2p1:Errors> <d2p1:ResponseError> <d2p1:ErrorCode>String</d2p1:ErrorCode> <d2p1:FieldName>String</d2p1:FieldName> <d2p1:Message>String</d2p1:Message> <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d5p1:KeyValueOfstringstring> <d5p1:Key>String</d5p1:Key> <d5p1:Value>String</d5p1:Value> </d5p1:KeyValueOfstringstring> </d2p1:Meta> </d2p1:ResponseError> </d2p1:Errors> <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d3p1:KeyValueOfstringstring> <d3p1:Key>String</d3p1:Key> <d3p1:Value>String</d3p1:Value> </d3p1:KeyValueOfstringstring> </d2p1:Meta> </ResponseStatus> </RegenerateLicenseKeyResponse>