BokaMera.API.Host

<back to all web services

UpdateVossSubscriptions

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
PUT/voss/subscriptionsPUT voss subscription
<?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 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="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="SubscriptionDiscountPeriodRequestDto")
class SubscriptionDiscountPeriodRequestDto implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="periodKind", IsRequired=true)
        /** @var PeriodKindEnum|null */
        public ?PeriodKindEnum $periodKind=null,

        // @DataMember(Name="length")
        /** @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;
    }
}

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

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

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

enum DiscountAgreementsChangeTypeEnum : string
{
    case Prospective = 'Prospective';
    case Retrospective = 'Retrospective';
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
class UpdateVossSubscriptions implements JsonSerializable
{
    public function __construct(
        /** @description The company id. Subscription will be fetched of this company */
        // @ApiMember(Description="The company id. Subscription will be fetched of this company")
        /** @var string */
        public string $CompanyId='',

        /** @description Discount agreement data */
        // @ApiMember(Description="Discount agreement data")
        /** @var array<SubscriptionDiscountAgreementRequestDto>|null */
        public ?array $DiscountAgreements=null,

        /** @description     Discount agreements change type controls how already occured transactions are treated <br />Retrospective - all future and past not invoiced transactions will be recalculated with new discount agreements  <br />Prospective - discounts will apply only for future transactions */
        // @ApiMember(Description="    Discount agreements change type controls how already occured transactions are treated <br />Retrospective - all future and past not invoiced transactions will be recalculated with new discount agreements  <br />Prospective - discounts will apply only for future transactions\n")
        /** @var DiscountAgreementsChangeTypeEnum|null */
        public ?DiscountAgreementsChangeTypeEnum $DiscountAgreementsChangeType=null,

        /** @description The company id. Subscription will be fetched of this company */
        // @ApiMember(Description="The company id. Subscription will be fetched of this company")
        /** @var int */
        public int $CompanyOwnerId=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['DiscountAgreements'])) $this->DiscountAgreements = JsonConverters::fromArray('SubscriptionDiscountAgreementRequestDto', $o['DiscountAgreements']);
        if (isset($o['DiscountAgreementsChangeType'])) $this->DiscountAgreementsChangeType = JsonConverters::from('DiscountAgreementsChangeTypeEnum', $o['DiscountAgreementsChangeType']);
        if (isset($o['CompanyOwnerId'])) $this->CompanyOwnerId = $o['CompanyOwnerId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->DiscountAgreements)) $o['DiscountAgreements'] = JsonConverters::toArray('SubscriptionDiscountAgreementRequestDto', $this->DiscountAgreements);
        if (isset($this->DiscountAgreementsChangeType)) $o['DiscountAgreementsChangeType'] = JsonConverters::to('DiscountAgreementsChangeTypeEnum', $this->DiscountAgreementsChangeType);
        if (isset($this->CompanyOwnerId)) $o['CompanyOwnerId'] = $this->CompanyOwnerId;
        return empty($o) ? new class(){} : $o;
    }
}

PHP UpdateVossSubscriptions DTOs

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

HTTP + OTHER

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

PUT /voss/subscriptions HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"DiscountAgreements":[{}],"DiscountAgreementsChangeType":"Prospective","CompanyOwnerId":0}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{}