BokaMera.API.Host

<back to all web services

TestDateSchedule

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/schedules/date/testTest date scheduleTest date schedule, only administrators are allowed to test schedules.
<?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 AddDateScheduleDate implements JsonSerializable
{
    public function __construct(
        /** @description The from date for the timeslot */
        // @ApiMember(Description="The from date for the timeslot", IsRequired=true)
        /** @var DateTime */
        public DateTime $From=new DateTime(),

        /** @description The to date for the timeslot */
        // @ApiMember(Description="The to date for the timeslot", IsRequired=true)
        /** @var DateTime */
        public DateTime $To=new DateTime()
    ) {
    }

    /** @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']);
    }
    
    /** @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);
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class TestDateSchedule implements ICompany, IInterval, 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 The dates for the schedule. This is the actual timeslots. */
        // @ApiMember(Description="The dates for the schedule. This is the actual timeslots.", IsRequired=true)
        /** @var array<AddDateScheduleDate>|null */
        public ?array $ScheduleDates=null,

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

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

        /** @description The Service Duration */
        // @ApiMember(Description="The Service Duration")
        /** @var int|null */
        public ?int $ServiceId=null
    ) {
    }

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

PHP TestDateSchedule DTOs

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

To embed the response in a jsonp callback, append ?callback=myCallback

HTTP + JSON

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

POST /schedules/date/test HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","ScheduleDates":[{}],"ServiceId":0}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

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