BokaMera.API.Host

<back to all web services

CreateIncentiveAction

Requires Authentication
Requires the role:superadmin
The following routes are available for this service:
POST/superadmin/incentives/actionAdd a new incentive action
<?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 IncentiveActionType : int
{
    case Upgrade = 1;
    case AddOn = 2;
    case Information = 3;
}

class LicenseItemsResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Name=null,
        /** @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|null */
        public ?string $CurrencyId=null,

        /** @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 LicensePrice extends BaseModel implements JsonSerializable
{
    public function __construct(
        // @Ignore()
        /** @var Country|null */
        public ?Country $Country=null,

        // @Ignore()
        /** @var bool|null */
        public ?bool $MonthlyPayment=null,

        // @Required()
        /** @var int */
        public int $LicenseTypeId=0,

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

        // @Required()
        /** @var int */
        public int $Price=0,

        /** @var DateTime|null */
        public ?DateTime $ModifiedDate=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['Country'])) $this->Country = JsonConverters::from('Country', $o['Country']);
        if (isset($o['MonthlyPayment'])) $this->MonthlyPayment = $o['MonthlyPayment'];
        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['ModifiedDate'])) $this->ModifiedDate = JsonConverters::from('DateTimeOffset', $o['ModifiedDate']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->Country)) $o['Country'] = JsonConverters::to('Country', $this->Country);
        if (isset($this->MonthlyPayment)) $o['MonthlyPayment'] = $this->MonthlyPayment;
        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->ModifiedDate)) $o['ModifiedDate'] = JsonConverters::to('DateTimeOffset', $this->ModifiedDate);
        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|null */
        public ?string $Name=null,

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

        /** @description If the license type is not a standard license but instead an extra license option. An example would be sending new letter license. */
        // @ApiMember(Description="If the license type is not a standard license but instead an extra license option. An example would be sending new letter 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<LicensePrice>|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('LicensePrice', $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('LicensePrice', $this->Prices);
        return empty($o) ? new class(){} : $o;
    }
}

class IncentiveActionResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Description=null,
        /** @var IncentiveActionType|null */
        public ?IncentiveActionType $ActionType=null,
        /** @var string|null */
        public ?string $Page=null,
        /** @var string|null */
        public ?string $Segment=null,
        /** @var string|null */
        public ?string $Element=null,
        /** @var int|null */
        public ?int $LicenseTypeId=null,
        /** @var LicenseTypeQueryResponse|null */
        public ?LicenseTypeQueryResponse $SuggestedLicenseToUpgrade=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['ActionType'])) $this->ActionType = JsonConverters::from('IncentiveActionType', $o['ActionType']);
        if (isset($o['Page'])) $this->Page = $o['Page'];
        if (isset($o['Segment'])) $this->Segment = $o['Segment'];
        if (isset($o['Element'])) $this->Element = $o['Element'];
        if (isset($o['LicenseTypeId'])) $this->LicenseTypeId = $o['LicenseTypeId'];
        if (isset($o['SuggestedLicenseToUpgrade'])) $this->SuggestedLicenseToUpgrade = JsonConverters::from('LicenseTypeQueryResponse', $o['SuggestedLicenseToUpgrade']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->ActionType)) $o['ActionType'] = JsonConverters::to('IncentiveActionType', $this->ActionType);
        if (isset($this->Page)) $o['Page'] = $this->Page;
        if (isset($this->Segment)) $o['Segment'] = $this->Segment;
        if (isset($this->Element)) $o['Element'] = $this->Element;
        if (isset($this->LicenseTypeId)) $o['LicenseTypeId'] = $this->LicenseTypeId;
        if (isset($this->SuggestedLicenseToUpgrade)) $o['SuggestedLicenseToUpgrade'] = JsonConverters::to('LicenseTypeQueryResponse', $this->SuggestedLicenseToUpgrade);
        return empty($o) ? new class(){} : $o;
    }
}

// @ValidateRequest(Validator="IsAuthenticated")
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
class CreateIncentiveAction implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var IncentiveActionType|null */
        public ?IncentiveActionType $ActionType=null,
        /** @var string|null */
        public ?string $Description=null,
        /** @var string|null */
        public ?string $Page=null,
        /** @var string|null */
        public ?string $Segment=null,
        /** @var string|null */
        public ?string $Element=null,
        /** @var int|null */
        public ?int $LicenseTypeId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['ActionType'])) $this->ActionType = JsonConverters::from('IncentiveActionType', $o['ActionType']);
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['Page'])) $this->Page = $o['Page'];
        if (isset($o['Segment'])) $this->Segment = $o['Segment'];
        if (isset($o['Element'])) $this->Element = $o['Element'];
        if (isset($o['LicenseTypeId'])) $this->LicenseTypeId = $o['LicenseTypeId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->ActionType)) $o['ActionType'] = JsonConverters::to('IncentiveActionType', $this->ActionType);
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->Page)) $o['Page'] = $this->Page;
        if (isset($this->Segment)) $o['Segment'] = $this->Segment;
        if (isset($this->Element)) $o['Element'] = $this->Element;
        if (isset($this->LicenseTypeId)) $o['LicenseTypeId'] = $this->LicenseTypeId;
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateIncentiveAction 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 /superadmin/incentives/action HTTP/1.1 
Host: api.bookmore.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateIncentiveAction xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <ActionType>Upgrade</ActionType>
  <Description>String</Description>
  <Element>String</Element>
  <Id>0</Id>
  <LicenseTypeId>0</LicenseTypeId>
  <Page>String</Page>
  <Segment>String</Segment>
</CreateIncentiveAction>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<IncentiveActionResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <ActionType>Upgrade</ActionType>
  <Description>String</Description>
  <Element>String</Element>
  <Id>0</Id>
  <LicenseTypeId>0</LicenseTypeId>
  <Page>String</Page>
  <Segment>String</Segment>
  <SuggestedLicenseToUpgrade>
    <Description>String</Description>
    <Id>0</Id>
    <IsExtraLicenseOption>false</IsExtraLicenseOption>
    <Items>
      <LicenseItemsResponse>
        <AllowedItems>0</AllowedItems>
        <Id>0</Id>
        <Name>String</Name>
      </LicenseItemsResponse>
    </Items>
    <Name>String</Name>
    <PeriodOfNoticeDays>0</PeriodOfNoticeDays>
    <Prices xmlns:d3p1="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Db">
      <d3p1:LicensePrice>
        <d3p1:Country>
          <d3p1:Culture>String</d3p1:Culture>
          <d3p1:CurrencyId>String</d3p1:CurrencyId>
          <d3p1:CurrencyInfo>
            <d3p1:Active>false</d3p1:Active>
            <d3p1:CurrencySign>String</d3p1:CurrencySign>
            <d3p1:Id>String</d3p1:Id>
            <d3p1:ModifiedDate xmlns:d7p1="http://schemas.datacontract.org/2004/07/System">
              <d7p1:DateTime>0001-01-01T00:00:00Z</d7p1:DateTime>
              <d7p1:OffsetMinutes>0</d7p1:OffsetMinutes>
            </d3p1:ModifiedDate>
            <d3p1:Name>String</d3p1:Name>
          </d3p1:CurrencyInfo>
          <d3p1:Id>String</d3p1:Id>
          <d3p1:ModifiedDate xmlns:d6p1="http://schemas.datacontract.org/2004/07/System">
            <d6p1:DateTime>0001-01-01T00:00:00Z</d6p1:DateTime>
            <d6p1:OffsetMinutes>0</d6p1:OffsetMinutes>
          </d3p1:ModifiedDate>
          <d3p1:Name>String</d3p1:Name>
          <d3p1:TimeZone>String</d3p1:TimeZone>
        </d3p1:Country>
        <d3p1:CountryId>String</d3p1:CountryId>
        <d3p1:LicenseTypeId>0</d3p1:LicenseTypeId>
        <d3p1:ModifiedDate xmlns:d5p1="http://schemas.datacontract.org/2004/07/System">
          <d5p1:DateTime>0001-01-01T00:00:00Z</d5p1:DateTime>
          <d5p1:OffsetMinutes>0</d5p1:OffsetMinutes>
        </d3p1:ModifiedDate>
        <d3p1:Price>0</d3p1:Price>
      </d3p1:LicensePrice>
    </Prices>
  </SuggestedLicenseToUpgrade>
</IncentiveActionResponse>