BokaMera.API.Host

<back to all web services

CollidingBookingQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
GET/timeexceptions/collidingeventsSearches for collisions with existing bookings of the resourceSearches for existing bookings and investigates if a proposed time exception would collide with them, if so, the bookings should be unbooked to be able to create the time exception. A time exception must be either recurring (DaysOfWeek, ExceptionFromTime, ExceptionToTime is set) or non recurring (From and To are set).
<?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};


enum BookingStatusEnum : int
{
    case Booked = 1;
    case Unbooked = 2;
    case Reserved = 3;
    case Canceled = 4;
    case AwaitingPayment = 5;
    case AwaitingPaymentNoTimeLimit = 6;
    case Payed = 7;
    case AwaitingPaymentRequestFromAdmin = 8;
    case AwaitingPaymentFromProvider = 9;
    case Invoiced = 10;
}

class BookedCustomer 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 $FacebookUserName=null,
        /** @var string|null */
        public ?string $ImageUrl=null,
        /** @var string|null */
        public ?string $CorporateIdentityNumber=null,
        /** @var string|null */
        public ?string $InvoiceAddress1=null,
        /** @var string|null */
        public ?string $InvoiceAddress2=null,
        /** @var string|null */
        public ?string $InvoiceCity=null,
        /** @var string|null */
        public ?string $InvoicePostalCode=null,
        /** @var string|null */
        public ?string $InvoiceCountryCode=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['FacebookUserName'])) $this->FacebookUserName = $o['FacebookUserName'];
        if (isset($o['ImageUrl'])) $this->ImageUrl = $o['ImageUrl'];
        if (isset($o['CorporateIdentityNumber'])) $this->CorporateIdentityNumber = $o['CorporateIdentityNumber'];
        if (isset($o['InvoiceAddress1'])) $this->InvoiceAddress1 = $o['InvoiceAddress1'];
        if (isset($o['InvoiceAddress2'])) $this->InvoiceAddress2 = $o['InvoiceAddress2'];
        if (isset($o['InvoiceCity'])) $this->InvoiceCity = $o['InvoiceCity'];
        if (isset($o['InvoicePostalCode'])) $this->InvoicePostalCode = $o['InvoicePostalCode'];
        if (isset($o['InvoiceCountryCode'])) $this->InvoiceCountryCode = $o['InvoiceCountryCode'];
    }
    
    /** @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->FacebookUserName)) $o['FacebookUserName'] = $this->FacebookUserName;
        if (isset($this->ImageUrl)) $o['ImageUrl'] = $this->ImageUrl;
        if (isset($this->CorporateIdentityNumber)) $o['CorporateIdentityNumber'] = $this->CorporateIdentityNumber;
        if (isset($this->InvoiceAddress1)) $o['InvoiceAddress1'] = $this->InvoiceAddress1;
        if (isset($this->InvoiceAddress2)) $o['InvoiceAddress2'] = $this->InvoiceAddress2;
        if (isset($this->InvoiceCity)) $o['InvoiceCity'] = $this->InvoiceCity;
        if (isset($this->InvoicePostalCode)) $o['InvoicePostalCode'] = $this->InvoicePostalCode;
        if (isset($this->InvoiceCountryCode)) $o['InvoiceCountryCode'] = $this->InvoiceCountryCode;
        return empty($o) ? new class(){} : $o;
    }
}

class GroupBookingSettings implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $Active=null,
        /** @var int */
        public int $Min=0,
        /** @var int */
        public int $Max=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['Min'])) $this->Min = $o['Min'];
        if (isset($o['Max'])) $this->Max = $o['Max'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->Min)) $o['Min'] = $this->Min;
        if (isset($this->Max)) $o['Max'] = $this->Max;
        return empty($o) ? new class(){} : $o;
    }
}

class MultipleResourceSettings implements JsonSerializable
{
    public function __construct(
        /** @var bool|null */
        public ?bool $Active=null,
        /** @var int */
        public int $Min=0,
        /** @var int */
        public int $Max=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Active'])) $this->Active = $o['Active'];
        if (isset($o['Min'])) $this->Min = $o['Min'];
        if (isset($o['Max'])) $this->Max = $o['Max'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Active)) $o['Active'] = $this->Active;
        if (isset($this->Min)) $o['Min'] = $this->Min;
        if (isset($this->Max)) $o['Max'] = $this->Max;
        return empty($o) ? new class(){} : $o;
    }
}

class ServiceInfoResponse 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 string|null */
        public ?string $ImageUrl=null,
        /** @var int|null */
        public ?int $LengthInMinutes=null,
        /** @var int */
        public int $MaxNumberOfSpotsPerBooking=0,
        /** @var int */
        public int $MinNumberOfSpotsPerBooking=0,
        /** @var GroupBookingSettings|null */
        public ?GroupBookingSettings $GroupBooking=null,
        /** @var MultipleResourceSettings|null */
        public ?MultipleResourceSettings $MultipleResource=null,
        /** @var bool|null */
        public ?bool $IsGroupBooking=null,
        /** @var bool|null */
        public ?bool $IsPaymentEnabled=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['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
        if (isset($o['LengthInMinutes'])) $this->LengthInMinutes = $o['LengthInMinutes'];
        if (isset($o['MaxNumberOfSpotsPerBooking'])) $this->MaxNumberOfSpotsPerBooking = $o['MaxNumberOfSpotsPerBooking'];
        if (isset($o['MinNumberOfSpotsPerBooking'])) $this->MinNumberOfSpotsPerBooking = $o['MinNumberOfSpotsPerBooking'];
        if (isset($o['GroupBooking'])) $this->GroupBooking = JsonConverters::from('GroupBookingSettings', $o['GroupBooking']);
        if (isset($o['MultipleResource'])) $this->MultipleResource = JsonConverters::from('MultipleResourceSettings', $o['MultipleResource']);
        if (isset($o['IsGroupBooking'])) $this->IsGroupBooking = $o['IsGroupBooking'];
        if (isset($o['IsPaymentEnabled'])) $this->IsPaymentEnabled = $o['IsPaymentEnabled'];
    }
    
    /** @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->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
        if (isset($this->LengthInMinutes)) $o['LengthInMinutes'] = $this->LengthInMinutes;
        if (isset($this->MaxNumberOfSpotsPerBooking)) $o['MaxNumberOfSpotsPerBooking'] = $this->MaxNumberOfSpotsPerBooking;
        if (isset($this->MinNumberOfSpotsPerBooking)) $o['MinNumberOfSpotsPerBooking'] = $this->MinNumberOfSpotsPerBooking;
        if (isset($this->GroupBooking)) $o['GroupBooking'] = JsonConverters::to('GroupBookingSettings', $this->GroupBooking);
        if (isset($this->MultipleResource)) $o['MultipleResource'] = JsonConverters::to('MultipleResourceSettings', $this->MultipleResource);
        if (isset($this->IsGroupBooking)) $o['IsGroupBooking'] = $this->IsGroupBooking;
        if (isset($this->IsPaymentEnabled)) $o['IsPaymentEnabled'] = $this->IsPaymentEnabled;
        return empty($o) ? new class(){} : $o;
    }
}

class BookingIntervalResponse implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @var string */
        public string $CompanyId='',
        /** @var DateTime */
        public DateTime $From=new DateTime(),
        /** @var DateTime */
        public DateTime $To=new DateTime(),
        /** @var BookingStatusEnum|null */
        public ?BookingStatusEnum $Status=null,
        /** @var int */
        public int $StatusId=0,
        /** @var string|null */
        public ?string $StatusName=null,
        /** @var BookedCustomer|null */
        public ?BookedCustomer $Customer=null,
        /** @var ServiceInfoResponse|null */
        public ?ServiceInfoResponse $Service=null,
        /** @var DateTime */
        public DateTime $CreatedDate=new DateTime()
    ) {
    }

    /** @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['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
        if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
        if (isset($o['Status'])) $this->Status = JsonConverters::from('BookingStatusEnum', $o['Status']);
        if (isset($o['StatusId'])) $this->StatusId = $o['StatusId'];
        if (isset($o['StatusName'])) $this->StatusName = $o['StatusName'];
        if (isset($o['Customer'])) $this->Customer = JsonConverters::from('BookedCustomer', $o['Customer']);
        if (isset($o['Service'])) $this->Service = JsonConverters::from('ServiceInfoResponse', $o['Service']);
        if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
    }
    
    /** @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->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
        if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
        if (isset($this->Status)) $o['Status'] = JsonConverters::to('BookingStatusEnum', $this->Status);
        if (isset($this->StatusId)) $o['StatusId'] = $this->StatusId;
        if (isset($this->StatusName)) $o['StatusName'] = $this->StatusName;
        if (isset($this->Customer)) $o['Customer'] = JsonConverters::to('BookedCustomer', $this->Customer);
        if (isset($this->Service)) $o['Service'] = JsonConverters::to('ServiceInfoResponse', $this->Service);
        if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
        return empty($o) ? new class(){} : $o;
    }
}

class CollidingBookingQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description Resource id of the resource that owns this exception */
        // @ApiMember(Description="Resource id of the resource that owns this exception")
        /** @var int[]|null */
        public ?array $ResourceIds=null,

        /** @description A list of bookings that would collide with the time exception */
        // @ApiMember(Description="A list of bookings that would collide with the time exception")
        /** @var array<BookingIntervalResponse>|null */
        public ?array $Bookings=null,

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

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

// @ApiResponse(Description="The request parameters was not valid", StatusCode=400)
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="You have too low privilegies to call this service", StatusCode=403)
// @ValidateRequest(Validator="IsAuthenticated")
class CollidingBookingQuery implements 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 Resource ids of the resource that should be matched against booked events */
        // @ApiMember(Description="Resource ids of the resource that should be matched against booked events")
        /** @var int[]|null */
        public ?array $ResourceIds=null,

        /** @description Time exception starting date */
        // @ApiMember(Description="Time exception starting date")
        /** @var DateTime */
        public DateTime $From=new DateTime(),

        /** @description Time exception ending date */
        // @ApiMember(Description="Time exception ending date")
        /** @var DateTime */
        public DateTime $To=new DateTime(),

        /** @description This value indicates the time of day when the time exception begins. Example: 10:00. If Recurring this will be the startime for each recurring day. */
        // @ApiMember(Description="This value indicates the time of day when the time exception begins. Example: 10:00. If Recurring this will be the startime for each recurring day.")
        /** @var DateInterval|null */
        public ?DateInterval $FromTime=null,

        /** @description This value indicates the time of day when the time exception ends. Example: 12:00. If Recurring this will be the endtime for each recurring day. */
        // @ApiMember(Description="This value indicates the time of day when the time exception ends. Example: 12:00. If Recurring this will be the endtime for each recurring day.")
        /** @var DateInterval|null */
        public ?DateInterval $ToTime=null,

        /** @description A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday */
        // @ApiMember(Description="A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday")
        /** @var int[]|null */
        public ?array $DaysOfWeek=null,

        /** @description If you want to include the service information for the booking */
        // @ApiMember(DataType="boolean", Description="If you want to include the service information for the booking", ParameterType="query")
        /** @var bool|null */
        public ?bool $IncludeServiceInformation=null,

        /** @description If you want to include the customer information for the booking */
        // @ApiMember(DataType="boolean", Description="If you want to include the customer information for the booking", ParameterType="query")
        /** @var bool|null */
        public ?bool $IncludeCustomerInformation=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['ResourceIds'])) $this->ResourceIds = JsonConverters::fromArray('int', $o['ResourceIds']);
        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['FromTime'])) $this->FromTime = JsonConverters::from('DateInterval', $o['FromTime']);
        if (isset($o['ToTime'])) $this->ToTime = JsonConverters::from('DateInterval', $o['ToTime']);
        if (isset($o['DaysOfWeek'])) $this->DaysOfWeek = JsonConverters::fromArray('int', $o['DaysOfWeek']);
        if (isset($o['IncludeServiceInformation'])) $this->IncludeServiceInformation = $o['IncludeServiceInformation'];
        if (isset($o['IncludeCustomerInformation'])) $this->IncludeCustomerInformation = $o['IncludeCustomerInformation'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->ResourceIds)) $o['ResourceIds'] = JsonConverters::toArray('int', $this->ResourceIds);
        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->FromTime)) $o['FromTime'] = JsonConverters::to('DateInterval', $this->FromTime);
        if (isset($this->ToTime)) $o['ToTime'] = JsonConverters::to('DateInterval', $this->ToTime);
        if (isset($this->DaysOfWeek)) $o['DaysOfWeek'] = JsonConverters::toArray('int', $this->DaysOfWeek);
        if (isset($this->IncludeServiceInformation)) $o['IncludeServiceInformation'] = $this->IncludeServiceInformation;
        if (isset($this->IncludeCustomerInformation)) $o['IncludeCustomerInformation'] = $this->IncludeCustomerInformation;
        return empty($o) ? new class(){} : $o;
    }
}

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

GET /timeexceptions/collidingevents HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ResourceIds":[0],"Bookings":[{"Id":0,"Status":"Booked","StatusId":0,"StatusName":"String","Customer":{"Firstname":"String","Lastname":"String","Email":"String","Phone":"String","FacebookUserName":"String","ImageUrl":"String","CorporateIdentityNumber":"String","InvoiceAddress1":"String","InvoiceAddress2":"String","InvoiceCity":"String","InvoicePostalCode":"String","InvoiceCountryCode":"String"},"Service":{"Id":0,"Name":"String","Description":"String","LengthInMinutes":0,"MaxNumberOfSpotsPerBooking":0,"MinNumberOfSpotsPerBooking":0,"GroupBooking":{"Active":false,"Min":0,"Max":0},"MultipleResource":{"Active":false,"Min":0,"Max":0},"IsGroupBooking":false,"IsPaymentEnabled":false}}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}