BokaMera.API.Host

<back to all web services

EndAllLicenses

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/licenses/company/deleteEnd all licensesEnd all licenses on the company for the logged in user.
<?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 LicenseItemsResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string */
        public string $Name='',
        /** @var int */
        public int $AllowedItems=0
    ) {
    }

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

class BaseModel implements JsonSerializable
{
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        return empty($o) ? new class(){} : $o;
    }
}

class Currency extends BaseModel implements JsonSerializable
{
    public function __construct(
        // @Required()
        /** @var string */
        public string $Name='',

        // @Required()
        /** @var string */
        public string $CurrencySign='',

        // @Required()
        /** @var bool|null */
        public ?bool $Active=null,

        /** @var DateTime|null */
        public ?DateTime $ModifiedDate=null,
        // @Required()
        /** @var string */
        public string $Id=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['CurrencySign'])) $this->CurrencySign = $o['CurrencySign'];
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['ModifiedDate'])) $this->ModifiedDate = JsonConverters::from('DateTimeOffset', $o['ModifiedDate']);
        if (isset($o['Id'])) $this->Id = $o['Id'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->CurrencySign)) $o['CurrencySign'] = $this->CurrencySign;
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->ModifiedDate)) $o['ModifiedDate'] = JsonConverters::to('DateTimeOffset', $this->ModifiedDate);
        if (isset($this->Id)) $o['Id'] = $this->Id;
        return empty($o) ? new class(){} : $o;
    }
}

class Country extends BaseModel implements JsonSerializable
{
    public function __construct(
        // @References("typeof(BokaMera.API.ServiceModel.Db.Currency)")
        /** @var string */
        public string $CurrencyId='',

        /** @var Currency|null */
        public ?Currency $CurrencyInfo=null,
        // @Required()
        /** @var string */
        public string $Name='',

        /** @var string|null */
        public ?string $Culture=null,
        /** @var string|null */
        public ?string $TimeZone=null,
        /** @var DateTime|null */
        public ?DateTime $ModifiedDate=null,
        // @Required()
        /** @var string */
        public string $Id=''
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
        if (isset($o['CurrencyInfo'])) $this->CurrencyInfo = JsonConverters::from('Currency', $o['CurrencyInfo']);
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Culture'])) $this->Culture = $o['Culture'];
        if (isset($o['TimeZone'])) $this->TimeZone = $o['TimeZone'];
        if (isset($o['ModifiedDate'])) $this->ModifiedDate = JsonConverters::from('DateTimeOffset', $o['ModifiedDate']);
        if (isset($o['Id'])) $this->Id = $o['Id'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
        if (isset($this->CurrencyInfo)) $o['CurrencyInfo'] = JsonConverters::to('Currency', $this->CurrencyInfo);
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Culture)) $o['Culture'] = $this->Culture;
        if (isset($this->TimeZone)) $o['TimeZone'] = $this->TimeZone;
        if (isset($this->ModifiedDate)) $o['ModifiedDate'] = JsonConverters::to('DateTimeOffset', $this->ModifiedDate);
        if (isset($this->Id)) $o['Id'] = $this->Id;
        return empty($o) ? new class(){} : $o;
    }
}

class LicensePriceResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $LicenseTypeId=0,
        /** @var string */
        public string $CountryId='',
        /** @var int */
        public int $Price=0,
        /** @var Country|null */
        public ?Country $Country=null,
        /** @var int */
        public int $LicensePlanId=0
    ) {
    }

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

class LicenseTypeQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description The license type id */
        // @ApiMember(Description="The license type id")
        /** @var int */
        public int $Id=0,

        /** @description The license type name */
        // @ApiMember(Description="The license type name")
        /** @var string */
        public string $Name='',

        /** @description The license type description */
        // @ApiMember(Description="The license type description")
        /** @var string */
        public string $Description='',

        /** @description If the license type is not a standard license but instead an extra license option. An example would be sending newsletter license. */
        // @ApiMember(Description="If the license type is not a standard license but instead an extra license option. An example would be sending newsletter license.")
        /** @var bool|null */
        public ?bool $IsExtraLicenseOption=null,

        /** @description The period of notice for the license in days. */
        // @ApiMember(Description="The period of notice for the license in days.")
        /** @var int */
        public int $PeriodOfNoticeDays=0,

        /** @description The license items for the license type */
        // @ApiMember(Description="The license items for the license type")
        /** @var array<LicenseItemsResponse>|null */
        public ?array $Items=null,

        /** @description The license prices in each country for the license type */
        // @ApiMember(Description="The license prices in each country for the license type")
        /** @var array<LicensePriceResponse>|null */
        public ?array $Prices=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['IsExtraLicenseOption'])) $this->IsExtraLicenseOption = $o['IsExtraLicenseOption'];
        if (isset($o['PeriodOfNoticeDays'])) $this->PeriodOfNoticeDays = $o['PeriodOfNoticeDays'];
        if (isset($o['Items'])) $this->Items = JsonConverters::fromArray('LicenseItemsResponse', $o['Items']);
        if (isset($o['Prices'])) $this->Prices = JsonConverters::fromArray('LicensePriceResponse', $o['Prices']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->IsExtraLicenseOption)) $o['IsExtraLicenseOption'] = $this->IsExtraLicenseOption;
        if (isset($this->PeriodOfNoticeDays)) $o['PeriodOfNoticeDays'] = $this->PeriodOfNoticeDays;
        if (isset($this->Items)) $o['Items'] = JsonConverters::toArray('LicenseItemsResponse', $this->Items);
        if (isset($this->Prices)) $o['Prices'] = JsonConverters::toArray('LicensePriceResponse', $this->Prices);
        return empty($o) ? new class(){} : $o;
    }
}

class ProductGroupResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string */
        public string $Name='',
        /** @var string */
        public string $TierId=''
    ) {
    }

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

class TierResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string */
        public string $Name='',
        /** @var array<ProductGroupResponse>|null */
        public ?array $ProductGroups=null
    ) {
    }

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

class VossSubscriptionResponse implements JsonSerializable
{
    public function __construct(
        /** @var DateTime */
        public DateTime $SubscriptionBillingPeriodStartDate=new DateTime(),
        /** @var DateTime */
        public DateTime $SubscriptionBillingPeriodEndDate=new DateTime(),
        /** @var DateTime|null */
        public ?DateTime $BindingPeriodEndDate=null,
        /** @var TierResponse|null */
        public ?TierResponse $Tier=null
    ) {
    }

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

class CompanyLicenseQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var int */
        public int $TypeId=0,
        /** @var LicenseTypeQueryResponse|null */
        public ?LicenseTypeQueryResponse $Type=null,
        /** @var DateTime */
        public DateTime $ValidFrom=new DateTime(),
        /** @var DateTime */
        public DateTime $ValidTo=new DateTime(),
        /** @var string|null */
        public ?string $VossSubscriptionId=null,
        /** @var VossSubscriptionResponse|null */
        public ?VossSubscriptionResponse $VossSubscription=null,
        /** @var string */
        public string $MetaData='',
        /** @var bool|null */
        public ?bool $Active=null,
        /** @var string */
        public string $LicenseStatus='',
        /** @var bool|null */
        public ?bool $Canceled=null,
        /** @var int|null */
        public ?int $LicensePlanId=null,
        /** @var DateTime */
        public DateTime $Updated=new DateTime(),
        /** @var DateTime */
        public DateTime $Created=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['TypeId'])) $this->TypeId = $o['TypeId'];
        if (isset($o['Type'])) $this->Type = JsonConverters::from('LicenseTypeQueryResponse', $o['Type']);
        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['VossSubscriptionId'])) $this->VossSubscriptionId = $o['VossSubscriptionId'];
        if (isset($o['VossSubscription'])) $this->VossSubscription = JsonConverters::from('VossSubscriptionResponse', $o['VossSubscription']);
        if (isset($o['MetaData'])) $this->MetaData = $o['MetaData'];
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['LicenseStatus'])) $this->LicenseStatus = $o['LicenseStatus'];
        if (isset($o['Canceled'])) $this->Canceled = $o['Canceled'];
        if (isset($o['LicensePlanId'])) $this->LicensePlanId = $o['LicensePlanId'];
        if (isset($o['Updated'])) $this->Updated = JsonConverters::from('DateTime', $o['Updated']);
        if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->TypeId)) $o['TypeId'] = $this->TypeId;
        if (isset($this->Type)) $o['Type'] = JsonConverters::to('LicenseTypeQueryResponse', $this->Type);
        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->VossSubscriptionId)) $o['VossSubscriptionId'] = $this->VossSubscriptionId;
        if (isset($this->VossSubscription)) $o['VossSubscription'] = JsonConverters::to('VossSubscriptionResponse', $this->VossSubscription);
        if (isset($this->MetaData)) $o['MetaData'] = $this->MetaData;
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->LicenseStatus)) $o['LicenseStatus'] = $this->LicenseStatus;
        if (isset($this->Canceled)) $o['Canceled'] = $this->Canceled;
        if (isset($this->LicensePlanId)) $o['LicensePlanId'] = $this->LicensePlanId;
        if (isset($this->Updated)) $o['Updated'] = JsonConverters::to('DateTime', $this->Updated);
        if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
        return empty($o) ? new class(){} : $o;
    }
}

class Questionnaire implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Question='',
        /** @var string */
        public string $Value=''
    ) {
    }

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

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class EndAllLicenses implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The company id, if empty will use the company id for the user you are logged in with. */
        // @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
        /** @var string|null */
        public ?string $CompanyId=null,

        /** @description If true, all licenses and the booking system are terminated today. If false (default), the licenses stay active and are billed until the end of the current billing period, and each license's ValidTo is set to that date. */
        // @ApiMember(Description="If true, all licenses and the booking system are terminated today. If false (default), the licenses stay active and are billed until the end of the current billing period, and each license's ValidTo is set to that date.")
        /** @var bool|null */
        public ?bool $Deactivate=null,

        /** @description Questionaire with answers from customer why ending license. */
        // @ApiMember(Description="Questionaire with answers from customer why ending license.")
        /** @var Questionnaire[] */
        public array $Questionnaire=[]
    ) {
    }

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

PHP EndAllLicenses 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 /licenses/company/delete HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","Deactivate":false,"Questionnaire":[{"Question":"String","Value":"String"}]}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"Id":0,"TypeId":0,"Type":{"Id":0,"Name":"String","Description":"String","IsExtraLicenseOption":false,"PeriodOfNoticeDays":0,"Items":[{"Id":0,"Name":"String","AllowedItems":0}],"Prices":[{"LicenseTypeId":0,"CountryId":"String","Price":0,"Country":{"CurrencyId":"String","CurrencyInfo":{"Name":"String","CurrencySign":"String","Active":false,"ModifiedDate":"0001-01-01T00:00:00.0000000+00:00","Id":"String"},"Name":"String","Culture":"String","TimeZone":"String","ModifiedDate":"0001-01-01T00:00:00.0000000+00:00","Id":"String"},"LicensePlanId":0}]},"VossSubscriptionId":"00000000-0000-0000-0000-000000000000","VossSubscription":{"BindingPeriodEndDate":"0001-01-01T00:00:00","Tier":{"Name":"String","ProductGroups":[{"Name":"String"}]}},"MetaData":"String","Active":false,"LicenseStatus":"String","Canceled":false,"LicensePlanId":0}