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 .xml suffix or ?format=xml

HTTP + XML

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: api.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<TestDateSchedule 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>
  <From>0001-01-01T00:00:00</From>
  <ScheduleDates>
    <AddDateScheduleDate>
      <From>0001-01-01T00:00:00</From>
      <To>0001-01-01T00:00:00</To>
    </AddDateScheduleDate>
  </ScheduleDates>
  <ServiceId>0</ServiceId>
  <To>0001-01-01T00:00:00</To>
</TestDateSchedule>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<AvailableTimesResponse 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>
  <ServiceId>0</ServiceId>
  <Times>
    <AvailableTimesSum>
      <ExceptionTexts i:nil="true" />
      <Free>0</Free>
      <FreeSpots>0</FreeSpots>
      <From>0001-01-01T00:00:00</From>
      <To>0001-01-01T00:00:00</To>
    </AvailableTimesSum>
  </Times>
  <TimesFreeTextMultiple>String</TimesFreeTextMultiple>
  <TimesFreeTextSingle>String</TimesFreeTextSingle>
</AvailableTimesResponse>