All Verbs | /buy/{Id} | ||
---|---|---|---|
GET | /Buy/{Id} | ||
All Verbs | /buy/{Id}/{Quantity} | ||
GET | /Buy |
<?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 SkuType : string
{
case Product = 'Product';
case PerDev = 'PerDev';
case PerCore = 'PerCore';
case Site = 'Site';
case Support = 'Support';
case Training = 'Training';
case Register = 'Register';
case Payment = 'Payment';
}
// @Flags()
enum LicenseFeature : int
{
case None = 0;
case Free = 0;
case Premium = 1;
case Text = 2;
case Client = 4;
case Common = 8;
case Redis = 16;
case RedisSku = 18;
case OrmLite = 32;
case OrmLiteSku = 34;
case ServiceStack = 64;
case Server = 128;
case Razor = 256;
case Admin = 512;
case Aws = 1024;
case AwsSku = 1026;
case All = 2047;
}
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 Sku implements JsonSerializable
{
public function __construct(
/** @var int */
public int $id=0,
/** @var int */
public int $productId=0,
/** @var SkuType|null */
public ?SkuType $type=null,
/** @var LicenseFeature|null */
public ?LicenseFeature $feature=null,
/** @var string|null */
public ?string $code=null,
/** @var string|null */
public ?string $name=null,
/** @var string|null */
public ?string $notes=null,
// @Ignore()
/** @var int|null */
public ?int $minQty=null,
/** @var int|null */
public ?int $maxQty=null,
/** @var int */
public int $price=0,
/** @var string|null */
public ?string $plan=null,
/** @var int */
public int $discountOff=0,
/** @var string|null */
public ?string $discountLabelOff=null,
/** @var int */
public int $actualPrice=0,
/** @var bool|null */
public ?bool $isPlan=null,
/** @var bool|null */
public ?bool $isRenewal=null,
/** @var int|null */
public ?int $subscriptionDurationDays=null,
/** @var int|null */
public ?int $expiryDurationDays=null,
/** @var int|null */
public ?int $trialPeriodDays=null,
/** @var int */
public int $supportQty=0,
/** @var int|null */
public ?int $coresQty=null,
/** @var DateTime */
public DateTime $createdDate=new DateTime(),
/** @var DateTime */
public DateTime $modifiedDate=new DateTime(),
/** @var LicenseType|null */
public ?LicenseType $licenseType=null,
/** @var bool|null */
public ?bool $active=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['productId'])) $this->productId = $o['productId'];
if (isset($o['type'])) $this->type = JsonConverters::from('SkuType', $o['type']);
if (isset($o['feature'])) $this->feature = JsonConverters::from('LicenseFeature', $o['feature']);
if (isset($o['code'])) $this->code = $o['code'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['notes'])) $this->notes = $o['notes'];
if (isset($o['minQty'])) $this->minQty = $o['minQty'];
if (isset($o['maxQty'])) $this->maxQty = $o['maxQty'];
if (isset($o['price'])) $this->price = $o['price'];
if (isset($o['plan'])) $this->plan = $o['plan'];
if (isset($o['discountOff'])) $this->discountOff = $o['discountOff'];
if (isset($o['discountLabelOff'])) $this->discountLabelOff = $o['discountLabelOff'];
if (isset($o['actualPrice'])) $this->actualPrice = $o['actualPrice'];
if (isset($o['isPlan'])) $this->isPlan = $o['isPlan'];
if (isset($o['isRenewal'])) $this->isRenewal = $o['isRenewal'];
if (isset($o['subscriptionDurationDays'])) $this->subscriptionDurationDays = $o['subscriptionDurationDays'];
if (isset($o['expiryDurationDays'])) $this->expiryDurationDays = $o['expiryDurationDays'];
if (isset($o['trialPeriodDays'])) $this->trialPeriodDays = $o['trialPeriodDays'];
if (isset($o['supportQty'])) $this->supportQty = $o['supportQty'];
if (isset($o['coresQty'])) $this->coresQty = $o['coresQty'];
if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
if (isset($o['modifiedDate'])) $this->modifiedDate = JsonConverters::from('DateTime', $o['modifiedDate']);
if (isset($o['licenseType'])) $this->licenseType = JsonConverters::from('LicenseType', $o['licenseType']);
if (isset($o['active'])) $this->active = $o['active'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->productId)) $o['productId'] = $this->productId;
if (isset($this->type)) $o['type'] = JsonConverters::to('SkuType', $this->type);
if (isset($this->feature)) $o['feature'] = JsonConverters::to('LicenseFeature', $this->feature);
if (isset($this->code)) $o['code'] = $this->code;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->notes)) $o['notes'] = $this->notes;
if (isset($this->minQty)) $o['minQty'] = $this->minQty;
if (isset($this->maxQty)) $o['maxQty'] = $this->maxQty;
if (isset($this->price)) $o['price'] = $this->price;
if (isset($this->plan)) $o['plan'] = $this->plan;
if (isset($this->discountOff)) $o['discountOff'] = $this->discountOff;
if (isset($this->discountLabelOff)) $o['discountLabelOff'] = $this->discountLabelOff;
if (isset($this->actualPrice)) $o['actualPrice'] = $this->actualPrice;
if (isset($this->isPlan)) $o['isPlan'] = $this->isPlan;
if (isset($this->isRenewal)) $o['isRenewal'] = $this->isRenewal;
if (isset($this->subscriptionDurationDays)) $o['subscriptionDurationDays'] = $this->subscriptionDurationDays;
if (isset($this->expiryDurationDays)) $o['expiryDurationDays'] = $this->expiryDurationDays;
if (isset($this->trialPeriodDays)) $o['trialPeriodDays'] = $this->trialPeriodDays;
if (isset($this->supportQty)) $o['supportQty'] = $this->supportQty;
if (isset($this->coresQty)) $o['coresQty'] = $this->coresQty;
if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
if (isset($this->modifiedDate)) $o['modifiedDate'] = JsonConverters::to('DateTime', $this->modifiedDate);
if (isset($this->licenseType)) $o['licenseType'] = JsonConverters::to('LicenseType', $this->licenseType);
if (isset($this->active)) $o['active'] = $this->active;
return empty($o) ? new class(){} : $o;
}
}
class QuoteResponse implements JsonSerializable
{
public function __construct(
/** @var int */
public int $skuId=0,
/** @var string|null */
public ?string $code=null,
/** @var int|null */
public ?int $customerId=null,
/** @var bool|null */
public ?bool $modifyingExistingSubscription=null,
/** @var bool|null */
public ?bool $changingSubscriptions=null,
/** @var bool|null */
public ?bool $switchingLicensingModels=null,
/** @var bool|null */
public ?bool $replacesExistingQuantity=null,
/** @var int|null */
public ?int $existingSubscriptionQuantity=null,
/** @var int|null */
public ?int $newSubscriptionQuantity=null,
/** @var string|null */
public ?string $unusedAmount=null,
/** @var bool|null */
public ?bool $manualProrating=null,
/** @var int */
public int $unusedDays=0,
/** @var int */
public int $quantity=0,
/** @var int */
public int $minQuantity=0,
/** @var int|null */
public ?int $maxQuantity=null,
/** @var string|null */
public ?string $subtotal=null,
/** @var string|null */
public ?string $discountDescription=null,
/** @var string|null */
public ?string $discountReceived=null,
/** @var string|null */
public ?string $discount=null,
/** @var string|null */
public ?string $total=null,
/** @var string|null */
public ?string $expiryDate=null,
/** @var string|null */
public ?string $renewalDate=null,
/** @var bool|null */
public ?bool $isReferrer=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['skuId'])) $this->skuId = $o['skuId'];
if (isset($o['code'])) $this->code = $o['code'];
if (isset($o['customerId'])) $this->customerId = $o['customerId'];
if (isset($o['modifyingExistingSubscription'])) $this->modifyingExistingSubscription = $o['modifyingExistingSubscription'];
if (isset($o['changingSubscriptions'])) $this->changingSubscriptions = $o['changingSubscriptions'];
if (isset($o['switchingLicensingModels'])) $this->switchingLicensingModels = $o['switchingLicensingModels'];
if (isset($o['replacesExistingQuantity'])) $this->replacesExistingQuantity = $o['replacesExistingQuantity'];
if (isset($o['existingSubscriptionQuantity'])) $this->existingSubscriptionQuantity = $o['existingSubscriptionQuantity'];
if (isset($o['newSubscriptionQuantity'])) $this->newSubscriptionQuantity = $o['newSubscriptionQuantity'];
if (isset($o['unusedAmount'])) $this->unusedAmount = $o['unusedAmount'];
if (isset($o['manualProrating'])) $this->manualProrating = $o['manualProrating'];
if (isset($o['unusedDays'])) $this->unusedDays = $o['unusedDays'];
if (isset($o['quantity'])) $this->quantity = $o['quantity'];
if (isset($o['minQuantity'])) $this->minQuantity = $o['minQuantity'];
if (isset($o['maxQuantity'])) $this->maxQuantity = $o['maxQuantity'];
if (isset($o['subtotal'])) $this->subtotal = $o['subtotal'];
if (isset($o['discountDescription'])) $this->discountDescription = $o['discountDescription'];
if (isset($o['discountReceived'])) $this->discountReceived = $o['discountReceived'];
if (isset($o['discount'])) $this->discount = $o['discount'];
if (isset($o['total'])) $this->total = $o['total'];
if (isset($o['expiryDate'])) $this->expiryDate = $o['expiryDate'];
if (isset($o['renewalDate'])) $this->renewalDate = $o['renewalDate'];
if (isset($o['isReferrer'])) $this->isReferrer = $o['isReferrer'];
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->skuId)) $o['skuId'] = $this->skuId;
if (isset($this->code)) $o['code'] = $this->code;
if (isset($this->customerId)) $o['customerId'] = $this->customerId;
if (isset($this->modifyingExistingSubscription)) $o['modifyingExistingSubscription'] = $this->modifyingExistingSubscription;
if (isset($this->changingSubscriptions)) $o['changingSubscriptions'] = $this->changingSubscriptions;
if (isset($this->switchingLicensingModels)) $o['switchingLicensingModels'] = $this->switchingLicensingModels;
if (isset($this->replacesExistingQuantity)) $o['replacesExistingQuantity'] = $this->replacesExistingQuantity;
if (isset($this->existingSubscriptionQuantity)) $o['existingSubscriptionQuantity'] = $this->existingSubscriptionQuantity;
if (isset($this->newSubscriptionQuantity)) $o['newSubscriptionQuantity'] = $this->newSubscriptionQuantity;
if (isset($this->unusedAmount)) $o['unusedAmount'] = $this->unusedAmount;
if (isset($this->manualProrating)) $o['manualProrating'] = $this->manualProrating;
if (isset($this->unusedDays)) $o['unusedDays'] = $this->unusedDays;
if (isset($this->quantity)) $o['quantity'] = $this->quantity;
if (isset($this->minQuantity)) $o['minQuantity'] = $this->minQuantity;
if (isset($this->maxQuantity)) $o['maxQuantity'] = $this->maxQuantity;
if (isset($this->subtotal)) $o['subtotal'] = $this->subtotal;
if (isset($this->discountDescription)) $o['discountDescription'] = $this->discountDescription;
if (isset($this->discountReceived)) $o['discountReceived'] = $this->discountReceived;
if (isset($this->discount)) $o['discount'] = $this->discount;
if (isset($this->total)) $o['total'] = $this->total;
if (isset($this->expiryDate)) $o['expiryDate'] = $this->expiryDate;
if (isset($this->renewalDate)) $o['renewalDate'] = $this->renewalDate;
if (isset($this->isReferrer)) $o['isReferrer'] = $this->isReferrer;
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
class BuyResponse implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $coupon=null,
/** @var string|null */
public ?string $renewalRef=null,
/** @var string|null */
public ?string $upgradeRef=null,
/** @var Sku|null */
public ?Sku $sku=null,
/** @var QuoteResponse|null */
public ?QuoteResponse $quote=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $responseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['coupon'])) $this->coupon = $o['coupon'];
if (isset($o['renewalRef'])) $this->renewalRef = $o['renewalRef'];
if (isset($o['upgradeRef'])) $this->upgradeRef = $o['upgradeRef'];
if (isset($o['sku'])) $this->sku = JsonConverters::from('Sku', $o['sku']);
if (isset($o['quote'])) $this->quote = JsonConverters::from('QuoteResponse', $o['quote']);
if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->coupon)) $o['coupon'] = $this->coupon;
if (isset($this->renewalRef)) $o['renewalRef'] = $this->renewalRef;
if (isset($this->upgradeRef)) $o['upgradeRef'] = $this->upgradeRef;
if (isset($this->sku)) $o['sku'] = JsonConverters::to('Sku', $this->sku);
if (isset($this->quote)) $o['quote'] = JsonConverters::to('QuoteResponse', $this->quote);
if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
return empty($o) ? new class(){} : $o;
}
}
class Buy implements IGet, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var string|null */
public ?string $coupon=null,
/** @var int|null */
public ?int $quantity=null,
/** @var string|null */
public ?string $renewalRef=null,
/** @var string|null */
public ?string $upgradeRef=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['coupon'])) $this->coupon = $o['coupon'];
if (isset($o['quantity'])) $this->quantity = $o['quantity'];
if (isset($o['renewalRef'])) $this->renewalRef = $o['renewalRef'];
if (isset($o['upgradeRef'])) $this->upgradeRef = $o['upgradeRef'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->coupon)) $o['coupon'] = $this->coupon;
if (isset($this->quantity)) $o['quantity'] = $this->quantity;
if (isset($this->renewalRef)) $o['renewalRef'] = $this->renewalRef;
if (isset($this->upgradeRef)) $o['upgradeRef'] = $this->upgradeRef;
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 /buy/{Id} HTTP/1.1
Host: account.servicestack.net
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"id":"String","coupon":"String","quantity":0,"renewalRef":"String","upgradeRef":"String"}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"coupon":"String","renewalRef":"String","upgradeRef":"String","sku":{"id":0,"productId":0,"type":"Product","feature":0,"code":"String","name":"String","notes":"String","maxQty":0,"price":0,"plan":"String","discountOff":0,"discountLabelOff":"String","actualPrice":0,"isPlan":false,"isRenewal":false,"subscriptionDurationDays":0,"expiryDurationDays":0,"trialPeriodDays":0,"supportQty":0,"coresQty":0,"createdDate":"\/Date(-62135596800000-0000)\/","modifiedDate":"\/Date(-62135596800000-0000)\/","licenseType":"Free","active":false},"quote":{"skuId":0,"code":"String","customerId":0,"modifyingExistingSubscription":false,"changingSubscriptions":false,"switchingLicensingModels":false,"replacesExistingQuantity":false,"existingSubscriptionQuantity":0,"newSubscriptionQuantity":0,"unusedAmount":"String","manualProrating":false,"unusedDays":0,"quantity":0,"minQuantity":0,"maxQuantity":0,"subtotal":"String","discountDescription":"String","discountReceived":"String","discount":"String","total":"String","expiryDate":"String","renewalDate":"String","isReferrer":false,"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}