| Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
| PUT | /resource/{Id} | Update existing resource | Updates an existing resource if you are authorized to do so. |
|---|
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
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TimeException(ITimeException):
# @ApiMember(Description="Time exception id")
id: int = 0
"""
Time exception id
"""
# @ApiMember(Description="Indicates whether or not the time exception is recurring")
is_recurring: bool = False
"""
Indicates whether or not the time exception is recurring
"""
# @ApiMember(Description="Indicates whether the time exception is blocking the time or not")
is_block: bool = False
"""
Indicates whether the time exception is blocking the time or not
"""
# @ApiMember(Description="The reason of the time exception, example: Vacation, doctors appointment, ...")
reason_text: Optional[str] = None
"""
The reason of the time exception, example: Vacation, doctors appointment, ...
"""
# @ApiMember(Description="The public reason of the time exception, example: Vacation, doctors appointment, ...")
reason_text_public: Optional[str] = None
"""
The public reason of the time exception, example: Vacation, doctors appointment, ...
"""
# @ApiMember(Description="Time exception start")
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
Time exception start
"""
# @ApiMember(Description="Time exception end")
to: datetime.datetime = datetime.datetime(1, 1, 1)
"""
Time exception end
"""
# @ApiMember(Description="Resources that owns this exception")
resource_ids: List[int] = field(default_factory=list)
"""
Resources that owns this exception
"""
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 BookedTime(IBookedTime):
# @ApiMember(Description="Booking id")
id: int = 0
"""
Booking id
"""
# @ApiMember(Description="The booked service")
service_id: int = 0
"""
The booked service
"""
# @ApiMember(Description="Booking start")
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
Booking start
"""
# @ApiMember(Description="Booking end")
to: datetime.datetime = datetime.datetime(1, 1, 1)
"""
Booking end
"""
# @ApiMember(Description="Number of booked spots")
booked_spots: int = 0
"""
Number of booked spots
"""
# @ApiMember(Description="Number of total spots for the service")
total_spots: int = 0
"""
Number of total spots for the service
"""
# @ApiMember(Description="The pause after the booking")
pause_after_in_minutes: int = 0
"""
The pause after the booking
"""
# @ApiMember(Description="The booking status")
status_id: int = 0
"""
The booking status
"""
status: Optional[BookingStatusEnum] = None
# @ApiMember(Description="The customer the booking belongs to")
customer: Optional[BookedCustomer] = None
"""
The customer the booking belongs to
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ResourceQueryResponse:
# @ApiMember(Description="The resource id")
id: int = 0
"""
The resource id
"""
# @ApiMember(Description="The resource name")
name: Optional[str] = None
"""
The resource name
"""
# @ApiMember(Description="The resource description")
description: Optional[str] = None
"""
The resource description
"""
# @ApiMember(Description="If resource is active or not")
active: bool = False
"""
If resource is active or not
"""
# @ApiMember(Description="The resource color in scheduler in hexadecimal color code. Example: #00b0f0 for blue.")
color: Optional[str] = None
"""
The resource color in scheduler in hexadecimal color code. Example: #00b0f0 for blue.
"""
# @ApiMember(Description="The Email of the resource")
email: Optional[str] = None
"""
The Email of the resource
"""
# @ApiMember(Description="The Image URL of the resource")
image_url: Optional[str] = None
"""
The Image URL of the resource
"""
# @ApiMember(Description="The Mobile phone number of the resource")
mobile_phone: Optional[str] = None
"""
The Mobile phone number of the resource
"""
# @ApiMember(Description="Used by example code locks to know what access group the resource is assigned to")
access_group: Optional[str] = None
"""
Used by example code locks to know what access group the resource is assigned to
"""
# @ApiMember(Description="If the resource should receive Email notification when booked")
email_notification: bool = False
"""
If the resource should receive Email notification when booked
"""
# @ApiMember(Description="If the resource should receive SMS notification when booked")
sms_notification: bool = False
"""
If the resource should receive SMS notification when booked
"""
# @ApiMember(Description="If the resource should receive Email reminders on bookings")
send_email_reminder: Optional[bool] = None
"""
If the resource should receive Email reminders on bookings
"""
# @ApiMember(Description="If the resource should receive SMS reminders on bookings")
send_s_m_s_reminder: Optional[bool] = None
"""
If the resource should receive SMS reminders on bookings
"""
# @ApiMember(Description="The resource time exceptions")
exceptions: List[TimeException] = field(default_factory=list)
"""
The resource time exceptions
"""
# @ApiMember(Description="The resource bookings")
bookings: List[BookedTime] = field(default_factory=list)
"""
The resource bookings
"""
# @ApiMember(Description="The date when the resource was created")
created: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the resource was created
"""
# @ApiMember(Description="The date when the resource was updated")
updated: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The date when the resource was updated
"""
response_status: Optional[ResponseStatus] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AddCustomField:
id: int = 0
value: Optional[str] = None
# @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateResource(ICompany):
# @ApiMember(Description="Enter the company id, if blank company id and you are an admin, your company id will be used.", IsRequired=true)
company_id: Optional[str] = None
"""
Enter the company id, if blank company id and you are an admin, your company id will be used.
"""
# @ApiMember(Description="Id of the resource", IsRequired=true, ParameterType="path")
id: int = 0
"""
Id of the resource
"""
# @ApiMember(Description="The resource name")
name: Optional[str] = None
"""
The resource name
"""
# @ApiMember(Description="The resource description")
description: Optional[str] = None
"""
The resource description
"""
# @ApiMember(Description="If resource is active or not")
active: Optional[bool] = None
"""
If resource is active or not
"""
# @ApiMember(Description="The resource color in scheduler")
color: Optional[str] = None
"""
The resource color in scheduler
"""
# @ApiMember(Description="The Image URL of the resource")
image_url: Optional[str] = None
"""
The Image URL of the resource
"""
# @ApiMember(Description="The Email of the resource")
email: Optional[str] = None
"""
The Email of the resource
"""
# @ApiMember(Description="The Mobile phone number of the resource")
mobile_phone: Optional[str] = None
"""
The Mobile phone number of the resource
"""
# @ApiMember(Description="Used by example code locks to know what access group the resource is assigned to")
access_group: Optional[str] = None
"""
Used by example code locks to know what access group the resource is assigned to
"""
# @ApiMember(Description="If the resource should receive Email notification when booked")
email_notification: Optional[bool] = None
"""
If the resource should receive Email notification when booked
"""
# @ApiMember(Description="If the resource should receive SMS notification when booked")
sms_notification: Optional[bool] = None
"""
If the resource should receive SMS notification when booked
"""
# @ApiMember(Description="If the resource should receive Email reminders on bookings")
send_email_reminder: Optional[bool] = None
"""
If the resource should receive Email reminders on bookings
"""
# @ApiMember(Description="If the resource should receive SMS reminders on bookings")
send_s_m_s_reminder: Optional[bool] = None
"""
If the resource should receive SMS reminders on bookings
"""
# @ApiMember(Description="If Custom Fields are added to the resource, here you will send the id and the value for each custom field to be saved")
custom_fields: List[AddCustomField] = field(default_factory=list)
"""
If Custom Fields are added to the resource, here you will send the id and the value for each custom field to be saved
"""
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 /resource/{Id} HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UpdateResource xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<AccessGroup>String</AccessGroup>
<Active>false</Active>
<Color>String</Color>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<CustomFields>
<AddCustomField>
<Id>0</Id>
<Value>String</Value>
</AddCustomField>
</CustomFields>
<Description>String</Description>
<Email>String</Email>
<EmailNotification>false</EmailNotification>
<Id>0</Id>
<ImageUrl i:nil="true" />
<MobilePhone>String</MobilePhone>
<Name>String</Name>
<SMSNotification>false</SMSNotification>
<SendEmailReminder>false</SendEmailReminder>
<SendSMSReminder>false</SendSMSReminder>
</UpdateResource>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<ResourceQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<AccessGroup>String</AccessGroup>
<Active>false</Active>
<Bookings>
<BookedTime>
<BookedSpots>0</BookedSpots>
<Customer>
<CorporateIdentityNumber>String</CorporateIdentityNumber>
<Email>String</Email>
<FacebookUserName>String</FacebookUserName>
<Firstname>String</Firstname>
<Id>00000000-0000-0000-0000-000000000000</Id>
<ImageUrl>String</ImageUrl>
<InvoiceAddress1>String</InvoiceAddress1>
<InvoiceAddress2>String</InvoiceAddress2>
<InvoiceCity>String</InvoiceCity>
<InvoiceCountryCode>String</InvoiceCountryCode>
<InvoicePostalCode>String</InvoicePostalCode>
<Lastname>String</Lastname>
<Phone>String</Phone>
</Customer>
<From>0001-01-01T00:00:00</From>
<Id>0</Id>
<PauseAfterInMinutes>0</PauseAfterInMinutes>
<ServiceId>0</ServiceId>
<Status>Booked</Status>
<StatusId>0</StatusId>
<To>0001-01-01T00:00:00</To>
<TotalSpots>0</TotalSpots>
</BookedTime>
</Bookings>
<Color>String</Color>
<Created>0001-01-01T00:00:00</Created>
<Description>String</Description>
<Email>String</Email>
<EmailNotification>false</EmailNotification>
<Exceptions>
<TimeException>
<From>0001-01-01T00:00:00</From>
<Id>0</Id>
<IsBlock>false</IsBlock>
<IsRecurring>false</IsRecurring>
<ReasonText>String</ReasonText>
<ReasonTextPublic>String</ReasonTextPublic>
<ResourceIds xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:int>0</d4p1:int>
</ResourceIds>
<To>0001-01-01T00:00:00</To>
</TimeException>
</Exceptions>
<Id>0</Id>
<ImageUrl i:nil="true" />
<MobilePhone>String</MobilePhone>
<Name>String</Name>
<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>
<SMSNotification>false</SMSNotification>
<SendEmailReminder>false</SendEmailReminder>
<SendSMSReminder>false</SendSMSReminder>
<Updated>0001-01-01T00:00:00</Updated>
</ResourceQueryResponse>