BokaMera.API.Host

<back to all web services

UpdateVossDiscountAgreements

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
PUT/voss/discountAgreementsPUT Discount agreements
<?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="UpdateDiscountPeriodRequestDto")
class UpdateDiscountPeriodRequestDto 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;
    }
}

enum DiscountAgreementStatusEnum : string
{
    case Draft = 'Draft';
    case Staged = 'Staged';
    case Published = 'Published';
    case Archived = 'Archived';
    case Discarded = 'Discarded';
}

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

        /** @description Discount agreement period data. Iteration count must be added */
        // @ApiMember(Description="Discount agreement period data. Iteration count must be added", IsRequired=true)
        /** @var UpdateDiscountPeriodRequestDto|null */
        public ?UpdateDiscountPeriodRequestDto $DiscountPeriod=null,

        /** @description Discount agreement status. Published is default. */
        // @ApiMember(Description="Discount agreement status. Published is default.", IsRequired=true)
        /** @var DiscountAgreementStatusEnum|null */
        public ?DiscountAgreementStatusEnum $DiscountAgreementStatus=null,

        /** @var string */
        public string $Name='',
        /** @var string */
        public string $Description='',
        /** @var DateTime */
        public DateTime $ValidFrom=new DateTime(),
        /** @var DateTime|null */
        public ?DateTime $ValidTo=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['DiscountAgreementId'])) $this->DiscountAgreementId = $o['DiscountAgreementId'];
        if (isset($o['DiscountPeriod'])) $this->DiscountPeriod = JsonConverters::from('UpdateDiscountPeriodRequestDto', $o['DiscountPeriod']);
        if (isset($o['DiscountAgreementStatus'])) $this->DiscountAgreementStatus = JsonConverters::from('DiscountAgreementStatusEnum', $o['DiscountAgreementStatus']);
        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']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->DiscountAgreementId)) $o['DiscountAgreementId'] = $this->DiscountAgreementId;
        if (isset($this->DiscountPeriod)) $o['DiscountPeriod'] = JsonConverters::to('UpdateDiscountPeriodRequestDto', $this->DiscountPeriod);
        if (isset($this->DiscountAgreementStatus)) $o['DiscountAgreementStatus'] = JsonConverters::to('DiscountAgreementStatusEnum', $this->DiscountAgreementStatus);
        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);
        return empty($o) ? new class(){} : $o;
    }
}

PHP UpdateVossDiscountAgreements DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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

PUT /voss/discountAgreements HTTP/1.1 
Host: api.bokamera.se 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"DiscountAgreementStatus":"Draft","Name":"String","Description":"String","ValidTo":"0001-01-01T00:00:00"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{}