Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /services/prices/ | Create a price | Create a new price on the service |
---|
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 DayOfWeekDto:
day_of_week_id: int = 0
dot_net_day_of_week_id: int = 0
day_of_week: 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 ServicePriceResponse:
# @ApiMember(Description="The company id")
company_id: Optional[str] = None
"""
The company id
"""
# @ApiMember(Description="The price id")
id: int = 0
"""
The price id
"""
# @ApiMember(Description="The service id")
service_id: int = 0
"""
The service id
"""
# @ApiMember(Description="The price")
price: float = 0.0
"""
The price
"""
# @ApiMember(Description="The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day")
calculation_type_id: int = 0
"""
The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day
"""
# @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 VAT in percent")
vat: Decimal = decimal.Decimal(0)
"""
The price VAT in percent
"""
# @ApiMember(Description="The price category if price has a category")
category: Optional[str] = None
"""
The price category if price has a category
"""
# @ApiMember(Description="The price text to display")
price_text: Optional[str] = None
"""
The price text to display
"""
# @ApiMember(Description="The valid from date for the price.")
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
The valid from date for the price.
"""
# @ApiMember(Description="The valid to date for the price.")
to: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The valid to date for the price.
"""
# @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
days_of_week: Optional[List[DayOfWeekDto]] = None
"""
If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.
"""
# @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
from_time: Optional[datetime.timedelta] = None
"""
If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.
"""
# @ApiMember(Description="If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.")
to_time: Optional[datetime.timedelta] = None
"""
If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.
"""
service: Optional[ServiceInfoResponse] = None
# @ApiMember(Description="If the price is only valid for a specific time span")
is_time_specific: bool = False
"""
If the price is only valid for a specific time span
"""
# @ApiMember(Description="If the price is only valid for specific days of week")
is_days_of_week_specific: bool = False
"""
If the price is only valid for specific days of week
"""
# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CreateServicePrice(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="The service id", IsRequired=true)
service_id: int = 0
"""
The service id
"""
# @ApiMember(Description="The price", IsRequired=true)
price: float = 0.0
"""
The price
"""
# @ApiMember(Description="The price currency", IsRequired=true)
currency_id: Optional[str] = None
"""
The price currency
"""
# @ApiMember(Description="The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day", IsRequired=true)
calculation_type_id: int = 0
"""
The price calculation type id, 1 = Normal, price is for the service total duration, 2 = Price is per minute, 3 = Price is per hour, 4= Price is per day
"""
# @ApiMember(Description="The price VAT in percent", IsRequired=true)
vat: Decimal = decimal.Decimal(0)
"""
The price VAT in percent
"""
# @ApiMember(Description="The price category if price has a category")
category: Optional[str] = None
"""
The price category if price has a category
"""
# @ApiMember(Description="The valid from date for the price.")
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
The valid from date for the price.
"""
# @ApiMember(Description="The valid to date for the price.")
to: datetime.datetime = datetime.datetime(1, 1, 1)
"""
The valid to date for the price.
"""
# @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
days_of_week: Optional[List[int]] = None
"""
If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.
"""
# @ApiMember(Description="If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.")
from_time: Optional[datetime.timedelta] = None
"""
If the price is only valid for specific days in week add a comma separated list of which days this day price belongs to, 1 = Monday .. 7 = Sunday. All old days connected will be removed on update.
"""
# @ApiMember(Description="If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.")
to_time: Optional[datetime.timedelta] = None
"""
If the price is only valid for a specific time span during a time of day enter the FromTime and ToTime parameters.
"""
Python CreateServicePrice DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /services/prices/ HTTP/1.1
Host: api.bokamera.se
Accept: application/json
Content-Type: application/json
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","ServiceId":0,"Price":0,"CurrencyId":"String","CalculationTypeId":0,"VAT":0,"Category":"String","DaysOfWeek":[0],"FromTime":"00:00:00","ToTime":"00:00:00"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"Id":0,"ServiceId":0,"Price":0,"CalculationTypeId":0,"CurrencyId":"String","PriceSign":"String","VAT":0,"Category":"String","PriceText":"String","DaysOfWeek":[{"DayOfWeekId":0,"DotNetDayOfWeekId":0,"DayOfWeek":"String"}],"FromTime":"00:00:00","ToTime":"00:00:00","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},"IsTimeSpecific":false,"IsDaysOfWeekSpecific":false}