GET | /services/{ServiceId}/availabletimes | Get availabletimes for the service | Get availabletimes for the service and it's connected 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 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 AvailableTimesQuery implements IInterval, JsonSerializable
{
public function __construct(
/** @description Company to show services for */
// @ApiMember(Description="Company to show services 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 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 Here you can select one of the resource in each resourcetype 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 resourcetype 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 resourcetype). Default is 1. */
// @ApiMember(Description="Here you select number of resources to book (in each resourcetype). Default is 1.", ParameterType="query")
/** @var int */
public int $NumberOfResources=0,
/** @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,
/** @description Both start and time time should be inside test interval. Default is false which means only start time needs to be inside. */
// @ApiMember(DataType="bool", Description="Both start and time time should be inside test interval. Default is false which means only start time needs to be inside.", ParameterType="query")
/** @var bool|null */
public ?bool $InsideSearchInterval=null,
/** @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,
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=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['ShowPerResource'])) $this->ShowPerResource = $o['ShowPerResource'];
if (isset($o['InsideSearchInterval'])) $this->InsideSearchInterval = $o['InsideSearchInterval'];
if (isset($o['Duration'])) $this->Duration = $o['Duration'];
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @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->ShowPerResource)) $o['ShowPerResource'] = $this->ShowPerResource;
if (isset($this->InsideSearchInterval)) $o['InsideSearchInterval'] = $this->InsideSearchInterval;
if (isset($this->Duration)) $o['Duration'] = $this->Duration;
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /services/{ServiceId}/availabletimes HTTP/1.1 Host: api.bokamera.se Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { ServiceId: 0, TimesFreeTextSingle: String, TimesFreeTextMultiple: String, Times: [ { Free: 0, FreeSpots: 0 } ] }