BokaMera.API.Host

<back to all web services

CreateResourceTimeException

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/timeexceptionsInserts a time exception for a given resource belonging to the current userInserts 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 'package:servicestack/servicestack.dart';

class CreateResourceTimeExceptionBase implements IConvertible
{
    /**
    * 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.")
    bool? Force;

    /**
    * 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.")
    String? CancelMessage;

    /**
    * 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")
    bool? SendSmsConfirmation;

    /**
    * 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")
    bool? SendEmailConfirmation;

    CreateResourceTimeExceptionBase({this.Force,this.CancelMessage,this.SendSmsConfirmation,this.SendEmailConfirmation});
    CreateResourceTimeExceptionBase.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Force = json['Force'];
        CancelMessage = json['CancelMessage'];
        SendSmsConfirmation = json['SendSmsConfirmation'];
        SendEmailConfirmation = json['SendEmailConfirmation'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Force': Force,
        'CancelMessage': CancelMessage,
        'SendSmsConfirmation': SendSmsConfirmation,
        'SendEmailConfirmation': SendEmailConfirmation
    };

    getTypeName() => "CreateResourceTimeExceptionBase";
    TypeContext? context = _ctx;
}

class TimeExceptionReosurceDetails implements IConvertible
{
    /**
    * Ids of the resources that owns this exception
    */
    // @ApiMember(Description="Ids of the resources that owns this exception")
    int? Id;

    /**
    * Name of the resource
    */
    // @ApiMember(Description="Name of the resource")
    String? Name;

    /**
    * Description of the resource
    */
    // @ApiMember(Description="Description of the resource")
    String? Description;

    /**
    * Color of the resource
    */
    // @ApiMember(Description="Color of the resource")
    String? Color;

    /**
    * Image of the resource
    */
    // @ApiMember(Description="Image of the resource")
    Uri? ImageUrl;

    ResponseStatus? ResponseStatus;

    TimeExceptionReosurceDetails({this.Id,this.Name,this.Description,this.Color,this.ImageUrl,this.ResponseStatus});
    TimeExceptionReosurceDetails.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        Name = json['Name'];
        Description = json['Description'];
        Color = json['Color'];
        ImageUrl = JsonConverters.fromJson(json['ImageUrl'],'Uri',context!);
        ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'Name': Name,
        'Description': Description,
        'Color': Color,
        'ImageUrl': JsonConverters.toJson(ImageUrl,'Uri',context!),
        'ResponseStatus': JsonConverters.toJson(ResponseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "TimeExceptionReosurceDetails";
    TypeContext? context = _ctx;
}

class ExceptionCalendarExportStatus implements IConvertible
{
    String? CalendarId;
    int? ExceptionId;
    bool? Synced;

    ExceptionCalendarExportStatus({this.CalendarId,this.ExceptionId,this.Synced});
    ExceptionCalendarExportStatus.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CalendarId = json['CalendarId'];
        ExceptionId = json['ExceptionId'];
        Synced = json['Synced'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CalendarId': CalendarId,
        'ExceptionId': ExceptionId,
        'Synced': Synced
    };

    getTypeName() => "ExceptionCalendarExportStatus";
    TypeContext? context = _ctx;
}

class DayOfWeekDto implements IConvertible
{
    int? DayOfWeekId;
    int? DotNetDayOfWeekId;
    String? DayOfWeek;

    DayOfWeekDto({this.DayOfWeekId,this.DotNetDayOfWeekId,this.DayOfWeek});
    DayOfWeekDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        DayOfWeekId = json['DayOfWeekId'];
        DotNetDayOfWeekId = json['DotNetDayOfWeekId'];
        DayOfWeek = json['DayOfWeek'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'DayOfWeekId': DayOfWeekId,
        'DotNetDayOfWeekId': DotNetDayOfWeekId,
        'DayOfWeek': DayOfWeek
    };

    getTypeName() => "DayOfWeekDto";
    TypeContext? context = _ctx;
}

class ResourceTimeExceptionQueryResponse implements IConvertible
{
    /**
    * Time exception id
    */
    // @ApiMember(Description="Time exception id")
    int? Id;

    /**
    * Time company id
    */
    // @ApiMember(Description="Time company id")
    String? CompanyId;

    /**
    * If it's locked for editing for the logged in administrator
    */
    // @ApiMember(Description="If it's locked for editing for the logged in administrator")
    bool? Locked;

    /**
    * Resources that owns this exception
    */
    // @ApiMember(Description="Resources that owns this exception")
    List<int>? ResourceIds;

    /**
    * Resources that owns this exception
    */
    // @ApiMember(Description="Resources that owns this exception")
    List<TimeExceptionReosurceDetails>? Resources;

    /**
    * Indicates wheter or not the time exception is recurring
    */
    // @ApiMember(Description="Indicates wheter or not the time exception is recurring")
    bool? IsRecurring;

    /**
    * Time exception starting timestamp
    */
    // @ApiMember(Description="Time exception starting timestamp")
    DateTime? From;

    /**
    * Time exception ending timestamp
    */
    // @ApiMember(Description="Time exception ending timestamp")
    DateTime? To;

    /**
    * 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")
    Duration? FromTime;

    /**
    * 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")
    Duration? ToTime;

    /**
    * The reason of the time exception, example: Vacation, doctors appointment, ...
    */
    // @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...")
    String? ReasonText;

    /**
    * 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, ...")
    String? ReasonTextPublic;

    /**
    * What hexadecimal color code the exception should have in the scheduler
    */
    // @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
    String? Color;

    /**
    * 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")
    bool? BlockTime;

    /**
    * 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")
    bool? Private;

    /**
    * The status for export to calendars like Gcal
    */
    // @ApiMember(Description="The status for export to calendars like Gcal")
    ExceptionCalendarExportStatus? CalendarExportStatus;

    /**
    * 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")
    List<DayOfWeekDto>? DaysOfWeek;

    /**
    * The datetime the exception was created
    */
    // @ApiMember(Description="The datetime the exception was created")
    DateTime? Created;

    ResponseStatus? ResponseStatus;

    ResourceTimeExceptionQueryResponse({this.Id,this.CompanyId,this.Locked,this.ResourceIds,this.Resources,this.IsRecurring,this.From,this.To,this.FromTime,this.ToTime,this.ReasonText,this.ReasonTextPublic,this.Color,this.BlockTime,this.Private,this.CalendarExportStatus,this.DaysOfWeek,this.Created,this.ResponseStatus});
    ResourceTimeExceptionQueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Id = json['Id'];
        CompanyId = json['CompanyId'];
        Locked = json['Locked'];
        ResourceIds = JsonConverters.fromJson(json['ResourceIds'],'List<int>',context!);
        Resources = JsonConverters.fromJson(json['Resources'],'List<TimeExceptionReosurceDetails>',context!);
        IsRecurring = json['IsRecurring'];
        From = JsonConverters.fromJson(json['From'],'DateTime',context!);
        To = JsonConverters.fromJson(json['To'],'DateTime',context!);
        FromTime = JsonConverters.fromJson(json['FromTime'],'Duration',context!);
        ToTime = JsonConverters.fromJson(json['ToTime'],'Duration',context!);
        ReasonText = json['ReasonText'];
        ReasonTextPublic = json['ReasonTextPublic'];
        Color = json['Color'];
        BlockTime = json['BlockTime'];
        Private = json['Private'];
        CalendarExportStatus = JsonConverters.fromJson(json['CalendarExportStatus'],'ExceptionCalendarExportStatus',context!);
        DaysOfWeek = JsonConverters.fromJson(json['DaysOfWeek'],'List<DayOfWeekDto>',context!);
        Created = JsonConverters.fromJson(json['Created'],'DateTime',context!);
        ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Id': Id,
        'CompanyId': CompanyId,
        'Locked': Locked,
        'ResourceIds': JsonConverters.toJson(ResourceIds,'List<int>',context!),
        'Resources': JsonConverters.toJson(Resources,'List<TimeExceptionReosurceDetails>',context!),
        'IsRecurring': IsRecurring,
        'From': JsonConverters.toJson(From,'DateTime',context!),
        'To': JsonConverters.toJson(To,'DateTime',context!),
        'FromTime': JsonConverters.toJson(FromTime,'Duration',context!),
        'ToTime': JsonConverters.toJson(ToTime,'Duration',context!),
        'ReasonText': ReasonText,
        'ReasonTextPublic': ReasonTextPublic,
        'Color': Color,
        'BlockTime': BlockTime,
        'Private': Private,
        'CalendarExportStatus': JsonConverters.toJson(CalendarExportStatus,'ExceptionCalendarExportStatus',context!),
        'DaysOfWeek': JsonConverters.toJson(DaysOfWeek,'List<DayOfWeekDto>',context!),
        'Created': JsonConverters.toJson(Created,'DateTime',context!),
        'ResponseStatus': JsonConverters.toJson(ResponseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "ResourceTimeExceptionQueryResponse";
    TypeContext? context = _ctx;
}

enum CollidingBookingOptions
{
    AddWithoutCancelingCollidingBookings,
    AddAndCancelCollidingBookings,
}

// @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, IConvertible
{
    /**
    * 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.")
    String? CompanyId;

    /**
    * 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)
    DateTime? From;

    /**
    * 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)
    DateTime? To;

    /**
    * Resource id of the resource that owns this exception
    */
    // @ApiMember(Description="Resource id of the resource that owns this exception", IsRequired=true)
    List<int>? ResourceIds;

    /**
    * 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.")
    Duration? FromTime;

    /**
    * 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.")
    Duration? ToTime;

    /**
    * 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")
    List<int>? DaysOfWeek;

    /**
    * The reason of the time exception, example: Vacation, doctors appointment, ...
    */
    // @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...", IsRequired=true)
    String? ReasonText;

    /**
    * 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, ...")
    String? ReasonTextPublic;

    /**
    * What hexadecimal color code the exception should have in the scheduler
    */
    // @ApiMember(Description="What hexadecimal color code the exception should have in the scheduler")
    String? Color;

    /**
    * 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")
    bool? BlockTime;

    /**
    * 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")
    bool? Private;

    /**
    * 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")
    CollidingBookingOptions? CollidingBookingOptions;

    CreateResourceTimeException({this.CompanyId,this.From,this.To,this.ResourceIds,this.FromTime,this.ToTime,this.DaysOfWeek,this.ReasonText,this.ReasonTextPublic,this.Color,this.BlockTime,this.Private,this.CollidingBookingOptions});
    CreateResourceTimeException.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        CompanyId = json['CompanyId'];
        From = JsonConverters.fromJson(json['From'],'DateTime',context!);
        To = JsonConverters.fromJson(json['To'],'DateTime',context!);
        ResourceIds = JsonConverters.fromJson(json['ResourceIds'],'List<int>',context!);
        FromTime = JsonConverters.fromJson(json['FromTime'],'Duration',context!);
        ToTime = JsonConverters.fromJson(json['ToTime'],'Duration',context!);
        DaysOfWeek = JsonConverters.fromJson(json['DaysOfWeek'],'List<int>',context!);
        ReasonText = json['ReasonText'];
        ReasonTextPublic = json['ReasonTextPublic'];
        Color = json['Color'];
        BlockTime = json['BlockTime'];
        Private = json['Private'];
        CollidingBookingOptions = JsonConverters.fromJson(json['CollidingBookingOptions'],'CollidingBookingOptions',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'CompanyId': CompanyId,
        'From': JsonConverters.toJson(From,'DateTime',context!),
        'To': JsonConverters.toJson(To,'DateTime',context!),
        'ResourceIds': JsonConverters.toJson(ResourceIds,'List<int>',context!),
        'FromTime': JsonConverters.toJson(FromTime,'Duration',context!),
        'ToTime': JsonConverters.toJson(ToTime,'Duration',context!),
        'DaysOfWeek': JsonConverters.toJson(DaysOfWeek,'List<int>',context!),
        'ReasonText': ReasonText,
        'ReasonTextPublic': ReasonTextPublic,
        'Color': Color,
        'BlockTime': BlockTime,
        'Private': Private,
        'CollidingBookingOptions': JsonConverters.toJson(CollidingBookingOptions,'CollidingBookingOptions',context!)
    });

    getTypeName() => "CreateResourceTimeException";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.bokamera.se', types: <String, TypeInfo> {
    'CreateResourceTimeExceptionBase': TypeInfo(TypeOf.Class, create:() => CreateResourceTimeExceptionBase()),
    'TimeExceptionReosurceDetails': TypeInfo(TypeOf.Class, create:() => TimeExceptionReosurceDetails()),
    'Uri': TypeInfo(TypeOf.Class, create:() => Uri()),
    'ExceptionCalendarExportStatus': TypeInfo(TypeOf.Class, create:() => ExceptionCalendarExportStatus()),
    'DayOfWeekDto': TypeInfo(TypeOf.Class, create:() => DayOfWeekDto()),
    'ResourceTimeExceptionQueryResponse': TypeInfo(TypeOf.Class, create:() => ResourceTimeExceptionQueryResponse()),
    'List<TimeExceptionReosurceDetails>': TypeInfo(TypeOf.Class, create:() => <TimeExceptionReosurceDetails>[]),
    'List<DayOfWeekDto>': TypeInfo(TypeOf.Class, create:() => <DayOfWeekDto>[]),
    'CollidingBookingOptions': TypeInfo(TypeOf.Enum, enumValues:CollidingBookingOptions.values),
    'CreateResourceTimeException': TypeInfo(TypeOf.Class, create:() => CreateResourceTimeException()),
});

Dart CreateResourceTimeException DTOs

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

HTTP + OTHER

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/jsonl
Content-Type: text/jsonl
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","ResourceIds":[0],"FromTime":"00:00:00","ToTime":"00:00:00","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/jsonl
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":"00:00:00","ToTime":"00:00:00","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"}}}