| GET | /bookingreservations/current | Get the caller's current booking reservation hold (from cookie) | Resolves the caller's active reservation hold from the bm_hold cookie so a reopened browser or a second tab can resume the same hold instead of creating a second one. Returns the full selection (including the entered personal details) when the cookie proves this browser owns the hold. 404 when there is no active hold, in which case the stale cookie is cleared. |
|---|
<?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 BookingReservationResponse 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 company id. */
// @ApiMember(Description="The company id.")
/** @var string */
public string $CompanyId='',
/** @description The reserved service id. */
// @ApiMember(Description="The reserved service id.")
/** @var int */
public int $ServiceId=0,
/** @description The reservation start. */
// @ApiMember(Description="The reservation start.")
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description The reservation end. */
// @ApiMember(Description="The reservation end.")
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description The BookingReservationStatus value. */
// @ApiMember(Description="The BookingReservationStatus value.")
/** @var int */
public int $StatusCode=0,
/** @description The BookingReservationStatus name. */
// @ApiMember(Description="The BookingReservationStatus name.")
/** @var string */
public string $StatusName='',
/** @description When the hold expires (company-local time). */
// @ApiMember(Description="When the hold expires (company-local time).")
/** @var DateTime */
public DateTime $ExpirationDatetime=new DateTime(),
/** @description The company's current time, in the same company-local frame as ExpirationDatetime. Clients compute the remaining hold as (ExpirationDatetime - ServerTime) so a countdown is correct regardless of the viewer's timezone or clock skew. */
// @ApiMember(Description="The company's current time, in the same company-local frame as ExpirationDatetime. Clients compute the remaining hold as (ExpirationDatetime - ServerTime) so a countdown is correct regardless of the viewer's timezone or clock skew.")
/** @var DateTime */
public DateTime $ServerTime=new DateTime(),
/** @description Number of reserved spots. */
// @ApiMember(Description="Number of reserved spots.")
/** @var int */
public int $NumberOfBookedSpots=0,
/** @description The computed price of the reservation, if any. */
// @ApiMember(Description="The computed price of the reservation, if any.")
/** @var float|null */
public ?float $Price=null,
/** @description The currency of the price, if any. */
// @ApiMember(Description="The currency of the price, if any.")
/** @var string */
public string $CurrencyId='',
/** @description Ids of the resources held by the reservation. */
// @ApiMember(Description="Ids of the resources held by the reservation.")
/** @var array<int>|null */
public ?array $ResourceIds=null,
/** @description The full in-progress selection payload (wizard/session state) as JSON. */
// @ApiMember(Description="The full in-progress selection payload (wizard/session state) as JSON.")
/** @var string */
public string $SelectionPayload='',
/** @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['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['ServiceId'])) $this->ServiceId = $o['ServiceId'];
if (isset($o['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
if (isset($o['StatusCode'])) $this->StatusCode = $o['StatusCode'];
if (isset($o['StatusName'])) $this->StatusName = $o['StatusName'];
if (isset($o['ExpirationDatetime'])) $this->ExpirationDatetime = JsonConverters::from('DateTime', $o['ExpirationDatetime']);
if (isset($o['ServerTime'])) $this->ServerTime = JsonConverters::from('DateTime', $o['ServerTime']);
if (isset($o['NumberOfBookedSpots'])) $this->NumberOfBookedSpots = $o['NumberOfBookedSpots'];
if (isset($o['Price'])) $this->Price = $o['Price'];
if (isset($o['CurrencyId'])) $this->CurrencyId = $o['CurrencyId'];
if (isset($o['ResourceIds'])) $this->ResourceIds = JsonConverters::fromArray('int', $o['ResourceIds']);
if (isset($o['SelectionPayload'])) $this->SelectionPayload = $o['SelectionPayload'];
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->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->ServiceId)) $o['ServiceId'] = $this->ServiceId;
if (isset($this->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
if (isset($this->StatusCode)) $o['StatusCode'] = $this->StatusCode;
if (isset($this->StatusName)) $o['StatusName'] = $this->StatusName;
if (isset($this->ExpirationDatetime)) $o['ExpirationDatetime'] = JsonConverters::to('DateTime', $this->ExpirationDatetime);
if (isset($this->ServerTime)) $o['ServerTime'] = JsonConverters::to('DateTime', $this->ServerTime);
if (isset($this->NumberOfBookedSpots)) $o['NumberOfBookedSpots'] = $this->NumberOfBookedSpots;
if (isset($this->Price)) $o['Price'] = $this->Price;
if (isset($this->CurrencyId)) $o['CurrencyId'] = $this->CurrencyId;
if (isset($this->ResourceIds)) $o['ResourceIds'] = JsonConverters::toArray('int', $this->ResourceIds);
if (isset($this->SelectionPayload)) $o['SelectionPayload'] = $this->SelectionPayload;
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="No active reservation hold for the caller", StatusCode=404)
class GetCurrentBookingReservation 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
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
return empty($o) ? new class(){} : $o;
}
}
PHP GetCurrentBookingReservation DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /bookingreservations/current HTTP/1.1 Host: testapi.bokamera.se Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<BookingReservationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<CurrencyId>String</CurrencyId>
<ExpirationDatetime>0001-01-01T00:00:00</ExpirationDatetime>
<From>0001-01-01T00:00:00</From>
<NumberOfBookedSpots>0</NumberOfBookedSpots>
<Price>0</Price>
<ResourceIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</ResourceIds>
<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>
<SelectionPayload>String</SelectionPayload>
<ServerTime>0001-01-01T00:00:00</ServerTime>
<ServiceId>0</ServiceId>
<SessionKey>00000000-0000-0000-0000-000000000000</SessionKey>
<StatusCode>0</StatusCode>
<StatusName>String</StatusName>
<To>0001-01-01T00:00:00</To>
</BookingReservationResponse>