BokaMera.API.Host

<back to all web services

NextFreeTimeQuery

The following routes are available for this service:
GET/services/{ServiceId}/nextfreetimeGet the next available time for the serviceGet the next available time for the service
<?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 ExceptionText implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Reason=null,
        /** @var string|null */
        public ?string $ReasonPublic=null
    ) {
    }

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

class AvailableTimesSum implements IAvailableTime, JsonSerializable
{
    public function __construct(
        /** @var DateTime */
        public DateTime $From=new DateTime(),
        /** @var DateTime */
        public DateTime $To=new DateTime(),
        /** @var int */
        public int $Free=0,
        /** @var int */
        public int $FreeSpots=0,
        /** @var array<ExceptionText>|null */
        public ?array $ExceptionTexts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        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['Free'])) $this->Free = $o['Free'];
        if (isset($o['FreeSpots'])) $this->FreeSpots = $o['FreeSpots'];
        if (isset($o['ExceptionTexts'])) $this->ExceptionTexts = JsonConverters::fromArray('ExceptionText', $o['ExceptionTexts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        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->Free)) $o['Free'] = $this->Free;
        if (isset($this->FreeSpots)) $o['FreeSpots'] = $this->FreeSpots;
        if (isset($this->ExceptionTexts)) $o['ExceptionTexts'] = JsonConverters::toArray('ExceptionText', $this->ExceptionTexts);
        return empty($o) ? new class(){} : $o;
    }
}

class AvailableTimesResponse implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $CompanyId='',
        /** @var int */
        public int $ServiceId=0,
        /** @var string|null */
        public ?string $TimesFreeTextSingle=null,
        /** @var string|null */
        public ?string $TimesFreeTextMultiple=null,
        /** @var array<AvailableTimesSum>|null */
        public ?array $Times=null
    ) {
    }

    /** @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['TimesFreeTextSingle'])) $this->TimesFreeTextSingle = $o['TimesFreeTextSingle'];
        if (isset($o['TimesFreeTextMultiple'])) $this->TimesFreeTextMultiple = $o['TimesFreeTextMultiple'];
        if (isset($o['Times'])) $this->Times = JsonConverters::fromArray('AvailableTimesSum', $o['Times']);
    }
    
    /** @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->TimesFreeTextSingle)) $o['TimesFreeTextSingle'] = $this->TimesFreeTextSingle;
        if (isset($this->TimesFreeTextMultiple)) $o['TimesFreeTextMultiple'] = $this->TimesFreeTextMultiple;
        if (isset($this->Times)) $o['Times'] = JsonConverters::toArray('AvailableTimesSum', $this->Times);
        return empty($o) ? new class(){} : $o;
    }
}

class AvailableTimesResourceTypeResource implements JsonSerializable
{
    public function __construct(
        /** @description The resourcetype id */
        // @ApiMember(Description="The resourcetype id")
        /** @var int */
        public int $ResourceTypeId=0,

        /** @description The resource id */
        // @ApiMember(Description="The resource id")
        /** @var int */
        public int $ResourceId=0
    ) {
    }

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

class NextFreeTimeQuery implements IInterval, JsonSerializable
{
    public function __construct(
        /** @description Company to show available time for */
        // @ApiMember(Description="Company to show available time for", ParameterType="query")
        /** @var string|null */
        public ?string $CompanyId=null,

        /** @description Service id */
        // @ApiMember(Description="Service id", IsRequired=true, ParameterType="path")
        /** @var int */
        public int $ServiceId=0,

        /** @description From what datetime to search available times */
        // @ApiMember(DataType="dateTime", Description="From what datetime to search available times", IsRequired=true, ParameterType="query")
        /** @var DateTime */
        public DateTime $From=new DateTime(),

        /** @description To what datetime to show available times. Optional, if no datetime is set it will search one year */
        // @ApiMember(DataType="dateTime", Description="To what datetime to show available times. Optional, if no datetime is set it will search one year", IsRequired=true, ParameterType="query")
        /** @var DateTime */
        public DateTime $To=new DateTime(),

        /** @description Here you can select one of the resource in each resource type connected to the service, if none is selected it will show available times for all */
        // @ApiMember(Description="Here you can select one of the resource in each resource type connected to the service, if none is selected it will show available times for all", ParameterType="query")
        /** @var array<AvailableTimesResourceTypeResource>|null */
        public ?array $Resources=null,

        /** @description Here you select number of resources to book (in each resource type). Default is 1. */
        // @ApiMember(Description="Here you select number of resources to book (in each resource type). Default is 1.", ParameterType="query")
        /** @var int */
        public int $NumberOfResources=0,

        /** @description The duration you want to book. Needs to withing the service Min and Max. If not set it will use the service duration */
        // @ApiMember(DataType="bool", Description="The duration you want to book. Needs to withing the service Min and Max. If not set it will use the service duration", ParameterType="query")
        /** @var int|null */
        public ?int $Duration=null,

        /** @description If you want to include the connected resource types and resources */
        // @ApiMember(Description="If you want to include the connected resource types and resources", ParameterType="query")
        /** @var bool|null */
        public ?bool $ShowPerResource=null
    ) {
    }

    /** @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['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
        if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
        if (isset($o['Resources'])) $this->Resources = JsonConverters::fromArray('AvailableTimesResourceTypeResource', $o['Resources']);
        if (isset($o['NumberOfResources'])) $this->NumberOfResources = $o['NumberOfResources'];
        if (isset($o['Duration'])) $this->Duration = $o['Duration'];
        if (isset($o['ShowPerResource'])) $this->ShowPerResource = $o['ShowPerResource'];
    }
    
    /** @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->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
        if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
        if (isset($this->Resources)) $o['Resources'] = JsonConverters::toArray('AvailableTimesResourceTypeResource', $this->Resources);
        if (isset($this->NumberOfResources)) $o['NumberOfResources'] = $this->NumberOfResources;
        if (isset($this->Duration)) $o['Duration'] = $this->Duration;
        if (isset($this->ShowPerResource)) $o['ShowPerResource'] = $this->ShowPerResource;
        return empty($o) ? new class(){} : $o;
    }
}

PHP NextFreeTimeQuery 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 /services/{ServiceId}/nextfreetime HTTP/1.1 
Host: testapi.bokamera.se 
Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"ServiceId":0,"TimesFreeTextSingle":"String","TimesFreeTextMultiple":"String","Times":[{"Free":0,"FreeSpots":0}]}