ServiceStack Home (Live)

<back to all web services

CreateCustomer

Admin
Requires Authentication
Required role:Admin
The following routes are available for this service:
POST/CreateCustomer
<?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';
}

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 Order implements IAddress, JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var int */
        public int $customerId=0,
        /** @var string|null */
        public ?string $productName=null,
        /** @var string|null */
        public ?string $firstName=null,
        /** @var string|null */
        public ?string $lastName=null,
        /** @var string|null */
        public ?string $email=null,
        /** @var string|null */
        public ?string $company=null,
        /** @var string|null */
        public ?string $phoneNumber=null,
        /** @var string|null */
        public ?string $addressLine1=null,
        /** @var string|null */
        public ?string $addressLine2=null,
        /** @var string|null */
        public ?string $addressCity=null,
        /** @var string|null */
        public ?string $addressZip=null,
        /** @var string|null */
        public ?string $addressState=null,
        /** @var string|null */
        public ?string $addressCountry=null,
        /** @var bool|null */
        public ?bool $agreeTerms=null,
        /** @var string|null */
        public ?string $notes=null,
        /** @var string|null */
        public ?string $last4=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 int */
        public int $itemQuantity=0,
        /** @var int|null */
        public ?int $authorizedQuantity=null,
        /** @var int|null */
        public ?int $subscriptionId=null,
        /** @var string|null */
        public ?string $licenseRef=null,
        /** @var int|null */
        public ?int $paymentId=null,
        /** @var int|null */
        public ?int $emailId=null,
        /** @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 string|null */
        public ?string $ipAddress=null,
        /** @var array<OrderDetail>|null */
        public ?array $orderDetails=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['productName'])) $this->productName = $o['productName'];
        if (isset($o['firstName'])) $this->firstName = $o['firstName'];
        if (isset($o['lastName'])) $this->lastName = $o['lastName'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['company'])) $this->company = $o['company'];
        if (isset($o['phoneNumber'])) $this->phoneNumber = $o['phoneNumber'];
        if (isset($o['addressLine1'])) $this->addressLine1 = $o['addressLine1'];
        if (isset($o['addressLine2'])) $this->addressLine2 = $o['addressLine2'];
        if (isset($o['addressCity'])) $this->addressCity = $o['addressCity'];
        if (isset($o['addressZip'])) $this->addressZip = $o['addressZip'];
        if (isset($o['addressState'])) $this->addressState = $o['addressState'];
        if (isset($o['addressCountry'])) $this->addressCountry = $o['addressCountry'];
        if (isset($o['agreeTerms'])) $this->agreeTerms = $o['agreeTerms'];
        if (isset($o['notes'])) $this->notes = $o['notes'];
        if (isset($o['last4'])) $this->last4 = $o['last4'];
        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['itemQuantity'])) $this->itemQuantity = $o['itemQuantity'];
        if (isset($o['authorizedQuantity'])) $this->authorizedQuantity = $o['authorizedQuantity'];
        if (isset($o['subscriptionId'])) $this->subscriptionId = $o['subscriptionId'];
        if (isset($o['licenseRef'])) $this->licenseRef = $o['licenseRef'];
        if (isset($o['paymentId'])) $this->paymentId = $o['paymentId'];
        if (isset($o['emailId'])) $this->emailId = $o['emailId'];
        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['ipAddress'])) $this->ipAddress = $o['ipAddress'];
        if (isset($o['orderDetails'])) $this->orderDetails = JsonConverters::fromArray('OrderDetail', $o['orderDetails']);
    }
    
    /** @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->productName)) $o['productName'] = $this->productName;
        if (isset($this->firstName)) $o['firstName'] = $this->firstName;
        if (isset($this->lastName)) $o['lastName'] = $this->lastName;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->company)) $o['company'] = $this->company;
        if (isset($this->phoneNumber)) $o['phoneNumber'] = $this->phoneNumber;
        if (isset($this->addressLine1)) $o['addressLine1'] = $this->addressLine1;
        if (isset($this->addressLine2)) $o['addressLine2'] = $this->addressLine2;
        if (isset($this->addressCity)) $o['addressCity'] = $this->addressCity;
        if (isset($this->addressZip)) $o['addressZip'] = $this->addressZip;
        if (isset($this->addressState)) $o['addressState'] = $this->addressState;
        if (isset($this->addressCountry)) $o['addressCountry'] = $this->addressCountry;
        if (isset($this->agreeTerms)) $o['agreeTerms'] = $this->agreeTerms;
        if (isset($this->notes)) $o['notes'] = $this->notes;
        if (isset($this->last4)) $o['last4'] = $this->last4;
        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->itemQuantity)) $o['itemQuantity'] = $this->itemQuantity;
        if (isset($this->authorizedQuantity)) $o['authorizedQuantity'] = $this->authorizedQuantity;
        if (isset($this->subscriptionId)) $o['subscriptionId'] = $this->subscriptionId;
        if (isset($this->licenseRef)) $o['licenseRef'] = $this->licenseRef;
        if (isset($this->paymentId)) $o['paymentId'] = $this->paymentId;
        if (isset($this->emailId)) $o['emailId'] = $this->emailId;
        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->ipAddress)) $o['ipAddress'] = $this->ipAddress;
        if (isset($this->orderDetails)) $o['orderDetails'] = JsonConverters::toArray('OrderDetail', $this->orderDetails);
        return empty($o) ? new class(){} : $o;
    }
}

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 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 Customer implements IAddress, JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        /** @var string|null */
        public ?string $email=null,
        /** @var string|null */
        public ?string $displayName=null,
        /** @var string|null */
        public ?string $firstName=null,
        /** @var string|null */
        public ?string $lastName=null,
        /** @var string|null */
        public ?string $company=null,
        /** @var string|null */
        public ?string $phoneNumber=null,
        /** @var string|null */
        public ?string $addressLine1=null,
        /** @var string|null */
        public ?string $addressLine2=null,
        /** @var string|null */
        public ?string $addressCity=null,
        /** @var string|null */
        public ?string $addressZip=null,
        /** @var string|null */
        public ?string $addressState=null,
        /** @var string|null */
        public ?string $addressCountry=null,
        /** @var string|null */
        public ?string $stripeCustomerId=null,
        /** @var string|null */
        public ?string $stripeCouponId=null,
        /** @var string|null */
        public ?string $plan=null,
        /** @var DateTime */
        public DateTime $createdDate=new DateTime(),
        /** @var bool|null */
        public ?bool $isReferrer=null,
        /** @var array<Order>|null */
        public ?array $orders=null,
        /** @var array<Subscription>|null */
        public ?array $subscriptions=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['displayName'])) $this->displayName = $o['displayName'];
        if (isset($o['firstName'])) $this->firstName = $o['firstName'];
        if (isset($o['lastName'])) $this->lastName = $o['lastName'];
        if (isset($o['company'])) $this->company = $o['company'];
        if (isset($o['phoneNumber'])) $this->phoneNumber = $o['phoneNumber'];
        if (isset($o['addressLine1'])) $this->addressLine1 = $o['addressLine1'];
        if (isset($o['addressLine2'])) $this->addressLine2 = $o['addressLine2'];
        if (isset($o['addressCity'])) $this->addressCity = $o['addressCity'];
        if (isset($o['addressZip'])) $this->addressZip = $o['addressZip'];
        if (isset($o['addressState'])) $this->addressState = $o['addressState'];
        if (isset($o['addressCountry'])) $this->addressCountry = $o['addressCountry'];
        if (isset($o['stripeCustomerId'])) $this->stripeCustomerId = $o['stripeCustomerId'];
        if (isset($o['stripeCouponId'])) $this->stripeCouponId = $o['stripeCouponId'];
        if (isset($o['plan'])) $this->plan = $o['plan'];
        if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
        if (isset($o['isReferrer'])) $this->isReferrer = $o['isReferrer'];
        if (isset($o['orders'])) $this->orders = JsonConverters::fromArray('Order', $o['orders']);
        if (isset($o['subscriptions'])) $this->subscriptions = JsonConverters::fromArray('Subscription', $o['subscriptions']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->displayName)) $o['displayName'] = $this->displayName;
        if (isset($this->firstName)) $o['firstName'] = $this->firstName;
        if (isset($this->lastName)) $o['lastName'] = $this->lastName;
        if (isset($this->company)) $o['company'] = $this->company;
        if (isset($this->phoneNumber)) $o['phoneNumber'] = $this->phoneNumber;
        if (isset($this->addressLine1)) $o['addressLine1'] = $this->addressLine1;
        if (isset($this->addressLine2)) $o['addressLine2'] = $this->addressLine2;
        if (isset($this->addressCity)) $o['addressCity'] = $this->addressCity;
        if (isset($this->addressZip)) $o['addressZip'] = $this->addressZip;
        if (isset($this->addressState)) $o['addressState'] = $this->addressState;
        if (isset($this->addressCountry)) $o['addressCountry'] = $this->addressCountry;
        if (isset($this->stripeCustomerId)) $o['stripeCustomerId'] = $this->stripeCustomerId;
        if (isset($this->stripeCouponId)) $o['stripeCouponId'] = $this->stripeCouponId;
        if (isset($this->plan)) $o['plan'] = $this->plan;
        if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
        if (isset($this->isReferrer)) $o['isReferrer'] = $this->isReferrer;
        if (isset($this->orders)) $o['orders'] = JsonConverters::toArray('Order', $this->orders);
        if (isset($this->subscriptions)) $o['subscriptions'] = JsonConverters::toArray('Subscription', $this->subscriptions);
        return empty($o) ? new class(){} : $o;
    }
}

// @ValidateRequest(Validator="IsAdmin")
class CreateCustomer implements IPost, JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $firstName=null,
        /** @var string|null */
        public ?string $lastName=null,
        /** @var string|null */
        public ?string $email=null,
        /** @var string|null */
        public ?string $password=null,
        /** @var string|null */
        public ?string $company=null,
        /** @var string|null */
        public ?string $phoneNumber=null,
        /** @var string|null */
        public ?string $addressLine1=null,
        /** @var string|null */
        public ?string $addressLine2=null,
        /** @var string|null */
        public ?string $addressCity=null,
        /** @var string|null */
        public ?string $addressZip=null,
        /** @var string|null */
        public ?string $addressState=null,
        /** @var string|null */
        public ?string $addressCountry=null,
        /** @var DateTime|null */
        public ?DateTime $createdDate=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['firstName'])) $this->firstName = $o['firstName'];
        if (isset($o['lastName'])) $this->lastName = $o['lastName'];
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['password'])) $this->password = $o['password'];
        if (isset($o['company'])) $this->company = $o['company'];
        if (isset($o['phoneNumber'])) $this->phoneNumber = $o['phoneNumber'];
        if (isset($o['addressLine1'])) $this->addressLine1 = $o['addressLine1'];
        if (isset($o['addressLine2'])) $this->addressLine2 = $o['addressLine2'];
        if (isset($o['addressCity'])) $this->addressCity = $o['addressCity'];
        if (isset($o['addressZip'])) $this->addressZip = $o['addressZip'];
        if (isset($o['addressState'])) $this->addressState = $o['addressState'];
        if (isset($o['addressCountry'])) $this->addressCountry = $o['addressCountry'];
        if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->firstName)) $o['firstName'] = $this->firstName;
        if (isset($this->lastName)) $o['lastName'] = $this->lastName;
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->password)) $o['password'] = $this->password;
        if (isset($this->company)) $o['company'] = $this->company;
        if (isset($this->phoneNumber)) $o['phoneNumber'] = $this->phoneNumber;
        if (isset($this->addressLine1)) $o['addressLine1'] = $this->addressLine1;
        if (isset($this->addressLine2)) $o['addressLine2'] = $this->addressLine2;
        if (isset($this->addressCity)) $o['addressCity'] = $this->addressCity;
        if (isset($this->addressZip)) $o['addressZip'] = $this->addressZip;
        if (isset($this->addressState)) $o['addressState'] = $this->addressState;
        if (isset($this->addressCountry)) $o['addressCountry'] = $this->addressCountry;
        if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateCustomer DTOs

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

HTTP + XML

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

POST /CreateCustomer HTTP/1.1 
Host: account.servicestack.net 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateCustomer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel">
  <AddressCity>String</AddressCity>
  <AddressCountry>String</AddressCountry>
  <AddressLine1>String</AddressLine1>
  <AddressLine2>String</AddressLine2>
  <AddressState>String</AddressState>
  <AddressZip>String</AddressZip>
  <Company>String</Company>
  <CreatedDate>0001-01-01T00:00:00</CreatedDate>
  <Email>String</Email>
  <FirstName>String</FirstName>
  <LastName>String</LastName>
  <Password>String</Password>
  <PhoneNumber>String</PhoneNumber>
</CreateCustomer>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<Customer xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MyApp.ServiceModel">
  <AddressCity>String</AddressCity>
  <AddressCountry>String</AddressCountry>
  <AddressLine1>String</AddressLine1>
  <AddressLine2>String</AddressLine2>
  <AddressState>String</AddressState>
  <AddressZip>String</AddressZip>
  <Company>String</Company>
  <CreatedDate>0001-01-01T00:00:00</CreatedDate>
  <DisplayName>String</DisplayName>
  <Email>String</Email>
  <FirstName>String</FirstName>
  <Id>0</Id>
  <IsReferrer>false</IsReferrer>
  <LastName>String</LastName>
  <Orders>
    <Order>
      <AddressCity>String</AddressCity>
      <AddressCountry>String</AddressCountry>
      <AddressLine1>String</AddressLine1>
      <AddressLine2>String</AddressLine2>
      <AddressState>String</AddressState>
      <AddressZip>String</AddressZip>
      <AgreeTerms>false</AgreeTerms>
      <AuthorizedQuantity>0</AuthorizedQuantity>
      <CancelledDate>0001-01-01T00:00:00</CancelledDate>
      <CancelledReason>String</CancelledReason>
      <Company>String</Company>
      <CouponId>String</CouponId>
      <CreatedDate>0001-01-01T00:00:00</CreatedDate>
      <CustomerId>0</CustomerId>
      <Discount>0</Discount>
      <Email>String</Email>
      <EmailId>0</EmailId>
      <FirstName>String</FirstName>
      <Id>0</Id>
      <IpAddress>String</IpAddress>
      <ItemQuantity>0</ItemQuantity>
      <Last4>String</Last4>
      <LastName>String</LastName>
      <LicenseRef>String</LicenseRef>
      <ModifiedBy>String</ModifiedBy>
      <ModifiedDate>0001-01-01T00:00:00</ModifiedDate>
      <Notes>String</Notes>
      <OrderDetails>
        <OrderDetail>
          <Description>String</Description>
          <Id>0</Id>
          <OrderId>0</OrderId>
          <Price>0</Price>
          <Quantity>0</Quantity>
          <SkuId>0</SkuId>
          <SkuType>Product</SkuType>
          <Total>0</Total>
        </OrderDetail>
      </OrderDetails>
      <Paid>false</Paid>
      <PaymentId>0</PaymentId>
      <PhoneNumber>String</PhoneNumber>
      <ProductName>String</ProductName>
      <SubTotal>0</SubTotal>
      <SubscriptionId>0</SubscriptionId>
      <Tax>0</Tax>
      <Total>0</Total>
    </Order>
  </Orders>
  <PhoneNumber>String</PhoneNumber>
  <Plan>String</Plan>
  <StripeCouponId>String</StripeCouponId>
  <StripeCustomerId>String</StripeCustomerId>
  <Subscriptions>
    <Subscription>
      <CancelledDate>0001-01-01T00:00:00</CancelledDate>
      <Code>String</Code>
      <CreatedDate>0001-01-01T00:00:00</CreatedDate>
      <CustomerId>0</CustomerId>
      <Email>String</Email>
      <EmailExpiredId>0</EmailExpiredId>
      <EmailId>0</EmailId>
      <EmailRenewalId>0</EmailRenewalId>
      <Error>String</Error>
      <ExpiryDate>0001-01-01T00:00:00</ExpiryDate>
      <ExternalRef>String</ExternalRef>
      <Id>0</Id>
      <IsPlan>false</IsPlan>
      <IsRenewal>false</IsRenewal>
      <LicenseAddress>String</LicenseAddress>
      <LicenseKey xmlns:d4p1="http://schemas.datacontract.org/2004/07/ServiceStack">
        <d4p1:Expiry>0001-01-01T00:00:00</d4p1:Expiry>
        <d4p1:Halg>String</d4p1:Halg>
        <d4p1:Hash>String</d4p1:Hash>
        <d4p1:Meta>0</d4p1:Meta>
        <d4p1:Name>String</d4p1:Name>
        <d4p1:Ref>String</d4p1:Ref>
        <d4p1:Type>Free</d4p1:Type>
      </LicenseKey>
      <LicenseKeyText>String</LicenseKeyText>
      <LicenseName>String</LicenseName>
      <LicenseRef>String</LicenseRef>
      <LicenseType>Free</LicenseType>
      <ModifiedDate>0001-01-01T00:00:00</ModifiedDate>
      <Notes>String</Notes>
      <Quantity>0</Quantity>
      <RenewalDate>0001-01-01T00:00:00</RenewalDate>
      <RenewalSubscriptionId>0</RenewalSubscriptionId>
      <SkuId>0</SkuId>
      <SkuName>String</SkuName>
      <SkuType>Product</SkuType>
      <StripeSubscriptionId>String</StripeSubscriptionId>
      <SubscriptionDurationDays>0</SubscriptionDurationDays>
      <SupportQuantity>0</SupportQuantity>
      <Total>0</Total>
    </Subscription>
  </Subscriptions>
</Customer>