Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /timeexceptions | Inserts a time exception for a given resource belonging to the current user | Inserts a time exception for a given resource belonging to the current user if no colliding bookings are found. If a colliding booking is found. A time exception must be either recurring (DaysOfWeek is set and From and To is the valid range for the recurrency) 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};
class CreateResourceTimeExceptionBase implements JsonSerializable
{
public function __construct(
/** @description If this equals true it will it add the time exception with the option you have selected in CollidingBookingOption. Default is to cancel all colliding bookings. */
// @ApiMember(Description="If this equals true it will it add the time exception with the option you have selected in CollidingBookingOption. Default is to cancel all colliding bookings.")
/** @var bool|null */
public ?bool $Force=null,
/** @description When Force=true and colliding bookings exsists, this message is the message that are sent to the users when canceling their bookings. */
// @ApiMember(Description="When Force=true and colliding bookings exsists, this message is the message that are sent to the users when canceling their bookings.")
/** @var string|null */
public ?string $CancelMessage=null,
/** @description When Force=true and colliding bookings exsists, send cancelmessage as SMS Confirmation */
// @ApiMember(Description="When Force=true and colliding bookings exsists, send cancelmessage as SMS Confirmation")
/** @var bool|null */
public ?bool $SendSmsConfirmation=null,
/** @description When Force=true and colliding bookings exsists, send cancelmessage as Email Confirmation */
// @ApiMember(Description="When Force=true and colliding bookings exsists, send cancelmessage as Email Confirmation")
/** @var bool|null */
public ?bool $SendEmailConfirmation=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Force'])) $this->Force = $o['Force'];
if (isset($o['CancelMessage'])) $this->CancelMessage = $o['CancelMessage'];
if (isset($o['SendSmsConfirmation'])) $this->SendSmsConfirmation = $o['SendSmsConfirmation'];
if (isset($o['SendEmailConfirmation'])) $this->SendEmailConfirmation = $o['SendEmailConfirmation'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Force)) $o['Force'] = $this->Force;
if (isset($this->CancelMessage)) $o['CancelMessage'] = $this->CancelMessage;
if (isset($this->SendSmsConfirmation)) $o['SendSmsConfirmation'] = $this->SendSmsConfirmation;
if (isset($this->SendEmailConfirmation)) $o['SendEmailConfirmation'] = $this->SendEmailConfirmation;
return empty($o) ? new class(){} : $o;
}
}
class TimeExceptionReosurceDetails implements JsonSerializable
{
public function __construct(
/** @description Ids of the resources that owns this exception */
// @ApiMember(Description="Ids of the resources that owns this exception")
/** @var int */
public int $Id=0,
/** @description Name of the resource */
// @ApiMember(Description="Name of the resource")
/** @var string|null */
public ?string $Name=null,
/** @description Description of the resource */
// @ApiMember(Description="Description of the resource")
/** @var string|null */
public ?string $Description=null,
/** @description Color of the resource */
// @ApiMember(Description="Color of the resource")
/** @var string|null */
public ?string $Color=null,
/** @description Image of the resource */
// @ApiMember(Description="Image of the resource")
/** @var string|null */
public ?string $ImageUrl=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=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['Color'])) $this->Color = $o['Color'];
if (isset($o['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @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->Color)) $o['Color'] = $this->Color;
if (isset($this->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
class ExceptionCalendarExportStatus implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $CalendarId=null,
/** @var int */
public int $ExceptionId=0,
/** @var bool|null */
public ?bool $Synced=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CalendarId'])) $this->CalendarId = $o['CalendarId'];
if (isset($o['ExceptionId'])) $this->ExceptionId = $o['ExceptionId'];
if (isset($o['Synced'])) $this->Synced = $o['Synced'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CalendarId)) $o['CalendarId'] = $this->CalendarId;
if (isset($this->ExceptionId)) $o['ExceptionId'] = $this->ExceptionId;
if (isset($this->Synced)) $o['Synced'] = $this->Synced;
return empty($o) ? new class(){} : $o;
}
}
class DayOfWeekDto implements JsonSerializable
{
public function __construct(
/** @var int */
public int $DayOfWeekId=0,
/** @var int */
public int $DotNetDayOfWeekId=0,
/** @var string|null */
public ?string $DayOfWeek=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['DayOfWeekId'])) $this->DayOfWeekId = $o['DayOfWeekId'];
if (isset($o['DotNetDayOfWeekId'])) $this->DotNetDayOfWeekId = $o['DotNetDayOfWeekId'];
if (isset($o['DayOfWeek'])) $this->DayOfWeek = $o['DayOfWeek'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->DayOfWeekId)) $o['DayOfWeekId'] = $this->DayOfWeekId;
if (isset($this->DotNetDayOfWeekId)) $o['DotNetDayOfWeekId'] = $this->DotNetDayOfWeekId;
if (isset($this->DayOfWeek)) $o['DayOfWeek'] = $this->DayOfWeek;
return empty($o) ? new class(){} : $o;
}
}
class ResourceTimeExceptionQueryResponse implements JsonSerializable
{
public function __construct(
/** @description Time exception id */
// @ApiMember(Description="Time exception id")
/** @var int */
public int $Id=0,
/** @description Time company id */
// @ApiMember(Description="Time company id")
/** @var string */
public string $CompanyId='',
/** @description If it's locked for editing for the logged in administrator */
// @ApiMember(Description="If it's locked for editing for the logged in administrator")
/** @var bool|null */
public ?bool $Locked=null,
/** @description Resources that owns this exception */
// @ApiMember(Description="Resources that owns this exception")
/** @var int[]|null */
public ?array $ResourceIds=null,
/** @description Resources that owns this exception */
// @ApiMember(Description="Resources that owns this exception")
/** @var array<TimeExceptionReosurceDetails>|null */
public ?array $Resources=null,
/** @description Indicates wheter or not the time exception is recurring */
// @ApiMember(Description="Indicates wheter or not the time exception is recurring")
/** @var bool|null */
public ?bool $IsRecurring=null,
/** @description Time exception starting timestamp */
// @ApiMember(Description="Time exception starting timestamp")
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description Time exception ending timestamp */
// @ApiMember(Description="Time exception ending timestamp")
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description If recurring then this value indicates the time of day when the time exception begins */
// @ApiMember(Description="If recurring then this value indicates the time of day when the time exception begins")
/** @var DateInterval|null */
public ?DateInterval $FromTime=null,
/** @description If recurring then this value indicates the time of day when the time exception ends */
// @ApiMember(Description="If recurring then this value indicates the time of day when the time exception ends")
/** @var DateInterval|null */
public ?DateInterval $ToTime=null,
/** @description The reason of the time exception, example: Vacation, doctors appointment, ... */
// @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...")
/** @var string|null */
public ?string $ReasonText=null,
/** @description The reason of the time exception that could be public to customers, example: Vacation, Closed, Sick leave, ... */
// @ApiMember(Description="The reason of the time exception that could be public to customers, example: Vacation, Closed, Sick leave, ...")
/** @var string|null */
public ?string $ReasonTextPublic=null,
/** @description What hexadecimal color code the exception should have in the scheduler */
// @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
/** @var string|null */
public ?string $Color=null,
/** @description If the time exception should block the time in the scheduler so it's not avaialable to book */
// @ApiMember(Description="If the time exception should block the time in the scheduler so it's not avaialable to book")
/** @var bool|null */
public ?bool $BlockTime=null,
/** @description If the ReasonText should only be visible to conncted resources. If false, all resources will be able to see it */
// @ApiMember(Description="If the ReasonText should only be visible to conncted resources. If false, all resources will be able to see it")
/** @var bool|null */
public ?bool $Private=null,
/** @description The status for export to calendars like Gcal */
// @ApiMember(Description="The status for export to calendars like Gcal")
/** @var ExceptionCalendarExportStatus|null */
public ?ExceptionCalendarExportStatus $CalendarExportStatus=null,
/** @description If recurring, an array indicating which days of the week the exception recures on where 1 = Monday .. 7 = Sunday. When recurring then the time portion of the Fields From and To indicates the time of day the recurrence occurs */
// @ApiMember(Description="If recurring, an array indicating which days of the week the exception recures on where 1 = Monday .. 7 = Sunday. When recurring then the time portion of the Fields From and To indicates the time of day the recurrence occurs")
/** @var array<DayOfWeekDto>|null */
public ?array $DaysOfWeek=null,
/** @description The datetime the exception was created */
// @ApiMember(Description="The datetime the exception was created")
/** @var DateTime */
public DateTime $Created=new DateTime(),
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @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['Locked'])) $this->Locked = $o['Locked'];
if (isset($o['ResourceIds'])) $this->ResourceIds = JsonConverters::fromArray('int', $o['ResourceIds']);
if (isset($o['Resources'])) $this->Resources = JsonConverters::fromArray('TimeExceptionReosurceDetails', $o['Resources']);
if (isset($o['IsRecurring'])) $this->IsRecurring = $o['IsRecurring'];
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['ReasonText'])) $this->ReasonText = $o['ReasonText'];
if (isset($o['ReasonTextPublic'])) $this->ReasonTextPublic = $o['ReasonTextPublic'];
if (isset($o['Color'])) $this->Color = $o['Color'];
if (isset($o['BlockTime'])) $this->BlockTime = $o['BlockTime'];
if (isset($o['Private'])) $this->Private = $o['Private'];
if (isset($o['CalendarExportStatus'])) $this->CalendarExportStatus = JsonConverters::from('ExceptionCalendarExportStatus', $o['CalendarExportStatus']);
if (isset($o['DaysOfWeek'])) $this->DaysOfWeek = JsonConverters::fromArray('DayOfWeekDto', $o['DaysOfWeek']);
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @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->Locked)) $o['Locked'] = $this->Locked;
if (isset($this->ResourceIds)) $o['ResourceIds'] = JsonConverters::toArray('int', $this->ResourceIds);
if (isset($this->Resources)) $o['Resources'] = JsonConverters::toArray('TimeExceptionReosurceDetails', $this->Resources);
if (isset($this->IsRecurring)) $o['IsRecurring'] = $this->IsRecurring;
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->ReasonText)) $o['ReasonText'] = $this->ReasonText;
if (isset($this->ReasonTextPublic)) $o['ReasonTextPublic'] = $this->ReasonTextPublic;
if (isset($this->Color)) $o['Color'] = $this->Color;
if (isset($this->BlockTime)) $o['BlockTime'] = $this->BlockTime;
if (isset($this->Private)) $o['Private'] = $this->Private;
if (isset($this->CalendarExportStatus)) $o['CalendarExportStatus'] = JsonConverters::to('ExceptionCalendarExportStatus', $this->CalendarExportStatus);
if (isset($this->DaysOfWeek)) $o['DaysOfWeek'] = JsonConverters::toArray('DayOfWeekDto', $this->DaysOfWeek);
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
enum CollidingBookingOptions : int
{
case AddWithoutCancelingCollidingBookings = 1;
case AddAndCancelCollidingBookings = 2;
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="You have too low privilegies to call this service", StatusCode=403)
// @ApiResponse(Description="Bookings exists that needs to be unbooked before creating this time exceptions, use the /timeexceptions/collidingevents to find which bookings and use the booking service to unbook them", StatusCode=409)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateResourceTimeException extends CreateResourceTimeExceptionBase implements ICompany, JsonSerializable
{
/**
* @param bool|null $Force
* @param string|null $CancelMessage
* @param bool|null $SendSmsConfirmation
* @param bool|null $SendEmailConfirmation
*/
public function __construct(
?bool $Force=null,
?string $CancelMessage=null,
?bool $SendSmsConfirmation=null,
?bool $SendEmailConfirmation=null,
/** @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 Time exception starting datestamp, only the date of day part is used of this value */
// @ApiMember(Description="Time exception starting datestamp, only the date of day part is used of this value", IsRequired=true)
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description Time exception ending datestamp, only the date of day part is used of this value */
// @ApiMember(Description="Time exception ending datestamp, only the date of day part is used of this value", IsRequired=true)
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description Resource id of the resource that owns this exception */
// @ApiMember(Description="Resource id of the resource that owns this exception", IsRequired=true)
/** @var int[] */
public array $ResourceIds=[],
/** @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 The reason of the time exception, example: Vacation, doctors appointment, ... */
// @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...", IsRequired=true)
/** @var string */
public string $ReasonText='',
/** @description The reason of the time exception that could be public to customers, example: Vacation, Closed, Sick leave, ... */
// @ApiMember(Description="The reason of the time exception that could be public to customers, example: Vacation, Closed, Sick leave, ...")
/** @var string|null */
public ?string $ReasonTextPublic=null,
/** @description What hexadecimal color code the exception should have in the scheduler */
// @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
/** @var string|null */
public ?string $Color=null,
/** @description If the time exception should block the time in the scheduler so it's not avaialable to book */
// @ApiMember(Description="If the time exception should block the time in the scheduler so it's not avaialable to book")
/** @var bool|null */
public ?bool $BlockTime=null,
/** @description If the ReasonText should only be visible to conncted resources. If false, all resources will be able to see it */
// @ApiMember(Description="If the ReasonText should only be visible to conncted resources. If false, all resources will be able to see it")
/** @var bool|null */
public ?bool $Private=null,
/** @description By default sets to 1, which is to add time exception without canceling colliding bookings */
// @ApiMember(Description="By default sets to 1, which is to add time exception without canceling colliding bookings")
/** @var CollidingBookingOptions|null */
public ?CollidingBookingOptions $CollidingBookingOptions=null
) {
parent::__construct($Force,$CancelMessage,$SendSmsConfirmation,$SendEmailConfirmation);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
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['ResourceIds'])) $this->ResourceIds = JsonConverters::fromArray('int', $o['ResourceIds']);
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['ReasonText'])) $this->ReasonText = $o['ReasonText'];
if (isset($o['ReasonTextPublic'])) $this->ReasonTextPublic = $o['ReasonTextPublic'];
if (isset($o['Color'])) $this->Color = $o['Color'];
if (isset($o['BlockTime'])) $this->BlockTime = $o['BlockTime'];
if (isset($o['Private'])) $this->Private = $o['Private'];
if (isset($o['CollidingBookingOptions'])) $this->CollidingBookingOptions = JsonConverters::from('CollidingBookingOptions', $o['CollidingBookingOptions']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
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->ResourceIds)) $o['ResourceIds'] = JsonConverters::toArray('int', $this->ResourceIds);
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->ReasonText)) $o['ReasonText'] = $this->ReasonText;
if (isset($this->ReasonTextPublic)) $o['ReasonTextPublic'] = $this->ReasonTextPublic;
if (isset($this->Color)) $o['Color'] = $this->Color;
if (isset($this->BlockTime)) $o['BlockTime'] = $this->BlockTime;
if (isset($this->Private)) $o['Private'] = $this->Private;
if (isset($this->CollidingBookingOptions)) $o['CollidingBookingOptions'] = JsonConverters::to('CollidingBookingOptions', $this->CollidingBookingOptions);
return empty($o) ? new class(){} : $o;
}
}
PHP CreateResourceTimeException DTOs
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.
POST /timeexceptions HTTP/1.1
Host: api.bokamera.se
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
CompanyId: 00000000-0000-0000-0000-000000000000,
ResourceIds:
[
0
],
FromTime: PT0S,
ToTime: PT0S,
DaysOfWeek:
[
0
],
ReasonText: String,
ReasonTextPublic: String,
Color: String,
BlockTime: False,
Private: False,
CollidingBookingOptions: AddWithoutCancelingCollidingBookings,
Force: False,
CancelMessage: String,
SendSmsConfirmation: False,
SendEmailConfirmation: False
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { Id: 0, Locked: False, ResourceIds: [ 0 ], Resources: [ { Id: 0, Name: String, Description: String, Color: String, ResponseStatus: { ErrorCode: String, Message: String, StackTrace: String, Errors: [ { ErrorCode: String, FieldName: String, Message: String, Meta: { String: String } } ], Meta: { String: String } } } ], IsRecurring: False, FromTime: PT0S, ToTime: PT0S, ReasonText: String, ReasonTextPublic: String, Color: String, BlockTime: False, Private: False, CalendarExportStatus: { CalendarId: String, ExceptionId: 0, Synced: False }, DaysOfWeek: [ { DayOfWeekId: 0, DotNetDayOfWeekId: 0, DayOfWeek: String } ], ResponseStatus: { ErrorCode: String, Message: String, StackTrace: String, Errors: [ { ErrorCode: String, FieldName: String, Message: String, Meta: { String: String } } ], Meta: { String: String } } }