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

{"CompanyId":"00000000-0000-0000-0000-000000000000","RebateCodeId":0,"Amount":0,"Usage":0,"BookingId":0,"ChangeType":"Increase"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"RebateCodeTransactionItem":{"Id":0,"Note":"String","RebateCodeId":0,"RebateCodeSign":"String","RebateCodeTypeId":0,"RebateCodeTypeName":"String","Amount":0,"BookingId":0,"Service":{"Id":0,"Name":"String","Description":"String","Active":false},"Customer":{"Firstname":"String","Lastname":"String","Email":"String","Phone":"String","ImageUrl":"String"},"PriceSign":"String"}}