BokaMera.API.Host

<back to all web services

CompanyIncentiveQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, bookingsupplier-administrator-read, superadmin
The following routes are available for this service:
GET/companies/{CompanyId}/incentivesIt gets either incentives which are not read or engaged by the current company/administrator.
<?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 BaseModel implements JsonSerializable
{
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        return empty($o) ? new class(){} : $o;
    }
}

enum IncentiveActionType : int
{
    case Upgrade = 1;
    case AddOn = 2;
    case Information = 3;
}

class IncentiveAction extends BaseModel implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @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
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['Id'])) $this->Id = $o['Id'];
        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'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->Id)) $o['Id'] = $this->Id;
        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;
        return empty($o) ? new class(){} : $o;
    }
}

class CompanyIncentiveResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Heading=null,
        /** @var string|null */
        public ?string $StorageUrl=null,
        /** @var string|null */
        public ?string $SuccessButtonText=null,
        /** @var int */
        public int $ActionId=0,
        /** @var int */
        public int $InitialDelayInSeconds=0,
        /** @var int|null */
        public ?int $MaxDisplayCount=null,
        /** @var DateTime */
        public DateTime $ValidFrom=new DateTime(),
        /** @var DateTime */
        public DateTime $ValidTo=new DateTime(),
        /** @var IncentiveAction|null */
        public ?IncentiveAction $Action=null,
        /** @var string|null */
        public ?string $Payload=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Heading'])) $this->Heading = $o['Heading'];
        if (isset($o['StorageUrl'])) $this->StorageUrl = $o['StorageUrl'];
        if (isset($o['SuccessButtonText'])) $this->SuccessButtonText = $o['SuccessButtonText'];
        if (isset($o['ActionId'])) $this->ActionId = $o['ActionId'];
        if (isset($o['InitialDelayInSeconds'])) $this->InitialDelayInSeconds = $o['InitialDelayInSeconds'];
        if (isset($o['MaxDisplayCount'])) $this->MaxDisplayCount = $o['MaxDisplayCount'];
        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['Action'])) $this->Action = JsonConverters::from('IncentiveAction', $o['Action']);
        if (isset($o['Payload'])) $this->Payload = $o['Payload'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Heading)) $o['Heading'] = $this->Heading;
        if (isset($this->StorageUrl)) $o['StorageUrl'] = $this->StorageUrl;
        if (isset($this->SuccessButtonText)) $o['SuccessButtonText'] = $this->SuccessButtonText;
        if (isset($this->ActionId)) $o['ActionId'] = $this->ActionId;
        if (isset($this->InitialDelayInSeconds)) $o['InitialDelayInSeconds'] = $this->InitialDelayInSeconds;
        if (isset($this->MaxDisplayCount)) $o['MaxDisplayCount'] = $this->MaxDisplayCount;
        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->Action)) $o['Action'] = JsonConverters::to('IncentiveAction', $this->Action);
        if (isset($this->Payload)) $o['Payload'] = $this->Payload;
        return empty($o) ? new class(){} : $o;
    }
}

class CompanyIncentivesQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @var array<CompanyIncentiveResponse>|null */
        public ?array $Incentives=null,
        /** @var string */
        public string $CompanyId=''
    ) {
    }

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

// @ValidateRequest(Validator="IsAuthenticated")
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
class CompanyIncentiveQuery 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.", IsRequired=true, ParameterType="path")
        /** @var string */
        public string $CompanyId=''
    ) {
    }

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

PHP CompanyIncentiveQuery 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.

GET /companies/{CompanyId}/incentives HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<CompanyIncentivesQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <Incentives i:nil="true" />
</CompanyIncentivesQueryResponse>