BokaMera.API.Host

<back to all web services

UpdateAllQuantities

Requires Authentication
The following routes are available for this service:
PUT/bookings/{BookingId}/quantity/Update all quantities on a booking. Note: all quantity needs to be added, all existing quantities on the booking will be deletedUpdate all quantities on a booking. You will need to provide all quantities in this call to be added/updated. Note: all quantity needs to be added, all existing quantities on the booking will be deleted.
<?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 BookedQuantity implements JsonSerializable
{
    public function __construct(
        /** @description The quantity Id */
        // @ApiMember(Description="The quantity Id")
        /** @var int */
        public int $Id=0,

        /** @description The quantity for booked on this price category */
        // @ApiMember(Description="The quantity for booked on this price category")
        /** @var int */
        public int $Quantity=0,

        /** @description The price */
        // @ApiMember(Description="The price")
        /** @var float|null */
        public ?float $Price=null,

        /** @description The price bofore rebate codes */
        // @ApiMember(Description="The price bofore rebate codes")
        /** @var float|null */
        public ?float $PriceBeforeRebate=null,

        /** @description The price currency */
        // @ApiMember(Description="The price currency")
        /** @var string|null */
        public ?string $CurrencyId=null,

        /** @description The price sign */
        // @ApiMember(Description="The price sign")
        /** @var string|null */
        public ?string $PriceSign=null,

        /** @description The price category */
        // @ApiMember(Description="The price category")
        /** @var string|null */
        public ?string $Category=null,

        /** @description The price VAT in percent */
        // @ApiMember(Description="The price VAT in percent")
        /** @var float|null */
        public ?float $VAT=null,

        /** @description The price text to display */
        // @ApiMember(Description="The price text to display")
        /** @var string|null */
        public ?string $PriceText=null,

        /** @description If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information. */
        // @ApiMember(Description="If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.")
        /** @var bool|null */
        public ?bool $OccupiesSpot=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['Quantity'])) $this->Quantity = $o['Quantity'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['PriceBeforeRebate'])) $this->PriceBeforeRebate = $o['PriceBeforeRebate'];
        if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
        if (isset($o['PriceSign'])) $this->PriceSign = $o['PriceSign'];
        if (isset($o['Category'])) $this->Category = $o['Category'];
        if (isset($o['VAT'])) $this->VAT = $o['VAT'];
        if (isset($o['PriceText'])) $this->PriceText = $o['PriceText'];
        if (isset($o['OccupiesSpot'])) $this->OccupiesSpot = $o['OccupiesSpot'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->Quantity)) $o['Quantity'] = $this->Quantity;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->PriceBeforeRebate)) $o['PriceBeforeRebate'] = $this->PriceBeforeRebate;
        if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
        if (isset($this->PriceSign)) $o['PriceSign'] = $this->PriceSign;
        if (isset($this->Category)) $o['Category'] = $this->Category;
        if (isset($this->VAT)) $o['VAT'] = $this->VAT;
        if (isset($this->PriceText)) $o['PriceText'] = $this->PriceText;
        if (isset($this->OccupiesSpot)) $o['OccupiesSpot'] = $this->OccupiesSpot;
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="You have too low privileges to call this service", StatusCode=403)
// @ValidateRequest(Validator="IsAuthenticated")
class UpdateAllQuantities 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.")
        /** @var string|null */
        public ?string $CompanyId=null,

        /** @description Id of the booking */
        // @ApiMember(Description="Id of the booking", IsRequired=true, ParameterType="path")
        /** @var int */
        public int $BookingId=0,

        /** @description Set the number of spots you want to book. You add number of spots per price category. Multiple spots require that the service has GroupBooking enabled. Default is one spot. */
        // @ApiMember(Description="Set the number of spots you want to book. You add number of spots per price category. Multiple spots require that the service has GroupBooking enabled. Default is one spot.")
        /** @var QuantityToUpdate[]|null */
        public ?array $Quantities=null,

        /** @description Any comments to be stored in the event log. */
        // @ApiMember(Description="Any comments to be stored in the event log.")
        /** @var string|null */
        public ?string $Comments=null
    ) {
    }

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

class QuantityToUpdate implements JsonSerializable
{
    public function __construct(
        /** @description Id of the quantity */
        // @ApiMember(Description="Id of the quantity", IsRequired=true)
        /** @var int */
        public int $Id=0,

        /** @description The quantity for booked on this price category */
        // @ApiMember(Description="The quantity for booked on this price category", IsRequired=true)
        /** @var int */
        public int $Quantity=0,

        /** @description The price */
        // @ApiMember(Description="The price")
        /** @var float|null */
        public ?float $Price=null,

        /** @description The price currency */
        // @ApiMember(Description="The price currency")
        /** @var string|null */
        public ?string $CurrencyId=null,

        /** @description The price category */
        // @ApiMember(Description="The price category")
        /** @var string|null */
        public ?string $Category=null,

        /** @description The price VAT in percent */
        // @ApiMember(Description="The price VAT in percent")
        /** @var float|null */
        public ?float $VAT=null,

        /** @description If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information. */
        // @ApiMember(Description="If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.")
        /** @var bool|null */
        public ?bool $OccupiesSpot=null
    ) {
    }

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

PHP UpdateAllQuantities DTOs

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

HTTP + JSV

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

PUT /bookings/{BookingId}/quantity/ HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000,
	BookingId: 0,
	Quantities: 
	[
		{
			Id: 0,
			Quantity: 0,
			Price: 0,
			CurrencyId: String,
			Category: String,
			VAT: 0,
			OccupiesSpot: False
		}
	],
	Comments: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Id: 0,
	Quantity: 0,
	Price: 0,
	PriceBeforeRebate: 0,
	CurrencyId: String,
	PriceSign: String,
	Category: String,
	VAT: 0,
	PriceText: String,
	OccupiesSpot: False
}