BokaMera.API.Host

<back to all web services

GetPricesAfterRebateCode

Requires Authentication
The following routes are available for this service:
POST/rebatecodes/pricesGet the new pricesGet the new prices after applying RebateCodes
<?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 RebateCodeTypeResponse 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
    ) {
    }

    /** @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'];
    }
    
    /** @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;
        return empty($o) ? new class(){} : $o;
    }
}

class AppliedRebateCodesResponse implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $RebateCodeSign=null,
        /** @var int */
        public int $RebateCodeValue=0,
        /** @var RebateCodeTypeResponse|null */
        public ?RebateCodeTypeResponse $RebateCodeType=null,
        /** @var int */
        public int $RebateCodeId=0,
        /** @var float */
        public float $RebateAmount=0.0
    ) {
    }

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

class RebateCodePrice implements JsonSerializable
{
    public function __construct(
        /** @description Price Id */
        // @ApiMember(Description="Price Id")
        /** @var int|null */
        public ?int $PriceId=null,

        /** @var string|null */
        public ?string $PriceText=null,
        /** @var float|null */
        public ?float $PriceBeforeRebate=null,
        /** @var float|null */
        public ?float $Price=null,
        /** @var float|null */
        public ?float $VAT=null,
        /** @var array<AppliedRebateCodesResponse>|null */
        public ?array $AppliedCodes=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['PriceId'])) $this->PriceId = $o['PriceId'];
        if (isset($o['PriceText'])) $this->PriceText = $o['PriceText'];
        if (isset($o['PriceBeforeRebate'])) $this->PriceBeforeRebate = $o['PriceBeforeRebate'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['VAT'])) $this->VAT = $o['VAT'];
        if (isset($o['AppliedCodes'])) $this->AppliedCodes = JsonConverters::fromArray('AppliedRebateCodesResponse', $o['AppliedCodes']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->PriceId)) $o['PriceId'] = $this->PriceId;
        if (isset($this->PriceText)) $o['PriceText'] = $this->PriceText;
        if (isset($this->PriceBeforeRebate)) $o['PriceBeforeRebate'] = $this->PriceBeforeRebate;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->VAT)) $o['VAT'] = $this->VAT;
        if (isset($this->AppliedCodes)) $o['AppliedCodes'] = JsonConverters::toArray('AppliedRebateCodesResponse', $this->AppliedCodes);
        return empty($o) ? new class(){} : $o;
    }
}

class RebateCodePriceResponse implements JsonSerializable
{
    public function __construct(
        /** @var array<RebateCodePrice>|null */
        public ?array $RebateCodePrices=null,
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

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

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

        /** @description The service you want to get the prices with rebates on */
        // @ApiMember(Description="The service you want to get the prices with rebates on")
        /** @var int|null */
        public ?int $ServiceId=null,

        /** @description Provide this if you like to the prices with rebate code ids */
        // @ApiMember(Description="Provide this if you like to the prices with rebate code ids")
        /** @var array<int>|null */
        public ?array $RebateCodeIds=null,

        /** @description Provide this if you like to the prices with rebate code signs instead of ids */
        // @ApiMember(Description="Provide this if you like to the prices with rebate code signs instead of ids")
        /** @var array<string>|null */
        public ?array $RebateCodeSigns=null,

        /** @description Provide this if you like to calculate the prices with the provided datetime */
        // @ApiMember(Description="Provide this if you like to calculate the prices with the provided datetime", IsRequired=true)
        /** @var DateTime */
        public DateTime $DateFrom=new DateTime()
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['ServiceId'])) $this->ServiceId = $o['ServiceId'];
        if (isset($o['RebateCodeIds'])) $this->RebateCodeIds = JsonConverters::fromArray('int', $o['RebateCodeIds']);
        if (isset($o['RebateCodeSigns'])) $this->RebateCodeSigns = JsonConverters::fromArray('string', $o['RebateCodeSigns']);
        if (isset($o['DateFrom'])) $this->DateFrom = JsonConverters::from('DateTime', $o['DateFrom']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->ServiceId)) $o['ServiceId'] = $this->ServiceId;
        if (isset($this->RebateCodeIds)) $o['RebateCodeIds'] = JsonConverters::toArray('int', $this->RebateCodeIds);
        if (isset($this->RebateCodeSigns)) $o['RebateCodeSigns'] = JsonConverters::toArray('string', $this->RebateCodeSigns);
        if (isset($this->DateFrom)) $o['DateFrom'] = JsonConverters::to('DateTime', $this->DateFrom);
        return empty($o) ? new class(){} : $o;
    }
}

PHP GetPricesAfterRebateCode DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /rebatecodes/prices HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"ServiceId":0,"RebateCodeIds":[0],"RebateCodeSigns":["String"]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"RebateCodePrices":[{"PriceId":0,"PriceText":"String","PriceBeforeRebate":0,"Price":0,"VAT":0,"AppliedCodes":[{"RebateCodeSign":"String","RebateCodeValue":0,"RebateCodeType":{"Id":0,"Name":"String","Description":"String"},"RebateCodeId":0,"RebateAmount":0}]}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}