BokaMera.API.Host

<back to all web services

UpdateServicePrice

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
PUT/services/prices/{Id}Update a priceUpdate a price on a 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
    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
    """


    # @ApiMember(Description="If the price is Weighted")
    is_weighted: bool = False
    """
    If the price is Weighted
    """


# @ValidateRequest(Validator="IsAuthenticated")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class UpdateServicePrice(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 price", IsRequired=true, ParameterType="path")
    id: int = 0
    """
    Id of the price
    """


    # @ApiMember(Description="The price")
    price: float = 0.0
    """
    The price
    """


    # @ApiMember(Description="The price currency")
    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")
    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")
    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 UpdateServicePrice DTOs

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

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

PUT /services/prices/{Id} HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<UpdateServicePrice xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <CalculationTypeId>0</CalculationTypeId>
  <Category>String</Category>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CurrencyId>String</CurrencyId>
  <DaysOfWeek xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:int>0</d2p1:int>
  </DaysOfWeek>
  <From>0001-01-01T00:00:00</From>
  <FromTime>PT0S</FromTime>
  <Id>0</Id>
  <Price>0</Price>
  <To>0001-01-01T00:00:00</To>
  <ToTime>PT0S</ToTime>
  <VAT>0</VAT>
</UpdateServicePrice>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ServicePriceResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <CalculationTypeId>0</CalculationTypeId>
  <Category>String</Category>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <CurrencyId>String</CurrencyId>
  <DaysOfWeek>
    <DayOfWeekDto>
      <DayOfWeek>String</DayOfWeek>
      <DayOfWeekId>0</DayOfWeekId>
      <DotNetDayOfWeekId>0</DotNetDayOfWeekId>
    </DayOfWeekDto>
  </DaysOfWeek>
  <From>0001-01-01T00:00:00</From>
  <FromTime>PT0S</FromTime>
  <Id>0</Id>
  <IsDaysOfWeekSpecific>false</IsDaysOfWeekSpecific>
  <IsTimeSpecific>false</IsTimeSpecific>
  <IsWeighted>false</IsWeighted>
  <Price>0</Price>
  <PriceSign>String</PriceSign>
  <PriceText>String</PriceText>
  <Service>
    <Description>String</Description>
    <GroupBooking>
      <Active>false</Active>
      <Max>0</Max>
      <Min>0</Min>
    </GroupBooking>
    <Id>0</Id>
    <ImageUrl i:nil="true" />
    <IsGroupBooking>false</IsGroupBooking>
    <IsPaymentEnabled>false</IsPaymentEnabled>
    <LengthInMinutes>0</LengthInMinutes>
    <MaxNumberOfSpotsPerBooking>0</MaxNumberOfSpotsPerBooking>
    <MultipleResource>
      <Active>false</Active>
      <Max>0</Max>
      <Min>0</Min>
    </MultipleResource>
    <Name>String</Name>
  </Service>
  <ServiceId>0</ServiceId>
  <To>0001-01-01T00:00:00</To>
  <ToTime>PT0S</ToTime>
  <VAT>0</VAT>
</ServicePriceResponse>