BokaMera.API.Host

<back to all web services

CreateVossDiscountAgreement

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/voss/discountAgreementsCreate discount agreementCreate discount agreement in VOSS System.
<?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 DiscountAgreementStatusEnum : string
{
    case Draft = 'Draft';
    case Staged = 'Staged';
    case Published = 'Published';
    case Archived = 'Archived';
    case Discarded = 'Discarded';
}

enum ApplicationScopeEnum : string
{
    case Any = 'Any';
    case SubscriptionCustomer = 'SubscriptionCustomer';
    case NonSubscriptionCustomerInvoiceRecipient = 'NonSubscriptionCustomerInvoiceRecipient';
}

enum PeriodKindEnum : string
{
    case FixedTime = 'FixedTime';
    case AlignedToBindingPeriod = 'AlignedToBindingPeriod';
    case AlignedToSubscriptionBillingPeriod = 'AlignedToSubscriptionBillingPeriod';
}

enum UnitEnum : string
{
    case Day = 'Day';
    case Month = 'Month';
    case Year = 'Year';
}

// @DataContract(Name="TimeLengthDto")
class TimeLengthDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="unit", IsRequired=true)
        /** @var UnitEnum|null */
        public ?UnitEnum $unit=null,

        // @DataMember(Name="value", EmitDefaultValue=false)
        /** @var int */
        public int $value=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['unit'])) $this->unit = JsonConverters::from('UnitEnum', $o['unit']);
        if (isset($o['value'])) $this->value = $o['value'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->unit)) $o['unit'] = JsonConverters::to('UnitEnum', $this->unit);
        if (isset($this->value)) $o['value'] = $this->value;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="DiscountPeriodDto")
class DiscountPeriodDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="periodKind", IsRequired=true)
        /** @var PeriodKindEnum|null */
        public ?PeriodKindEnum $periodKind=null,

        // @DataMember(Name="length")
        /** @var TimeLengthDto|null */
        public ?TimeLengthDto $length=null,

        // @DataMember(Name="periodIterationCount")
        /** @var int|null */
        public ?int $periodIterationCount=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['periodKind'])) $this->periodKind = JsonConverters::from('PeriodKindEnum', $o['periodKind']);
        if (isset($o['length'])) $this->length = JsonConverters::from('TimeLengthDto', $o['length']);
        if (isset($o['periodIterationCount'])) $this->periodIterationCount = $o['periodIterationCount'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->periodKind)) $o['periodKind'] = JsonConverters::to('PeriodKindEnum', $this->periodKind);
        if (isset($this->length)) $o['length'] = JsonConverters::to('TimeLengthDto', $this->length);
        if (isset($this->periodIterationCount)) $o['periodIterationCount'] = $this->periodIterationCount;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="DiscountPackageDto")
class DiscountPackageDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="name", IsRequired=true)
        /** @var string */
        public string $name=''
    ) {
    }

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

// @DataContract(Name="DiscountAgreementCustomerResultDto")
class DiscountAgreementCustomerResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="customerId", IsRequired=true)
        /** @var string */
        public string $customerId=''
    ) {
    }

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

// @DataContract(Name="DiscountAgreementCustomerGroupResultDto")
class DiscountAgreementCustomerGroupResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="intervalStart", EmitDefaultValue=false)
        /** @var int */
        public int $intervalStart=0,

        // @DataMember(Name="intervalEnd", EmitDefaultValue=false)
        /** @var int */
        public int $intervalEnd=0
    ) {
    }

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

enum DiscountTypeEnum : string
{
    case FlatPrice = 'FlatPrice';
    case Percentage = 'Percentage';
}

// @DataContract(Name="PricingTierDiscountResultDto")
class PricingTierDiscountResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="discountType", IsRequired=true)
        /** @var DiscountTypeEnum|null */
        public ?DiscountTypeEnum $discountType=null,

        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="index", EmitDefaultValue=false)
        /** @var int */
        public int $index=0,

        // @DataMember(Name="unitPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $unitPriceDiscount=0.0,

        // @DataMember(Name="flatPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $flatPriceDiscount=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['discountType'])) $this->discountType = JsonConverters::from('DiscountTypeEnum', $o['discountType']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['index'])) $this->index = $o['index'];
        if (isset($o['unitPriceDiscount'])) $this->unitPriceDiscount = $o['unitPriceDiscount'];
        if (isset($o['flatPriceDiscount'])) $this->flatPriceDiscount = $o['flatPriceDiscount'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->discountType)) $o['discountType'] = JsonConverters::to('DiscountTypeEnum', $this->discountType);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->index)) $o['index'] = $this->index;
        if (isset($this->unitPriceDiscount)) $o['unitPriceDiscount'] = $this->unitPriceDiscount;
        if (isset($this->flatPriceDiscount)) $o['flatPriceDiscount'] = $this->flatPriceDiscount;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="ProductPricingDiscountResultDto")
class ProductPricingDiscountResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="discountType", IsRequired=true)
        /** @var DiscountTypeEnum|null */
        public ?DiscountTypeEnum $discountType=null,

        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="productId", IsRequired=true)
        /** @var string */
        public string $productId='',

        // @DataMember(Name="unitPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $unitPriceDiscount=0.0,

        // @DataMember(Name="tierPricingDiscounts", EmitDefaultValue=false)
        /** @var array<PricingTierDiscountResultDto>|null */
        public ?array $tierPricingDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['discountType'])) $this->discountType = JsonConverters::from('DiscountTypeEnum', $o['discountType']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['productId'])) $this->productId = $o['productId'];
        if (isset($o['unitPriceDiscount'])) $this->unitPriceDiscount = $o['unitPriceDiscount'];
        if (isset($o['tierPricingDiscounts'])) $this->tierPricingDiscounts = JsonConverters::fromArray('PricingTierDiscountResultDto', $o['tierPricingDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->discountType)) $o['discountType'] = JsonConverters::to('DiscountTypeEnum', $this->discountType);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->productId)) $o['productId'] = $this->productId;
        if (isset($this->unitPriceDiscount)) $o['unitPriceDiscount'] = $this->unitPriceDiscount;
        if (isset($this->tierPricingDiscounts)) $o['tierPricingDiscounts'] = JsonConverters::toArray('PricingTierDiscountResultDto', $this->tierPricingDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="ProductGroupDiscountResultDto")
class ProductGroupDiscountResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="productGroupId", IsRequired=true)
        /** @var string */
        public string $productGroupId='',

        // @DataMember(Name="productPricingDiscounts", EmitDefaultValue=false)
        /** @var array<ProductPricingDiscountResultDto>|null */
        public ?array $productPricingDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['productGroupId'])) $this->productGroupId = $o['productGroupId'];
        if (isset($o['productPricingDiscounts'])) $this->productPricingDiscounts = JsonConverters::fromArray('ProductPricingDiscountResultDto', $o['productPricingDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->productGroupId)) $o['productGroupId'] = $this->productGroupId;
        if (isset($this->productPricingDiscounts)) $o['productPricingDiscounts'] = JsonConverters::toArray('ProductPricingDiscountResultDto', $this->productPricingDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="ChargePlanDiscountResultDto")
class ChargePlanDiscountResultDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="chargePlanId", IsRequired=true)
        /** @var string */
        public string $chargePlanId='',

        // @DataMember(Name="productGroupDiscounts", EmitDefaultValue=false)
        /** @var array<ProductGroupDiscountResultDto>|null */
        public ?array $productGroupDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['chargePlanId'])) $this->chargePlanId = $o['chargePlanId'];
        if (isset($o['productGroupDiscounts'])) $this->productGroupDiscounts = JsonConverters::fromArray('ProductGroupDiscountResultDto', $o['productGroupDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->chargePlanId)) $o['chargePlanId'] = $this->chargePlanId;
        if (isset($this->productGroupDiscounts)) $o['productGroupDiscounts'] = JsonConverters::toArray('ProductGroupDiscountResultDto', $this->productGroupDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="DiscountAgreementResult")
class DiscountAgreementResult implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="status", IsRequired=true)
        /** @var DiscountAgreementStatusEnum|null */
        public ?DiscountAgreementStatusEnum $status=null,

        // @DataMember(Name="applicationScope", IsRequired=true)
        /** @var ApplicationScopeEnum|null */
        public ?ApplicationScopeEnum $applicationScope=null,

        // @DataMember(Name="id", IsRequired=true)
        /** @var string */
        public string $id='',

        // @DataMember(Name="versionId", IsRequired=true)
        /** @var string */
        public string $versionId='',

        // @DataMember(Name="sourceVersionId")
        /** @var string|null */
        public ?string $sourceVersionId=null,

        // @DataMember(Name="externalId")
        /** @var string */
        public string $externalId='',

        // @DataMember(Name="name", IsRequired=true)
        /** @var string */
        public string $name='',

        // @DataMember(Name="description")
        /** @var string */
        public string $description='',

        // @DataMember(Name="validFrom", IsRequired=true)
        /** @var DateTime */
        public DateTime $validFrom=new DateTime(),

        // @DataMember(Name="validTo")
        /** @var DateTime|null */
        public ?DateTime $validTo=null,

        // @DataMember(Name="discountPeriod", EmitDefaultValue=false)
        /** @var DiscountPeriodDto|null */
        public ?DiscountPeriodDto $discountPeriod=null,

        // @DataMember(Name="package", IsRequired=true)
        /** @var DiscountPackageDto|null */
        public ?DiscountPackageDto $package=null,

        // @DataMember(Name="customers", EmitDefaultValue=false)
        /** @var array<DiscountAgreementCustomerResultDto>|null */
        public ?array $customers=null,

        // @DataMember(Name="customerGroups", EmitDefaultValue=false)
        /** @var array<DiscountAgreementCustomerGroupResultDto>|null */
        public ?array $customerGroups=null,

        // @DataMember(Name="chargePlanDiscounts", EmitDefaultValue=false)
        /** @var array<ChargePlanDiscountResultDto>|null */
        public ?array $chargePlanDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['status'])) $this->status = JsonConverters::from('DiscountAgreementStatusEnum', $o['status']);
        if (isset($o['applicationScope'])) $this->applicationScope = JsonConverters::from('ApplicationScopeEnum', $o['applicationScope']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['versionId'])) $this->versionId = $o['versionId'];
        if (isset($o['sourceVersionId'])) $this->sourceVersionId = $o['sourceVersionId'];
        if (isset($o['externalId'])) $this->externalId = $o['externalId'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['validFrom'])) $this->validFrom = JsonConverters::from('DateTime', $o['validFrom']);
        if (isset($o['validTo'])) $this->validTo = JsonConverters::from('DateTime', $o['validTo']);
        if (isset($o['discountPeriod'])) $this->discountPeriod = JsonConverters::from('DiscountPeriodDto', $o['discountPeriod']);
        if (isset($o['package'])) $this->package = JsonConverters::from('DiscountPackageDto', $o['package']);
        if (isset($o['customers'])) $this->customers = JsonConverters::fromArray('DiscountAgreementCustomerResultDto', $o['customers']);
        if (isset($o['customerGroups'])) $this->customerGroups = JsonConverters::fromArray('DiscountAgreementCustomerGroupResultDto', $o['customerGroups']);
        if (isset($o['chargePlanDiscounts'])) $this->chargePlanDiscounts = JsonConverters::fromArray('ChargePlanDiscountResultDto', $o['chargePlanDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->status)) $o['status'] = JsonConverters::to('DiscountAgreementStatusEnum', $this->status);
        if (isset($this->applicationScope)) $o['applicationScope'] = JsonConverters::to('ApplicationScopeEnum', $this->applicationScope);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->versionId)) $o['versionId'] = $this->versionId;
        if (isset($this->sourceVersionId)) $o['sourceVersionId'] = $this->sourceVersionId;
        if (isset($this->externalId)) $o['externalId'] = $this->externalId;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->validFrom)) $o['validFrom'] = JsonConverters::to('DateTime', $this->validFrom);
        if (isset($this->validTo)) $o['validTo'] = JsonConverters::to('DateTime', $this->validTo);
        if (isset($this->discountPeriod)) $o['discountPeriod'] = JsonConverters::to('DiscountPeriodDto', $this->discountPeriod);
        if (isset($this->package)) $o['package'] = JsonConverters::to('DiscountPackageDto', $this->package);
        if (isset($this->customers)) $o['customers'] = JsonConverters::toArray('DiscountAgreementCustomerResultDto', $this->customers);
        if (isset($this->customerGroups)) $o['customerGroups'] = JsonConverters::toArray('DiscountAgreementCustomerGroupResultDto', $this->customerGroups);
        if (isset($this->chargePlanDiscounts)) $o['chargePlanDiscounts'] = JsonConverters::toArray('ChargePlanDiscountResultDto', $this->chargePlanDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CreatePricingTierDiscountRequestDto")
class CreatePricingTierDiscountRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="discountType", IsRequired=true)
        /** @var DiscountTypeEnum|null */
        public ?DiscountTypeEnum $discountType=null,

        // @DataMember(Name="index", IsRequired=true)
        /** @var int */
        public int $index=0,

        // @DataMember(Name="unitPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $unitPriceDiscount=0.0,

        // @DataMember(Name="flatPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $flatPriceDiscount=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['discountType'])) $this->discountType = JsonConverters::from('DiscountTypeEnum', $o['discountType']);
        if (isset($o['index'])) $this->index = $o['index'];
        if (isset($o['unitPriceDiscount'])) $this->unitPriceDiscount = $o['unitPriceDiscount'];
        if (isset($o['flatPriceDiscount'])) $this->flatPriceDiscount = $o['flatPriceDiscount'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->discountType)) $o['discountType'] = JsonConverters::to('DiscountTypeEnum', $this->discountType);
        if (isset($this->index)) $o['index'] = $this->index;
        if (isset($this->unitPriceDiscount)) $o['unitPriceDiscount'] = $this->unitPriceDiscount;
        if (isset($this->flatPriceDiscount)) $o['flatPriceDiscount'] = $this->flatPriceDiscount;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="ProductPricingDiscountRequestDto")
class ProductPricingDiscountRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="discountType", IsRequired=true)
        /** @var DiscountTypeEnum|null */
        public ?DiscountTypeEnum $discountType=null,

        // @DataMember(Name="productId", IsRequired=true)
        /** @var string */
        public string $productId='',

        // @DataMember(Name="unitPriceDiscount", EmitDefaultValue=false)
        /** @var float */
        public float $unitPriceDiscount=0.0,

        // @DataMember(Name="tierPricingDiscounts", EmitDefaultValue=false)
        /** @var array<CreatePricingTierDiscountRequestDto>|null */
        public ?array $tierPricingDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['discountType'])) $this->discountType = JsonConverters::from('DiscountTypeEnum', $o['discountType']);
        if (isset($o['productId'])) $this->productId = $o['productId'];
        if (isset($o['unitPriceDiscount'])) $this->unitPriceDiscount = $o['unitPriceDiscount'];
        if (isset($o['tierPricingDiscounts'])) $this->tierPricingDiscounts = JsonConverters::fromArray('CreatePricingTierDiscountRequestDto', $o['tierPricingDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->discountType)) $o['discountType'] = JsonConverters::to('DiscountTypeEnum', $this->discountType);
        if (isset($this->productId)) $o['productId'] = $this->productId;
        if (isset($this->unitPriceDiscount)) $o['unitPriceDiscount'] = $this->unitPriceDiscount;
        if (isset($this->tierPricingDiscounts)) $o['tierPricingDiscounts'] = JsonConverters::toArray('CreatePricingTierDiscountRequestDto', $this->tierPricingDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CreateProductGroupDiscountRequestDto")
class CreateProductGroupDiscountRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="productGroupId", IsRequired=true)
        /** @var string */
        public string $productGroupId='',

        // @DataMember(Name="productPricingDiscounts", EmitDefaultValue=false)
        /** @var array<ProductPricingDiscountRequestDto>|null */
        public ?array $productPricingDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['productGroupId'])) $this->productGroupId = $o['productGroupId'];
        if (isset($o['productPricingDiscounts'])) $this->productPricingDiscounts = JsonConverters::fromArray('ProductPricingDiscountRequestDto', $o['productPricingDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->productGroupId)) $o['productGroupId'] = $this->productGroupId;
        if (isset($this->productPricingDiscounts)) $o['productPricingDiscounts'] = JsonConverters::toArray('ProductPricingDiscountRequestDto', $this->productPricingDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CreateChargePlanDiscountRequestDto")
class CreateChargePlanDiscountRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="chargePlanId", IsRequired=true)
        /** @var string */
        public string $chargePlanId='',

        // @DataMember(Name="productGroupDiscounts", EmitDefaultValue=false)
        /** @var array<CreateProductGroupDiscountRequestDto>|null */
        public ?array $productGroupDiscounts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['chargePlanId'])) $this->chargePlanId = $o['chargePlanId'];
        if (isset($o['productGroupDiscounts'])) $this->productGroupDiscounts = JsonConverters::fromArray('CreateProductGroupDiscountRequestDto', $o['productGroupDiscounts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->chargePlanId)) $o['chargePlanId'] = $this->chargePlanId;
        if (isset($this->productGroupDiscounts)) $o['productGroupDiscounts'] = JsonConverters::toArray('CreateProductGroupDiscountRequestDto', $this->productGroupDiscounts);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="DiscountAgreementTimeLengthRequestDto")
class DiscountAgreementTimeLengthRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="unit", IsRequired=true)
        /** @var UnitEnum|null */
        public ?UnitEnum $unit=null,

        // @DataMember(Name="value", IsRequired=true)
        /** @var int */
        public int $value=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['unit'])) $this->unit = JsonConverters::from('UnitEnum', $o['unit']);
        if (isset($o['value'])) $this->value = $o['value'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->unit)) $o['unit'] = JsonConverters::to('UnitEnum', $this->unit);
        if (isset($this->value)) $o['value'] = $this->value;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract(Name="CreateDiscountPeriodRequestDto")
class CreateDiscountPeriodRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="periodKind", IsRequired=true)
        /** @var PeriodKindEnum|null */
        public ?PeriodKindEnum $periodKind=null,

        // @DataMember(Name="length", EmitDefaultValue=false)
        /** @var DiscountAgreementTimeLengthRequestDto|null */
        public ?DiscountAgreementTimeLengthRequestDto $length=null,

        // @DataMember(Name="periodIterationCount")
        /** @var int|null */
        public ?int $periodIterationCount=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['periodKind'])) $this->periodKind = JsonConverters::from('PeriodKindEnum', $o['periodKind']);
        if (isset($o['length'])) $this->length = JsonConverters::from('DiscountAgreementTimeLengthRequestDto', $o['length']);
        if (isset($o['periodIterationCount'])) $this->periodIterationCount = $o['periodIterationCount'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->periodKind)) $o['periodKind'] = JsonConverters::to('PeriodKindEnum', $this->periodKind);
        if (isset($this->length)) $o['length'] = JsonConverters::to('DiscountAgreementTimeLengthRequestDto', $this->length);
        if (isset($this->periodIterationCount)) $o['periodIterationCount'] = $this->periodIterationCount;
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateVossDiscountAgreement implements JsonSerializable
{
    public function __construct(
        /** @description Discount agreement name */
        // @ApiMember(Description="Discount agreement name", IsRequired=true)
        /** @var string */
        public string $Name='',

        /** @description Discount agreement name */
        // @ApiMember(Description="Discount agreement name", IsRequired=true)
        /** @var array<CreateChargePlanDiscountRequestDto>|null */
        public ?array $ChargePlanDiscounts=null,

        /** @var string */
        public string $Description='',
        /** @description Discount agreement name */
        // @ApiMember(Description="Discount agreement name", IsRequired=true)
        /** @var DateTime */
        public DateTime $ValidFrom=new DateTime(),

        /** @description Discount agreement name */
        // @ApiMember(Description="Discount agreement name")
        /** @var DateTime|null */
        public ?DateTime $ValidTo=null,

        /** @description Discount agreement name */
        // @ApiMember(Description="Discount agreement name")
        /** @var CreateDiscountPeriodRequestDto|null */
        public ?CreateDiscountPeriodRequestDto $DiscountPeriod=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['ChargePlanDiscounts'])) $this->ChargePlanDiscounts = JsonConverters::fromArray('CreateChargePlanDiscountRequestDto', $o['ChargePlanDiscounts']);
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ValidFrom'])) $this->ValidFrom = JsonConverters::from('DateTime', $o['ValidFrom']);
        if (isset($o['ValidTo'])) $this->ValidTo = JsonConverters::from('DateTime', $o['ValidTo']);
        if (isset($o['DiscountPeriod'])) $this->DiscountPeriod = JsonConverters::from('CreateDiscountPeriodRequestDto', $o['DiscountPeriod']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->ChargePlanDiscounts)) $o['ChargePlanDiscounts'] = JsonConverters::toArray('CreateChargePlanDiscountRequestDto', $this->ChargePlanDiscounts);
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ValidFrom)) $o['ValidFrom'] = JsonConverters::to('DateTime', $this->ValidFrom);
        if (isset($this->ValidTo)) $o['ValidTo'] = JsonConverters::to('DateTime', $this->ValidTo);
        if (isset($this->DiscountPeriod)) $o['DiscountPeriod'] = JsonConverters::to('CreateDiscountPeriodRequestDto', $this->DiscountPeriod);
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateVossDiscountAgreement 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 /voss/discountAgreements HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"Name":"String","ChargePlanDiscounts":[{}],"Description":"String","ValidTo":"0001-01-01T00:00:00"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"status":"Draft","applicationScope":"Any","sourceVersionId":"00000000-0000-0000-0000-000000000000","externalId":"String","name":"String","description":"String","validTo":"0001-01-01T00:00:00","customers":[{}],"customerGroups":[{}],"chargePlanDiscounts":[{}]}