BokaMera.API.Host

<back to all web services

CommitBookingReservation

The following routes are available for this service:
POST/bookingreservations/{SessionKey}/commitCommit a booking reservationCommits a reservation. If the service has no payment or the final price is zero the reservation is converted to a real booking synchronously and PaymentRequired is false. Otherwise the reservation is moved to AwaitingPayment and PaymentRequired is true.
<?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 CommitBookingReservationResponse implements JsonSerializable
{
    public function __construct(
        /** @description The opaque session key that identifies the reservation. */
        // @ApiMember(Description="The opaque session key that identifies the reservation.")
        /** @var string */
        public string $SessionKey='',

        /** @description The BookingReservationStatus value after commit. */
        // @ApiMember(Description="The BookingReservationStatus value after commit.")
        /** @var int */
        public int $StatusCode=0,

        /** @description The BookingReservationStatus name after commit. */
        // @ApiMember(Description="The BookingReservationStatus name after commit.")
        /** @var string */
        public string $StatusName='',

        /** @description True when the customer still needs to pay (reservation moved to AwaitingPayment). */
        // @ApiMember(Description="True when the customer still needs to pay (reservation moved to AwaitingPayment).")
        /** @var bool|null */
        public ?bool $PaymentRequired=null,

        /** @description The created booking id, set when the reservation was converted without payment. */
        // @ApiMember(Description="The created booking id, set when the reservation was converted without payment.")
        /** @var int|null */
        public ?int $BookingId=null,

        /** @description The computed final price of the reservation, if any. */
        // @ApiMember(Description="The computed final price of the reservation, if any.")
        /** @var float|null */
        public ?float $Price=null,

        /** @description The reservation payable reference to use as the checkout InternalReferenceId when PaymentRequired is true. */
        // @ApiMember(Description="The reservation payable reference to use as the checkout InternalReferenceId when PaymentRequired is true.")
        /** @var string */
        public string $InternalReferenceId='',

        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['SessionKey'])) $this->SessionKey = $o['SessionKey'];
        if (isset($o['StatusCode'])) $this->StatusCode = $o['StatusCode'];
        if (isset($o['StatusName'])) $this->StatusName = $o['StatusName'];
        if (isset($o['PaymentRequired'])) $this->PaymentRequired = $o['PaymentRequired'];
        if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
        if (isset($o['Price'])) $this->Price = $o['Price'];
        if (isset($o['InternalReferenceId'])) $this->InternalReferenceId = $o['InternalReferenceId'];
        if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->SessionKey)) $o['SessionKey'] = $this->SessionKey;
        if (isset($this->StatusCode)) $o['StatusCode'] = $this->StatusCode;
        if (isset($this->StatusName)) $o['StatusName'] = $this->StatusName;
        if (isset($this->PaymentRequired)) $o['PaymentRequired'] = $this->PaymentRequired;
        if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
        if (isset($this->Price)) $o['Price'] = $this->Price;
        if (isset($this->InternalReferenceId)) $o['InternalReferenceId'] = $this->InternalReferenceId;
        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)
// @ApiResponse(Description="No reservation found for the given session key", StatusCode=404)
// @ApiResponse(Description="The selected slot is no longer available", StatusCode=409)
class CommitBookingReservation implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The opaque session key that identifies the reservation. */
        // @ApiMember(Description="The opaque session key that identifies the reservation.", IsRequired=true, ParameterType="path")
        /** @var string */
        public string $SessionKey='',

        /** @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 Rebate codes to apply when computing the final price. */
        // @ApiMember(Description="Rebate codes to apply when computing the final price.")
        /** @var array<int>|null */
        public ?array $RebateCodeIds=null
    ) {
    }

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

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

POST /bookingreservations/{SessionKey}/commit HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000,
	RebateCodeIds: 
	[
		0
	]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	StatusCode: 0,
	StatusName: String,
	PaymentRequired: False,
	BookingId: 0,
	Price: 0,
	InternalReferenceId: String,
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}