Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
GET | /timeexceptions/collidingevents | Searches for collisions with existing bookings of the resource | Searches for existing bookings and investigates if a proposed time exception would collide with them, if so, the bookings should be unbooked to be able to create the time exception. A time exception must be either recurring (DaysOfWeek, ExceptionFromTime, ExceptionToTime is set) or non recurring (From and To are set). |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class BookingStatusEnum(IntEnum):
BOOKED = 1
UNBOOKED = 2
RESERVED = 3
CANCELED = 4
AWAITING_PAYMENT = 5
AWAITING_PAYMENT_NO_TIME_LIMIT = 6
PAYED = 7
AWAITING_PAYMENT_REQUEST_FROM_ADMIN = 8
AWAITING_PAYMENT_FROM_PROVIDER = 9
INVOICED = 10
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookedCustomer:
id: Optional[str] = None
firstname: Optional[str] = None
lastname: Optional[str] = None
email: Optional[str] = None
phone: Optional[str] = None
facebook_user_name: Optional[str] = None
image_url: Optional[str] = None
corporate_identity_number: Optional[str] = None
invoice_address1: Optional[str] = None
invoice_address2: Optional[str] = None
invoice_city: Optional[str] = None
invoice_postal_code: Optional[str] = None
invoice_country_code: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class GroupBookingSettings:
active: bool = False
min: int = 0
max: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class MultipleResourceSettings:
active: bool = False
min: int = 0
max: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ServiceInfoResponse:
id: int = 0
name: Optional[str] = None
description: Optional[str] = None
image_url: Optional[str] = None
length_in_minutes: Optional[int] = None
max_number_of_spots_per_booking: int = 0
min_number_of_spots_per_booking: int = 0
group_booking: Optional[GroupBookingSettings] = None
multiple_resource: Optional[MultipleResourceSettings] = None
is_group_booking: bool = False
is_payment_enabled: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingIntervalResponse:
id: int = 0
company_id: Optional[str] = None
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
to: datetime.datetime = datetime.datetime(1, 1, 1)
status: Optional[BookingStatusEnum] = None
status_id: int = 0
status_name: Optional[str] = None
customer: Optional[BookedCustomer] = None
service: Optional[ServiceInfoResponse] = None
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CollidingBookingQueryResponse:
# @ApiMember(Description="Resource id of the resource that owns this exception")
resource_ids: Optional[List[int]] = None
"""
Resource id of the resource that owns this exception
"""
# @ApiMember(Description="A list of bookings that would collide with the time exception")
bookings: Optional[List[BookingIntervalResponse]] = None
"""
A list of bookings that would collide with the time exception
"""
response_status: Optional[ResponseStatus] = None
# @ApiResponse(Description="The request parameters was not valid", StatusCode=400)
# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
# @ApiResponse(Description="You have too low privilegies to call this service", StatusCode=403)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CollidingBookingQuery:
# @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
company_id: Optional[str] = None
"""
The company id, if empty will use the company id for the user you are logged in with.
"""
# @ApiMember(Description="Resource ids of the resource that should be matched against booked events")
resource_ids: Optional[List[int]] = None
"""
Resource ids of the resource that should be matched against booked events
"""
# @ApiMember(Description="Time exception starting date")
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
Time exception starting date
"""
# @ApiMember(Description="Time exception ending date")
to: datetime.datetime = datetime.datetime(1, 1, 1)
"""
Time exception ending date
"""
# @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.")
from_time: datetime.timedelta = datetime.timedelta()
"""
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 ends. Example: 12:00. If Recurring this will be the endtime for each recurring day.")
to_time: datetime.timedelta = datetime.timedelta()
"""
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="A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday")
days_of_week: Optional[List[int]] = None
"""
A comma separated list of which days this day exception belongs to, 1 = Monday .. 7 = Sunday
"""
# @ApiMember(DataType="boolean", Description="If you want to include the service information for the booking", ParameterType="query")
include_service_information: bool = False
"""
If you want to include the service information for the booking
"""
# @ApiMember(DataType="boolean", Description="If you want to include the customer information for the booking", ParameterType="query")
include_customer_information: bool = False
"""
If you want to include the customer information for the booking
"""
Python CollidingBookingQuery 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.
GET /timeexceptions/collidingevents HTTP/1.1 Host: api.bokamera.se Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { ResourceIds: [ 0 ], Bookings: [ { Id: 0, Status: Booked, StatusId: 0, StatusName: String, Customer: { Firstname: String, Lastname: String, Email: String, Phone: String, FacebookUserName: String, ImageUrl: String, CorporateIdentityNumber: String, InvoiceAddress1: String, InvoiceAddress2: String, InvoiceCity: String, InvoicePostalCode: String, InvoiceCountryCode: String }, Service: { Id: 0, Name: String, Description: String, LengthInMinutes: 0, MaxNumberOfSpotsPerBooking: 0, MinNumberOfSpotsPerBooking: 0, GroupBooking: { Active: False, Min: 0, Max: 0 }, MultipleResource: { Active: False, Min: 0, Max: 0 }, IsGroupBooking: False, IsPaymentEnabled: False } } ], ResponseStatus: { ErrorCode: String, Message: String, StackTrace: String, Errors: [ { ErrorCode: String, FieldName: String, Message: String, Meta: { String: String } } ], Meta: { String: String } } }