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 .jsv suffix or ?format=jsv

HTTP + JSV

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: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	CompanyId: 00000000-0000-0000-0000-000000000000,
	Id: 0,
	Price: 0,
	CurrencyId: String,
	CalculationTypeId: 0,
	VAT: 0,
	Category: String,
	DaysOfWeek: 
	[
		0
	],
	FromTime: PT0S,
	ToTime: PT0S
}
HTTP/1.1 200 OK
Content-Type: text/jsv
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: PT0S,
	ToTime: PT0S,
	Service: 
	{
		Id: 0,
		Name: String,
		Description: String,
		LengthInMinutes: 0,
		MaxNumberOfSpotsPerBooking: 0,
		GroupBooking: 
		{
			Active: False,
			Min: 0,
			Max: 0
		},
		MultipleResource: 
		{
			Active: False,
			Min: 0,
			Max: 0
		},
		IsGroupBooking: False,
		IsPaymentEnabled: False
	},
	IsTimeSpecific: False,
	IsDaysOfWeekSpecific: False,
	IsWeighted: False
}