Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
PUT | /timeexceptions/{Id} | Updates a time exception for a given resource belonging to the current user | Updates 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) |
---|
import Foundation
import ServiceStack
// @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")
public class UpdateResourceTimeException : CreateResourceTimeExceptionBase, ICompany
{
/**
* 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.")
public var companyId:String?
/**
* Tome exceptions id
*/
// @ApiMember(Description="Tome exceptions id", ParameterType="path")
public var id:Int
/**
* 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")
public var from:Date?
/**
* 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")
public var to:Date?
/**
* Resource id of the resource that owns this exception
*/
// @ApiMember(Description="Resource id of the resource that owns this exception", IsRequired=true)
public var resourceIds:[Int] = []
/**
* 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.")
@TimeSpan public var fromTime:TimeInterval?
/**
* 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.")
@TimeSpan public var toTime:TimeInterval?
/**
* A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.
*/
// @ApiMember(Description="A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
public var daysOfWeek:[Int] = []
/**
* The reason of the time exception, example: Vacation, doctors appointment, ...
*/
// @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...", IsRequired=true)
public var reasonText:String
/**
* 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, ...")
public var reasonTextPublic:String
/**
* What hexadecimal color code the exception should have in the scheduler
*/
// @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
public var color:String
/**
* 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")
public var blockTime:Bool?
/**
* 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")
public var `private`:Bool?
/**
* 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")
public var collidingBookingOptions:CollidingBookingOptions
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case companyId
case id
case from
case to
case resourceIds
case fromTime
case toTime
case daysOfWeek
case reasonText
case reasonTextPublic
case color
case blockTime
case `private`
case collidingBookingOptions
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
companyId = try container.decodeIfPresent(String.self, forKey: .companyId)
id = try container.decodeIfPresent(Int.self, forKey: .id)
from = try container.decodeIfPresent(Date.self, forKey: .from)
to = try container.decodeIfPresent(Date.self, forKey: .to)
resourceIds = try container.decodeIfPresent([Int].self, forKey: .resourceIds) ?? []
fromTime = try container.convertIfPresent(TimeInterval.self, forKey: .fromTime)
toTime = try container.convertIfPresent(TimeInterval.self, forKey: .toTime)
daysOfWeek = try container.decodeIfPresent([Int].self, forKey: .daysOfWeek) ?? []
reasonText = try container.decodeIfPresent(String.self, forKey: .reasonText)
reasonTextPublic = try container.decodeIfPresent(String.self, forKey: .reasonTextPublic)
color = try container.decodeIfPresent(String.self, forKey: .color)
blockTime = try container.decodeIfPresent(Bool.self, forKey: .blockTime)
`private` = try container.decodeIfPresent(Bool.self, forKey: .`private`)
collidingBookingOptions = try container.decodeIfPresent(CollidingBookingOptions.self, forKey: .collidingBookingOptions)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if companyId != nil { try container.encode(companyId, forKey: .companyId) }
if id != nil { try container.encode(id, forKey: .id) }
if from != nil { try container.encode(from, forKey: .from) }
if to != nil { try container.encode(to, forKey: .to) }
if resourceIds.count > 0 { try container.encode(resourceIds, forKey: .resourceIds) }
if fromTime != nil { try container.encode(fromTime, forKey: .fromTime) }
if toTime != nil { try container.encode(toTime, forKey: .toTime) }
if daysOfWeek.count > 0 { try container.encode(daysOfWeek, forKey: .daysOfWeek) }
if reasonText != nil { try container.encode(reasonText, forKey: .reasonText) }
if reasonTextPublic != nil { try container.encode(reasonTextPublic, forKey: .reasonTextPublic) }
if color != nil { try container.encode(color, forKey: .color) }
if blockTime != nil { try container.encode(blockTime, forKey: .blockTime) }
if `private` != nil { try container.encode(`private`, forKey: .`private`) }
if collidingBookingOptions != nil { try container.encode(collidingBookingOptions, forKey: .collidingBookingOptions) }
}
}
public class CreateResourceTimeExceptionBase : Codable
{
/**
* 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.")
public var force:Bool
/**
* 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.")
public var cancelMessage:String
/**
* 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")
public var sendSmsConfirmation:Bool?
/**
* 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")
public var sendEmailConfirmation:Bool?
required public init(){}
}
public enum CollidingBookingOptions : Int, Codable
{
case AddWithoutCancelingCollidingBookings = 1
case AddAndCancelCollidingBookings = 2
}
public class ResourceTimeExceptionQueryResponse : Codable
{
/**
* Time exception id
*/
// @ApiMember(Description="Time exception id")
public var id:Int
/**
* Time company id
*/
// @ApiMember(Description="Time company id")
public var companyId:String
/**
* If it's locked for editing for the logged in administrator
*/
// @ApiMember(Description="If it's locked for editing for the logged in administrator")
public var locked:Bool
/**
* Resources that owns this exception
*/
// @ApiMember(Description="Resources that owns this exception")
public var resourceIds:[Int] = []
/**
* Resources that owns this exception
*/
// @ApiMember(Description="Resources that owns this exception")
public var resources:[TimeExceptionReosurceDetails] = []
/**
* Indicates wheter or not the time exception is recurring
*/
// @ApiMember(Description="Indicates wheter or not the time exception is recurring")
public var isRecurring:Bool
/**
* Time exception starting timestamp
*/
// @ApiMember(Description="Time exception starting timestamp")
public var from:Date
/**
* Time exception ending timestamp
*/
// @ApiMember(Description="Time exception ending timestamp")
public var to:Date
/**
* 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")
@TimeSpan public var fromTime:TimeInterval
/**
* 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")
@TimeSpan public var toTime:TimeInterval
/**
* The reason of the time exception, example: Vacation, doctors appointment, ...
*/
// @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...")
public var reasonText:String
/**
* 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, ...")
public var reasonTextPublic:String
/**
* What hexadecimal color code the exception should have in the scheduler
*/
// @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
public var color:String
/**
* 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")
public var blockTime:Bool
/**
* 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")
public var `private`:Bool
/**
* The status for export to calendars like Gcal
*/
// @ApiMember(Description="The status for export to calendars like Gcal")
public var calendarExportStatus:ExceptionCalendarExportStatus
/**
* 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")
public var daysOfWeek:[DayOfWeekDto] = []
/**
* The datetime the exception was created
*/
// @ApiMember(Description="The datetime the exception was created")
public var created:Date
public var responseStatus:ResponseStatus
required public init(){}
}
public class TimeExceptionReosurceDetails : Codable
{
/**
* Ids of the resources that owns this exception
*/
// @ApiMember(Description="Ids of the resources that owns this exception")
public var id:Int
/**
* Name of the resource
*/
// @ApiMember(Description="Name of the resource")
public var name:String
/**
* Description of the resource
*/
// @ApiMember(Description="Description of the resource")
public var Description:String
/**
* Color of the resource
*/
// @ApiMember(Description="Color of the resource")
public var color:String
/**
* Image of the resource
*/
// @ApiMember(Description="Image of the resource")
public var imageUrl:Uri
public var responseStatus:ResponseStatus
required public init(){}
}
public class ExceptionCalendarExportStatus : Codable
{
public var calendarId:String
public var exceptionId:Int
public var synced:Bool?
required public init(){}
}
public class DayOfWeekDto : Codable
{
public var dayOfWeekId:Int
public var dotNetDayOfWeekId:Int
public var dayOfWeek:String
required public init(){}
}
Swift UpdateResourceTimeException DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /timeexceptions/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UpdateResourceTimeException xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CancelMessage>String</CancelMessage>
<Force>false</Force>
<SendEmailConfirmation>false</SendEmailConfirmation>
<SendSmsConfirmation>false</SendSmsConfirmation>
<BlockTime>false</BlockTime>
<CollidingBookingOptions>AddWithoutCancelingCollidingBookings</CollidingBookingOptions>
<Color>String</Color>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<DaysOfWeek xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</DaysOfWeek>
<From>0001-01-01T00:00:00</From>
<FromTime>PT0S</FromTime>
<Id>0</Id>
<Private>false</Private>
<ReasonText>String</ReasonText>
<ReasonTextPublic>String</ReasonTextPublic>
<ResourceIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</ResourceIds>
<To>0001-01-01T00:00:00</To>
<ToTime>PT0S</ToTime>
</UpdateResourceTimeException>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <ResourceTimeExceptionQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <BlockTime>false</BlockTime> <CalendarExportStatus> <CalendarId>String</CalendarId> <ExceptionId>0</ExceptionId> <Synced>false</Synced> </CalendarExportStatus> <Color>String</Color> <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId> <Created>0001-01-01T00:00:00</Created> <DaysOfWeek> <DayOfWeekDto> <DayOfWeek>String</DayOfWeek> <DayOfWeekId>0</DayOfWeekId> <DotNetDayOfWeekId>0</DotNetDayOfWeekId> </DayOfWeekDto> </DaysOfWeek> <From>0001-01-01T00:00:00</From> <FromTime>PT0S</FromTime> <Id>0</Id> <IsRecurring>false</IsRecurring> <Locked>false</Locked> <Private>false</Private> <ReasonText>String</ReasonText> <ReasonTextPublic>String</ReasonTextPublic> <ResourceIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d2p1:int>0</d2p1:int> </ResourceIds> <Resources> <TimeExceptionReosurceDetails> <Color>String</Color> <Description>String</Description> <Id>0</Id> <ImageUrl i:nil="true" /> <Name>String</Name> <ResponseStatus xmlns:d4p1="http://schemas.servicestack.net/types"> <d4p1:ErrorCode>String</d4p1:ErrorCode> <d4p1:Message>String</d4p1:Message> <d4p1:StackTrace>String</d4p1:StackTrace> <d4p1:Errors> <d4p1:ResponseError> <d4p1:ErrorCode>String</d4p1:ErrorCode> <d4p1:FieldName>String</d4p1:FieldName> <d4p1:Message>String</d4p1:Message> <d4p1:Meta xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:KeyValueOfstringstring> <d7p1:Key>String</d7p1:Key> <d7p1:Value>String</d7p1:Value> </d7p1:KeyValueOfstringstring> </d4p1:Meta> </d4p1:ResponseError> </d4p1:Errors> <d4p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d5p1:KeyValueOfstringstring> <d5p1:Key>String</d5p1:Key> <d5p1:Value>String</d5p1:Value> </d5p1:KeyValueOfstringstring> </d4p1:Meta> </ResponseStatus> </TimeExceptionReosurceDetails> </Resources> <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types"> <d2p1:ErrorCode>String</d2p1:ErrorCode> <d2p1:Message>String</d2p1:Message> <d2p1:StackTrace>String</d2p1:StackTrace> <d2p1:Errors> <d2p1:ResponseError> <d2p1:ErrorCode>String</d2p1:ErrorCode> <d2p1:FieldName>String</d2p1:FieldName> <d2p1:Message>String</d2p1:Message> <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d5p1:KeyValueOfstringstring> <d5p1:Key>String</d5p1:Key> <d5p1:Value>String</d5p1:Value> </d5p1:KeyValueOfstringstring> </d2p1:Meta> </d2p1:ResponseError> </d2p1:Errors> <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d3p1:KeyValueOfstringstring> <d3p1:Key>String</d3p1:Key> <d3p1:Value>String</d3p1:Value> </d3p1:KeyValueOfstringstring> </d2p1:Meta> </ResponseStatus> <To>0001-01-01T00:00:00</To> <ToTime>PT0S</ToTime> </ResourceTimeExceptionQueryResponse>