BokaMera.API.Host

<back to all web services

CreateRebateCodeTransaction

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/rebatecodes/transactionsCreate transaction for the rebate codeCreate transaction for the rebate code
<?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 RebateCodeServiceResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $Description=null,
        /** @var bool|null */
        public ?bool $Active=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['Active'])) $this->Active = $o['Active'];
    }
    
    /** @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->Active)) $o['Active'] = $this->Active;
        return empty($o) ? new class(){} : $o;
    }
}

class RebateCodeCustomerResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $Id='',
        /** @var string|null */
        public ?string $Firstname=null,
        /** @var string|null */
        public ?string $Lastname=null,
        /** @var string|null */
        public ?string $Email=null,
        /** @var string|null */
        public ?string $Phone=null,
        /** @var string|null */
        public ?string $ImageUrl=null
    ) {
    }

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

class RebateCodeTransactionQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string */
        public string $CompanyId='',
        /** @var string|null */
        public ?string $Note=null,
        /** @var int */
        public int $RebateCodeId=0,
        /** @var string|null */
        public ?string $RebateCodeSign=null,
        /** @var int|null */
        public ?int $RebateCodeTypeId=null,
        /** @var string|null */
        public ?string $RebateCodeTypeName=null,
        /** @var float */
        public float $Amount=0.0,
        /** @var int|null */
        public ?int $BookingId=null,
        /** @var DateTime */
        public DateTime $UpdatedDate=new DateTime(),
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime(),
        /** @var RebateCodeServiceResponse|null */
        public ?RebateCodeServiceResponse $Service=null,
        /** @var RebateCodeCustomerResponse|null */
        public ?RebateCodeCustomerResponse $Customer=null,
        /** @var string|null */
        public ?string $PriceSign=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['Note'])) $this->Note = $o['Note'];
        if (isset($o['RebateCodeId'])) $this->RebateCodeId = $o['RebateCodeId'];
        if (isset($o['RebateCodeSign'])) $this->RebateCodeSign = $o['RebateCodeSign'];
        if (isset($o['RebateCodeTypeId'])) $this->RebateCodeTypeId = $o['RebateCodeTypeId'];
        if (isset($o['RebateCodeTypeName'])) $this->RebateCodeTypeName = $o['RebateCodeTypeName'];
        if (isset($o['Amount'])) $this->Amount = $o['Amount'];
        if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
        if (isset($o['UpdatedDate'])) $this->UpdatedDate = JsonConverters::from('DateTime', $o['UpdatedDate']);
        if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
        if (isset($o['Service'])) $this->Service = JsonConverters::from('RebateCodeServiceResponse', $o['Service']);
        if (isset($o['Customer'])) $this->Customer = JsonConverters::from('RebateCodeCustomerResponse', $o['Customer']);
        if (isset($o['PriceSign'])) $this->PriceSign = $o['PriceSign'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->Note)) $o['Note'] = $this->Note;
        if (isset($this->RebateCodeId)) $o['RebateCodeId'] = $this->RebateCodeId;
        if (isset($this->RebateCodeSign)) $o['RebateCodeSign'] = $this->RebateCodeSign;
        if (isset($this->RebateCodeTypeId)) $o['RebateCodeTypeId'] = $this->RebateCodeTypeId;
        if (isset($this->RebateCodeTypeName)) $o['RebateCodeTypeName'] = $this->RebateCodeTypeName;
        if (isset($this->Amount)) $o['Amount'] = $this->Amount;
        if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
        if (isset($this->UpdatedDate)) $o['UpdatedDate'] = JsonConverters::to('DateTime', $this->UpdatedDate);
        if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
        if (isset($this->Service)) $o['Service'] = JsonConverters::to('RebateCodeServiceResponse', $this->Service);
        if (isset($this->Customer)) $o['Customer'] = JsonConverters::to('RebateCodeCustomerResponse', $this->Customer);
        if (isset($this->PriceSign)) $o['PriceSign'] = $this->PriceSign;
        return empty($o) ? new class(){} : $o;
    }
}

class RebateCodeTransactionResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var RebateCodeTransactionQueryResponse|null */
        public ?RebateCodeTransactionQueryResponse $RebateCodeTransactionItem=null
    ) {
    }

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

enum AmountChangeType : string
{
    case Increase = 'Increase';
    case Decrease = 'Decrease';
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateRebateCodeTransaction implements JsonSerializable
{
    public function __construct(
        /** @description  */
        // @ApiMember(Description="", IsRequired=true)
        /** @var string */
        public string $CompanyId='',

        /** @description Rebate code id to which you wish to add transaction */
        // @ApiMember(Description="Rebate code id to which you wish to add transaction", IsRequired=true)
        /** @var int */
        public int $RebateCodeId=0,

        // @ApiMember(IsRequired=true)
        /** @var float */
        public float $Amount=0.0,

        // @ApiMember(IsRequired=true)
        /** @var int */
        public int $Usage=0,

        // @ApiMember()
        /** @var int|null */
        public ?int $BookingId=null,

        /** @description If you want to Increase = 0 or Decrease = 1 the value */
        // @ApiMember(Description="If you want to Increase = 0 or Decrease = 1 the value", IsRequired=true)
        /** @var AmountChangeType|null */
        public ?AmountChangeType $ChangeType=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['RebateCodeId'])) $this->RebateCodeId = $o['RebateCodeId'];
        if (isset($o['Amount'])) $this->Amount = $o['Amount'];
        if (isset($o['Usage'])) $this->Usage = $o['Usage'];
        if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
        if (isset($o['ChangeType'])) $this->ChangeType = JsonConverters::from('AmountChangeType', $o['ChangeType']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->RebateCodeId)) $o['RebateCodeId'] = $this->RebateCodeId;
        if (isset($this->Amount)) $o['Amount'] = $this->Amount;
        if (isset($this->Usage)) $o['Usage'] = $this->Usage;
        if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
        if (isset($this->ChangeType)) $o['ChangeType'] = JsonConverters::to('AmountChangeType', $this->ChangeType);
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateRebateCodeTransaction 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 /rebatecodes/transactions HTTP/1.1 
Host: api.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateRebateCodeTransaction xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <Amount>0</Amount>
  <BookingId>0</BookingId>
  <ChangeType>Increase</ChangeType>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <RebateCodeId>0</RebateCodeId>
  <Usage>0</Usage>
</CreateRebateCodeTransaction>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<RebateCodeTransactionResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <RebateCodeTransactionItem>
    <Amount>0</Amount>
    <BookingId>0</BookingId>
    <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
    <CreatedDate>0001-01-01T00:00:00</CreatedDate>
    <Customer>
      <Email>String</Email>
      <Firstname>String</Firstname>
      <Id>00000000-0000-0000-0000-000000000000</Id>
      <ImageUrl>String</ImageUrl>
      <Lastname>String</Lastname>
      <Phone>String</Phone>
    </Customer>
    <Id>0</Id>
    <Note>String</Note>
    <PriceSign>String</PriceSign>
    <RebateCodeId>0</RebateCodeId>
    <RebateCodeSign>String</RebateCodeSign>
    <RebateCodeTypeId>0</RebateCodeTypeId>
    <RebateCodeTypeName>String</RebateCodeTypeName>
    <Service>
      <Active>false</Active>
      <Description>String</Description>
      <Id>0</Id>
      <Name>String</Name>
    </Service>
    <UpdatedDate>0001-01-01T00:00:00</UpdatedDate>
  </RebateCodeTransactionItem>
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
      </d2p1:ResponseError>
    </d2p1:Errors>
    <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </d2p1:Meta>
  </ResponseStatus>
</RebateCodeTransactionResponse>