ServiceStack Home (Live)

<back to all web services

Subscriptions

Requires Authentication
The following routes are available for this service:
All Verbs/account/subscription
GET/Subscriptions
<?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 Subscriptions implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $section=null,
        /** @var bool|null */
        public ?bool $success=null,
        /** @var bool|null */
        public ?bool $activated=null,
        /** @var int|null */
        public ?int $purchasedOrderId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['section'])) $this->section = $o['section'];
        if (isset($o['success'])) $this->success = $o['success'];
        if (isset($o['activated'])) $this->activated = $o['activated'];
        if (isset($o['purchasedOrderId'])) $this->purchasedOrderId = $o['purchasedOrderId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->section)) $o['section'] = $this->section;
        if (isset($this->success)) $o['success'] = $this->success;
        if (isset($this->activated)) $o['activated'] = $this->activated;
        if (isset($this->purchasedOrderId)) $o['purchasedOrderId'] = $this->purchasedOrderId;
        return empty($o) ? new class(){} : $o;
    }
}

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 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 Subscription implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var int */
        public int $customerId=0,
        /** @var string|null */
        public ?string $email=null,
        /** @var int */
        public int $skuId=0,
        /** @var string|null */
        public ?string $skuName=null,
        /** @var SkuType|null */
        public ?SkuType $skuType=null,
        /** @var string|null */
        public ?string $code=null,
        /** @var int */
        public int $quantity=0,
        /** @var int */
        public int $supportQuantity=0,
        /** @var int */
        public int $total=0,
        /** @var bool|null */
        public ?bool $isPlan=null,
        /** @var bool|null */
        public ?bool $isRenewal=null,
        /** @var int */
        public int $subscriptionDurationDays=0,
        /** @var DateTime|null */
        public ?DateTime $renewalDate=null,
        /** @var string|null */
        public ?string $licenseRef=null,
        /** @var string|null */
        public ?string $licenseName=null,
        /** @var string|null */
        public ?string $licenseAddress=null,
        /** @var LicenseType|null */
        public ?LicenseType $licenseType=null,
        /** @var DateTime */
        public DateTime $expiryDate=new DateTime(),
        /** @var LicenseKey|null */
        public ?LicenseKey $licenseKey=null,
        /** @var string|null */
        public ?string $licenseKeyText=null,
        /** @var DateTime */
        public DateTime $createdDate=new DateTime(),
        /** @var DateTime */
        public DateTime $modifiedDate=new DateTime(),
        /** @var DateTime|null */
        public ?DateTime $cancelledDate=null,
        /** @var string|null */
        public ?string $stripeSubscriptionId=null,
        /** @var int|null */
        public ?int $emailId=null,
        /** @var int|null */
        public ?int $emailRenewalId=null,
        /** @var int|null */
        public ?int $emailExpiredId=null,
        /** @var int|null */
        public ?int $renewalSubscriptionId=null,
        /** @var string|null */
        public ?string $externalRef=null,
        /** @var string|null */
        public ?string $notes=null,
        /** @var string|null */
        public ?string $error=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['customerId'])) $this->customerId = $o['customerId'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['skuId'])) $this->skuId = $o['skuId'];
        if (isset($o['skuName'])) $this->skuName = $o['skuName'];
        if (isset($o['skuType'])) $this->skuType = JsonConverters::from('SkuType', $o['skuType']);
        if (isset($o['code'])) $this->code = $o['code'];
        if (isset($o['quantity'])) $this->quantity = $o['quantity'];
        if (isset($o['supportQuantity'])) $this->supportQuantity = $o['supportQuantity'];
        if (isset($o['total'])) $this->total = $o['total'];
        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['renewalDate'])) $this->renewalDate = JsonConverters::from('DateTime', $o['renewalDate']);
        if (isset($o['licenseRef'])) $this->licenseRef = $o['licenseRef'];
        if (isset($o['licenseName'])) $this->licenseName = $o['licenseName'];
        if (isset($o['licenseAddress'])) $this->licenseAddress = $o['licenseAddress'];
        if (isset($o['licenseType'])) $this->licenseType = JsonConverters::from('LicenseType', $o['licenseType']);
        if (isset($o['expiryDate'])) $this->expiryDate = JsonConverters::from('DateTime', $o['expiryDate']);
        if (isset($o['licenseKey'])) $this->licenseKey = JsonConverters::from('LicenseKey', $o['licenseKey']);
        if (isset($o['licenseKeyText'])) $this->licenseKeyText = $o['licenseKeyText'];
        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['cancelledDate'])) $this->cancelledDate = JsonConverters::from('DateTime', $o['cancelledDate']);
        if (isset($o['stripeSubscriptionId'])) $this->stripeSubscriptionId = $o['stripeSubscriptionId'];
        if (isset($o['emailId'])) $this->emailId = $o['emailId'];
        if (isset($o['emailRenewalId'])) $this->emailRenewalId = $o['emailRenewalId'];
        if (isset($o['emailExpiredId'])) $this->emailExpiredId = $o['emailExpiredId'];
        if (isset($o['renewalSubscriptionId'])) $this->renewalSubscriptionId = $o['renewalSubscriptionId'];
        if (isset($o['externalRef'])) $this->externalRef = $o['externalRef'];
        if (isset($o['notes'])) $this->notes = $o['notes'];
        if (isset($o['error'])) $this->error = $o['error'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->customerId)) $o['customerId'] = $this->customerId;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->skuId)) $o['skuId'] = $this->skuId;
        if (isset($this->skuName)) $o['skuName'] = $this->skuName;
        if (isset($this->skuType)) $o['skuType'] = JsonConverters::to('SkuType', $this->skuType);
        if (isset($this->code)) $o['code'] = $this->code;
        if (isset($this->quantity)) $o['quantity'] = $this->quantity;
        if (isset($this->supportQuantity)) $o['supportQuantity'] = $this->supportQuantity;
        if (isset($this->total)) $o['total'] = $this->total;
        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->renewalDate)) $o['renewalDate'] = JsonConverters::to('DateTime', $this->renewalDate);
        if (isset($this->licenseRef)) $o['licenseRef'] = $this->licenseRef;
        if (isset($this->licenseName)) $o['licenseName'] = $this->licenseName;
        if (isset($this->licenseAddress)) $o['licenseAddress'] = $this->licenseAddress;
        if (isset($this->licenseType)) $o['licenseType'] = JsonConverters::to('LicenseType', $this->licenseType);
        if (isset($this->expiryDate)) $o['expiryDate'] = JsonConverters::to('DateTime', $this->expiryDate);
        if (isset($this->licenseKey)) $o['licenseKey'] = JsonConverters::to('LicenseKey', $this->licenseKey);
        if (isset($this->licenseKeyText)) $o['licenseKeyText'] = $this->licenseKeyText;
        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->cancelledDate)) $o['cancelledDate'] = JsonConverters::to('DateTime', $this->cancelledDate);
        if (isset($this->stripeSubscriptionId)) $o['stripeSubscriptionId'] = $this->stripeSubscriptionId;
        if (isset($this->emailId)) $o['emailId'] = $this->emailId;
        if (isset($this->emailRenewalId)) $o['emailRenewalId'] = $this->emailRenewalId;
        if (isset($this->emailExpiredId)) $o['emailExpiredId'] = $this->emailExpiredId;
        if (isset($this->renewalSubscriptionId)) $o['renewalSubscriptionId'] = $this->renewalSubscriptionId;
        if (isset($this->externalRef)) $o['externalRef'] = $this->externalRef;
        if (isset($this->notes)) $o['notes'] = $this->notes;
        if (isset($this->error)) $o['error'] = $this->error;
        return empty($o) ? new class(){} : $o;
    }
}

class OrderDetail implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var int */
        public int $orderId=0,
        /** @var int */
        public int $skuId=0,
        /** @var SkuType|null */
        public ?SkuType $skuType=null,
        /** @var int */
        public int $price=0,
        /** @var string|null */
        public ?string $description=null,
        /** @var int */
        public int $quantity=0,
        /** @var int */
        public int $total=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['orderId'])) $this->orderId = $o['orderId'];
        if (isset($o['skuId'])) $this->skuId = $o['skuId'];
        if (isset($o['skuType'])) $this->skuType = JsonConverters::from('SkuType', $o['skuType']);
        if (isset($o['price'])) $this->price = $o['price'];
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['quantity'])) $this->quantity = $o['quantity'];
        if (isset($o['total'])) $this->total = $o['total'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->orderId)) $o['orderId'] = $this->orderId;
        if (isset($this->skuId)) $o['skuId'] = $this->skuId;
        if (isset($this->skuType)) $o['skuType'] = JsonConverters::to('SkuType', $this->skuType);
        if (isset($this->price)) $o['price'] = $this->price;
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->quantity)) $o['quantity'] = $this->quantity;
        if (isset($this->total)) $o['total'] = $this->total;
        return empty($o) ? new class(){} : $o;
    }
}

class OrderAnalyticData implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $productName=null,
        /** @var int */
        public int $subTotal=0,
        /** @var string|null */
        public ?string $couponId=null,
        /** @var int */
        public int $discount=0,
        /** @var int */
        public int $tax=0,
        /** @var int */
        public int $total=0,
        /** @var bool|null */
        public ?bool $paid=null,
        /** @var DateTime */
        public DateTime $createdDate=new DateTime(),
        /** @var DateTime */
        public DateTime $modifiedDate=new DateTime(),
        /** @var string|null */
        public ?string $modifiedBy=null,
        /** @var DateTime|null */
        public ?DateTime $cancelledDate=null,
        /** @var string|null */
        public ?string $cancelledReason=null,
        /** @var array<OrderDetail>|null */
        public ?array $orderDetails=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['productName'])) $this->productName = $o['productName'];
        if (isset($o['subTotal'])) $this->subTotal = $o['subTotal'];
        if (isset($o['couponId'])) $this->couponId = $o['couponId'];
        if (isset($o['discount'])) $this->discount = $o['discount'];
        if (isset($o['tax'])) $this->tax = $o['tax'];
        if (isset($o['total'])) $this->total = $o['total'];
        if (isset($o['paid'])) $this->paid = $o['paid'];
        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['modifiedBy'])) $this->modifiedBy = $o['modifiedBy'];
        if (isset($o['cancelledDate'])) $this->cancelledDate = JsonConverters::from('DateTime', $o['cancelledDate']);
        if (isset($o['cancelledReason'])) $this->cancelledReason = $o['cancelledReason'];
        if (isset($o['orderDetails'])) $this->orderDetails = JsonConverters::fromArray('OrderDetail', $o['orderDetails']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->productName)) $o['productName'] = $this->productName;
        if (isset($this->subTotal)) $o['subTotal'] = $this->subTotal;
        if (isset($this->couponId)) $o['couponId'] = $this->couponId;
        if (isset($this->discount)) $o['discount'] = $this->discount;
        if (isset($this->tax)) $o['tax'] = $this->tax;
        if (isset($this->total)) $o['total'] = $this->total;
        if (isset($this->paid)) $o['paid'] = $this->paid;
        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->modifiedBy)) $o['modifiedBy'] = $this->modifiedBy;
        if (isset($this->cancelledDate)) $o['cancelledDate'] = JsonConverters::to('DateTime', $this->cancelledDate);
        if (isset($this->cancelledReason)) $o['cancelledReason'] = $this->cancelledReason;
        if (isset($this->orderDetails)) $o['orderDetails'] = JsonConverters::toArray('OrderDetail', $this->orderDetails);
        return empty($o) ? new class(){} : $o;
    }
}

class SubscriptionsResponse implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $section=null,
        /** @var int */
        public int $supportQuantity=0,
        /** @var Sku|null */
        public ?Sku $activeSku=null,
        /** @var Subscription|null */
        public ?Subscription $activeSubscription=null,
        /** @var array<Subscription>|null */
        public ?array $inActiveSubscriptions=null,
        /** @var OrderAnalyticData|null */
        public ?OrderAnalyticData $purchasedOrder=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['section'])) $this->section = $o['section'];
        if (isset($o['supportQuantity'])) $this->supportQuantity = $o['supportQuantity'];
        if (isset($o['activeSku'])) $this->activeSku = JsonConverters::from('Sku', $o['activeSku']);
        if (isset($o['activeSubscription'])) $this->activeSubscription = JsonConverters::from('Subscription', $o['activeSubscription']);
        if (isset($o['inActiveSubscriptions'])) $this->inActiveSubscriptions = JsonConverters::fromArray('Subscription', $o['inActiveSubscriptions']);
        if (isset($o['purchasedOrder'])) $this->purchasedOrder = JsonConverters::from('OrderAnalyticData', $o['purchasedOrder']);
        if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->section)) $o['section'] = $this->section;
        if (isset($this->supportQuantity)) $o['supportQuantity'] = $this->supportQuantity;
        if (isset($this->activeSku)) $o['activeSku'] = JsonConverters::to('Sku', $this->activeSku);
        if (isset($this->activeSubscription)) $o['activeSubscription'] = JsonConverters::to('Subscription', $this->activeSubscription);
        if (isset($this->inActiveSubscriptions)) $o['inActiveSubscriptions'] = JsonConverters::toArray('Subscription', $this->inActiveSubscriptions);
        if (isset($this->purchasedOrder)) $o['purchasedOrder'] = JsonConverters::to('OrderAnalyticData', $this->purchasedOrder);
        if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

PHP Subscriptions DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /account/subscription HTTP/1.1 
Host: account.servicestack.net 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"section":"String","success":false,"activated":false,"purchasedOrderId":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"section":"String","supportQuantity":0,"activeSku":{"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},"activeSubscription":{"id":0,"customerId":0,"email":"String","skuId":0,"skuName":"String","skuType":"Product","code":"String","quantity":0,"supportQuantity":0,"total":0,"isPlan":false,"isRenewal":false,"subscriptionDurationDays":0,"renewalDate":"\/Date(-62135596800000-0000)\/","licenseRef":"String","licenseName":"String","licenseAddress":"String","licenseType":"Free","expiryDate":"\/Date(-62135596800000-0000)\/","licenseKey":{"ref":"String","name":"String","type":"Free","meta":0,"hash":"String","halg":"String","expiry":"\/Date(-62135596800000-0000)\/"},"licenseKeyText":"String","createdDate":"\/Date(-62135596800000-0000)\/","modifiedDate":"\/Date(-62135596800000-0000)\/","cancelledDate":"\/Date(-62135596800000-0000)\/","stripeSubscriptionId":"String","emailId":0,"emailRenewalId":0,"emailExpiredId":0,"renewalSubscriptionId":0,"externalRef":"String","notes":"String","error":"String"},"inActiveSubscriptions":[{"id":0,"customerId":0,"email":"String","skuId":0,"skuName":"String","skuType":"Product","code":"String","quantity":0,"supportQuantity":0,"total":0,"isPlan":false,"isRenewal":false,"subscriptionDurationDays":0,"renewalDate":"\/Date(-62135596800000-0000)\/","licenseRef":"String","licenseName":"String","licenseAddress":"String","licenseType":"Free","expiryDate":"\/Date(-62135596800000-0000)\/","licenseKey":{"ref":"String","name":"String","type":"Free","meta":0,"hash":"String","halg":"String","expiry":"\/Date(-62135596800000-0000)\/"},"licenseKeyText":"String","createdDate":"\/Date(-62135596800000-0000)\/","modifiedDate":"\/Date(-62135596800000-0000)\/","cancelledDate":"\/Date(-62135596800000-0000)\/","stripeSubscriptionId":"String","emailId":0,"emailRenewalId":0,"emailExpiredId":0,"renewalSubscriptionId":0,"externalRef":"String","notes":"String","error":"String"}],"purchasedOrder":{"productName":"String","subTotal":0,"couponId":"String","discount":0,"tax":0,"total":0,"paid":false,"createdDate":"\/Date(-62135596800000-0000)\/","modifiedDate":"\/Date(-62135596800000-0000)\/","modifiedBy":"String","cancelledDate":"\/Date(-62135596800000-0000)\/","cancelledReason":"String","orderDetails":[{"id":0,"orderId":0,"skuId":0,"skuType":"Product","price":0,"description":"String","quantity":0,"total":0}]},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}