Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
PUT | /bookings/{Id}/resource | Change a resource on a booking | Update an existing booking with a another available resource. |
---|
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 BookingStatusQueryResponse:
id: int = 0
name: Optional[str] = None
description: Optional[str] = None
icon: Optional[str] = None
color: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldValueResponse:
value: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldConfigData:
# @ApiMember(Description="Custom field id")
id: int = 0
"""
Custom field id
"""
# @ApiMember(Description="Configuration name. Example: 'Number of persons'.")
name: Optional[str] = None
"""
Configuration name. Example: 'Number of persons'.
"""
# @ApiMember(Description="Custom field description. Example: 'For how many persons is this booking?'")
description: Optional[str] = None
"""
Custom field description. Example: 'For how many persons is this booking?'
"""
# @ApiMember(Description="Field width. Example: 20 for 20px")
width: Optional[int] = None
"""
Field width. Example: 20 for 20px
"""
# @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
data_type: Optional[str] = None
"""
Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
"""
# @ApiMember(Description="Default value of the field. Example: '3'")
default_value: Optional[str] = None
"""
Default value of the field. Example: '3'
"""
# @ApiMember(Description="Determines if the field is required to have a value or not")
is_mandatory: bool = False
"""
Determines if the field is required to have a value or not
"""
# @ApiMember(Description="Error message shown to the user if the field data is required but not entered")
mandatory_error_message: Optional[str] = None
"""
Error message shown to the user if the field data is required but not entered
"""
# @ApiMember(Description="Max lenght of the field")
max_length: int = 0
"""
Max lenght of the field
"""
# @ApiMember(Description="If the field should have multiple lines")
multiple_line_text: bool = False
"""
If the field should have multiple lines
"""
# @ApiMember(Description="Regular expression used for validation of the field")
reg_ex: Optional[str] = None
"""
Regular expression used for validation of the field
"""
# @ApiMember(Description="Error message shown if the regular expression validation failed")
reg_ex_error_message: Optional[str] = None
"""
Error message shown if the regular expression validation failed
"""
# @ApiMember(Description="The values to select from if Datatype is DropDown for this custom field")
values: Optional[List[CustomFieldValueResponse]] = None
"""
The values to select from if Datatype is DropDown for this custom field
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomFieldDataResponse:
id: int = 0
column: Optional[str] = None
name: Optional[str] = None
description: Optional[str] = None
value: Optional[str] = None
# @ApiMember(Description="Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'")
data_type: Optional[str] = None
"""
Data field of custom field. Valid values are: TextBox, ... Example: 'TextBox'
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookedResource:
id: int = 0
name: Optional[str] = None
color: Optional[str] = None
image_url: Optional[str] = None
email: Optional[str] = None
mobile_phone: Optional[str] = None
access_group: Optional[str] = None
email_notification: bool = False
sms_notification: bool = False
email_reminder: bool = False
sms_reminder: bool = False
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookedResourceType:
# @ApiMember(Description="The resource type id")
id: int = 0
"""
The resource type id
"""
# @ApiMember(Description="The resource type name")
name: Optional[str] = None
"""
The resource type name
"""
# @ApiMember(Description="The resources inside resource type")
resources: Optional[List[BookedResource]] = None
"""
The resources inside resource type
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookedCompany:
id: Optional[str] = None
name: Optional[str] = None
logo_type: Optional[str] = None
category: Optional[str] = None
street1: Optional[str] = None
street2: Optional[str] = None
zip_code: Optional[str] = None
city: Optional[str] = None
country_id: Optional[str] = None
longitude: Optional[str] = None
latitude: Optional[str] = None
phone: Optional[str] = None
email: Optional[str] = None
home_page: Optional[str] = None
site_path: Optional[str] = None
is_favorite: bool = False
payment_provider_id: Optional[int] = None
@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 BookedQuantity:
# @ApiMember(Description="The quantity Id")
id: int = 0
"""
The quantity Id
"""
# @ApiMember(Description="The quantity for booked on this price category")
quantity: int = 0
"""
The quantity for booked on this price category
"""
# @ApiMember(Description="The price")
price: Optional[float] = None
"""
The price
"""
# @ApiMember(Description="The price bofore rebate codes")
price_before_rebate: Optional[float] = None
"""
The price bofore rebate codes
"""
# @ApiMember(Description="The price currency")
currency_id: Optional[str] = None
"""
The price currency
"""
# @ApiMember(Description="The price sign")
price_sign: Optional[str] = None
"""
The price sign
"""
# @ApiMember(Description="The price category")
category: Optional[str] = None
"""
The price category
"""
# @ApiMember(Description="The price VAT in percent")
vat: Optional[Decimal] = None
"""
The price VAT in percent
"""
# @ApiMember(Description="The price text to display")
price_text: Optional[str] = None
"""
The price text to display
"""
# @ApiMember(Description="If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.")
occupies_spot: bool = False
"""
If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.
"""
@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 BookingLogEventTypeResponse:
# @ApiMember(Description="The event type id")
id: int = 0
"""
The event type id
"""
# @ApiMember(Description="The event type name")
name: Optional[str] = None
"""
The event type name
"""
# @ApiMember(Description="The event type description")
description: Optional[str] = None
"""
The event type description
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingLogQueryResponse:
# @ApiMember(Description="The booking log id")
id: int = 0
"""
The booking log id
"""
# @ApiMember(Description="The booking id")
booking_id: int = 0
"""
The booking id
"""
# @ApiMember(Description="The type of event")
event_type_id: int = 0
"""
The type of event
"""
# @ApiMember(Description="The type of event")
event_type: Optional[BookingLogEventTypeResponse] = None
"""
The type of event
"""
# @ApiMember(Description="Comments that could be added to the event log item")
comments: Optional[str] = None
"""
Comments that could be added to the event log item
"""
# @ApiMember(Description="The user created the event")
user_name: Optional[str] = None
"""
The user created the event
"""
# @ApiMember(Description="Then date when the event occured")
created: datetime.datetime = datetime.datetime(1, 1, 1)
"""
Then date when the event occured
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CurrencyInfoResponse:
# @ApiMember(Description="The currency id")
id: Optional[str] = None
"""
The currency id
"""
# @ApiMember(Description="The currency id")
name: Optional[str] = None
"""
The currency id
"""
# @ApiMember(Description="The currency id")
currency_sign: Optional[str] = None
"""
The currency id
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingPaymentLogQueryResponse:
# @ApiMember(Description="The booking payment log id")
id: int = 0
"""
The booking payment log id
"""
# @ApiMember(Description="The booking id")
booking_id: int = 0
"""
The booking id
"""
# @ApiMember(Description="The payment reference id")
payment_reference_id: Optional[str] = None
"""
The payment reference id
"""
# @ApiMember(Description="The payment order item reference id")
order_item_reference_id: Optional[str] = None
"""
The payment order item reference id
"""
# @ApiMember(Description="The payment reference id")
payment_provider_id: Optional[int] = None
"""
The payment reference id
"""
# @ApiMember(Description="The payment amount")
amount: float = 0.0
"""
The payment amount
"""
# @ApiMember(Description="The payment VAT in percent")
vat: Decimal = decimal.Decimal(0)
"""
The payment VAT in percent
"""
# @ApiMember(Description="The payment amount that is credited")
amount_credited: float = 0.0
"""
The payment amount that is credited
"""
# @ApiMember(Description="The payment currency id")
currency_id: Optional[str] = None
"""
The payment currency id
"""
# @ApiMember(Description="The payment currency info")
currency_info: Optional[CurrencyInfoResponse] = None
"""
The payment currency info
"""
# @ApiMember(Description="Comments that could be added to the event log item")
comments: Optional[str] = None
"""
Comments that could be added to the event log item
"""
# @ApiMember(Description="The date when the payment items was created")
created: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the payment items was created
"""
# @ApiMember(Description="The date when the payment items was update")
updated: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the payment items was update
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingCheckoutQueryResponse:
# @ApiMember(Description="The checkout id")
id: Optional[str] = None
"""
The checkout id
"""
# @ApiMember(Description="The booking id")
booking_id: int = 0
"""
The booking id
"""
# @ApiMember(Description="The purchase id")
purchase_id: Optional[int] = None
"""
The purchase id
"""
# @ApiMember(Description="The payment checkout expiration datetime")
expiration_time: Optional[datetime.datetime] = None
"""
The payment checkout expiration datetime
"""
# @ApiMember(Description="The payment snippet code")
snippet: Optional[str] = None
"""
The payment snippet code
"""
# @ApiMember(Description="The payment status")
status: Optional[str] = None
"""
The payment status
"""
# @ApiMember(Description="Log message")
message: Optional[str] = None
"""
Log message
"""
# @ApiMember(Description="When the checkout log item was created")
created: datetime.datetime = datetime.datetime(1, 1, 1)
"""
When the checkout log item was created
"""
# @ApiMember(Description="When the checkout log item was updated")
updated: datetime.datetime = datetime.datetime(1, 1, 1)
"""
When the checkout log item was updated
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ExternalReferenceResponse:
company_id: Optional[str] = None
id: Optional[str] = None
owner_id: Optional[str] = None
reference_type: Optional[str] = None
external_data: Optional[str] = None
created_by: Optional[str] = None
updated: datetime.datetime = datetime.datetime(1, 1, 1)
created: datetime.datetime = datetime.datetime(1, 1, 1)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingCalendarExportStatus:
calendar_id: Optional[str] = None
booking_id: int = 0
synced: Optional[bool] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BookingQueryResponse:
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
status_info: Optional[BookingStatusQueryResponse] = None
send_email_reminder: bool = False
send_sms_reminder: bool = False
send_sms_confirmation: bool = False
send_email_confirmation: bool = False
last_time_to_un_book: Optional[datetime.datetime] = None
custom_fields: Optional[List[CustomFieldConfigData]] = None
custom_field_values: Optional[List[CustomFieldDataResponse]] = None
booked_resource_types: Optional[List[BookedResourceType]] = None
company: Optional[BookedCompany] = None
customer: Optional[BookedCustomer] = None
quantities: Optional[List[BookedQuantity]] = None
service: Optional[ServiceInfoResponse] = None
payment_expiration: Optional[datetime.datetime] = None
log: Optional[List[BookingLogQueryResponse]] = None
payment_log: Optional[List[BookingPaymentLogQueryResponse]] = None
checkout_log: Optional[List[BookingCheckoutQueryResponse]] = None
external_reference: Optional[List[ExternalReferenceResponse]] = None
response_status: Optional[ResponseStatus] = None
calendar_export_status: Optional[BookingCalendarExportStatus] = None
length_in_minutes: Optional[int] = None
booked_by: Optional[str] = None
booked_comments: Optional[str] = None
unbooked_comments: Optional[str] = None
comments_to_customer: Optional[str] = None
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
updated_date: datetime.datetime = datetime.datetime(1, 1, 1)
unbooked_on: Optional[datetime.datetime] = None
cancellation_code: Optional[str] = None
rating_code: Optional[str] = None
# @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 ChangeResourceOnBooking(ICompany):
# @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="Id of the booking", IsRequired=true, ParameterType="path")
id: Optional[int] = None
"""
Id of the booking
"""
# @ApiMember(Description="The resource type id")
resource_type_id: int = 0
"""
The resource type id
"""
# @ApiMember(Description="The resource id you want to replace")
resource_id: int = 0
"""
The resource id you want to replace
"""
# @ApiMember(Description="The resource id to be replaced with")
new_resource_id: int = 0
"""
The resource id to be replaced with
"""
Python ChangeResourceOnBooking DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /bookings/{Id}/resource HTTP/1.1
Host: testapi.bokamera.se
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","Id":0,"ResourceTypeId":0,"ResourceId":0,"NewResourceId":0}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"Id":0,"Status":"Booked","StatusId":0,"StatusName":"String","StatusInfo":{"Id":0,"Name":"String","Description":"String","Icon":"String","Color":"String"},"SendEmailReminder":false,"SendSmsReminder":false,"SendSmsConfirmation":false,"SendEmailConfirmation":false,"LastTimeToUnBook":"0001-01-01T00:00:00","CustomFields":[{"Id":0,"Name":"String","Description":"String","Width":0,"DataType":"String","DefaultValue":"String","IsMandatory":false,"MandatoryErrorMessage":"String","MaxLength":0,"MultipleLineText":false,"RegEx":"String","RegExErrorMessage":"String","Values":[{"Value":"String"}]}],"CustomFieldValues":[{"Id":0,"Column":"String","Name":"String","Description":"String","Value":"String","DataType":"String"}],"BookedResourceTypes":[{"Id":0,"Name":"String","Resources":[{"Id":0,"Name":"String","Color":"String","Email":"String","MobilePhone":"String","AccessGroup":"String","EmailNotification":false,"SMSNotification":false,"EmailReminder":false,"SMSReminder":false}]}],"Company":{"Name":"String","Category":"String","Street1":"String","Street2":"String","ZipCode":"String","City":"String","CountryId":"String","Longitude":"String","Latitude":"String","Phone":"String","Email":"String","HomePage":"String","SitePath":"String","IsFavorite":false,"PaymentProviderId":0},"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"},"Quantities":[{"Id":0,"Quantity":0,"Price":0,"PriceBeforeRebate":0,"CurrencyId":"String","PriceSign":"String","Category":"String","VAT":0,"PriceText":"String","OccupiesSpot":false}],"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},"PaymentExpiration":"0001-01-01T00:00:00","Log":[{"Id":0,"BookingId":0,"EventTypeId":0,"EventType":{"Id":0,"Name":"String","Description":"String"},"Comments":"String","UserName":"String"}],"PaymentLog":[{"Id":0,"BookingId":0,"PaymentReferenceId":"String","OrderItemReferenceId":"String","PaymentProviderId":0,"Amount":0,"VAT":0,"AmountCredited":0,"CurrencyId":"String","CurrencyInfo":{"Id":"String","Name":"String","CurrencySign":"String"},"Comments":"String"}],"CheckoutLog":[{"BookingId":0,"PurchaseId":0,"ExpirationTime":"0001-01-01T00:00:00","Snippet":"String","Status":"String","Message":"String"}],"ExternalReference":[{"ReferenceType":"String","ExternalData":"String","CreatedBy":"String"}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}},"CalendarExportStatus":{"CalendarId":"String","BookingId":0,"Synced":false},"LengthInMinutes":0,"BookedBy":"String","BookedComments":"String","UnbookedComments":"String","CommentsToCustomer":"String","UnbookedOn":"0001-01-01T00:00:00","CancellationCode":"String","RatingCode":"String"}