| PUT | /services/{Id}/calculateprice | Calculate price on service | Calculate an 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
Object = TypeVar('Object')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RebateCodeTypeResponse:
id: int = 0
name: Optional[str] = None
description: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AppliedRebateCodesResponse:
rebate_code_sign: Optional[str] = None
rebate_code_value: int = 0
rebate_code_type: Optional[RebateCodeTypeResponse] = None
rebate_code_id: int = 0
rebate_amount: float = 0.0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TotalPricePriceDetail:
quantity: int = 0
price: float = 0.0
vat_amount: float = 0.0
description: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TotalPriceInformationResponse:
price_sign: Optional[str] = None
currency_id: Optional[str] = None
total_price: float = 0.0
total_vat_amount: float = 0.0
total_price_before_rebate: float = 0.0
price_difference: float = 0.0
applied_codes: List[AppliedRebateCodesResponse] = field(default_factory=list)
price_details: List[TotalPricePriceDetail] = field(default_factory=list)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PriceInterval:
# @ApiMember(Description="The start date and time for the price to be calculated. Normally the booking start datetime.", IsRequired=true)
from_: datetime.datetime = field(metadata=config(field_name='from'), default=datetime.datetime(1, 1, 1))
"""
The start date and time for the price to be calculated. Normally the booking start datetime.
"""
# @ApiMember(Description="The end date and time for the price to be calculated.Normally the booking end datetime. If nothing entered it will use the service length.")
to: Optional[datetime.datetime] = None
"""
The end date and time for the price to be calculated.Normally the booking end datetime. If nothing entered it will use the service length.
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ArticleToCreateBase:
article_id: int = 0
quantity: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QuantityToBook:
# @ApiMember(Description="If service has a price, enter the price id for that price. If no price exists for the service set 0 as PriceId. If you put 0 and a price exists, it will use that price (only works if just one price exists for the current selected date to book)", IsRequired=true)
price_id: int = 0
"""
If service has a price, enter the price id for that price. If no price exists for the service set 0 as PriceId. If you put 0 and a price exists, it will use that price (only works if just one price exists for the current selected date to book)
"""
# @ApiMember(Description="Set the number of spots or resources you want to book on the specific price category", IsRequired=true)
quantity: int = 0
"""
Set the number of spots or resources you want to book on the specific price category
"""
# @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 CalculateTotalPriceOnService(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 service", IsRequired=true, ParameterType="path")
id: int = 0
"""
Id of the service
"""
# @ApiMember(Description="Optional booking id. If provided, the response will also contain the price difference compared to the existing booking price.")
booking_id: Optional[int] = None
"""
Optional booking id. If provided, the response will also contain the price difference compared to the existing booking price.
"""
# @ApiMember(Description="The price interval to be used for calculations", IsRequired=true)
interval: Optional[PriceInterval] = None
"""
The price interval to be used for calculations
"""
# @ApiMember(Description="Rebate codes applied to booking")
rebate_code_ids: List[int] = field(default_factory=list)
"""
Rebate codes applied to booking
"""
# @ApiMember(Description="DEPRECATED — use Articles instead. Article ids that should be included in the price calculation. The articles must be of type ServiceAddonArticle and connected to the service. Duplicate ids are counted as quantity.")
article_ids: List[int] = field(default_factory=list)
"""
DEPRECATED — use Articles instead. Article ids that should be included in the price calculation. The articles must be of type ServiceAddonArticle and connected to the service. Duplicate ids are counted as quantity.
"""
# @ApiMember(Description="Articles (with quantity) that should be included in the price calculation. The articles must be of type ServiceAddonArticle and connected to the service.")
articles: List[ArticleToCreateBase] = field(default_factory=list)
"""
Articles (with quantity) that should be included in the price calculation. The articles must be of type ServiceAddonArticle and connected to the service.
"""
# @ApiMember(Description="If you have selected to include the prices, here you can include the quantities to book to get the correct total price.")
quantities: List[QuantityToBook] = field(default_factory=list)
"""
If you have selected to include the prices, here you can include the quantities to book to get the correct total price.
"""
# @ApiMember(Description="")
customer_email: Optional[str] = None
"""
"""
Python CalculateTotalPriceOnService DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /services/{Id}/calculateprice HTTP/1.1
Host: testapi.bokamera.se
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"CompanyId":"00000000-0000-0000-0000-000000000000","Id":0,"BookingId":0,"Interval":{"To":"0001-01-01T00:00:00"},"RebateCodeIds":[0],"ArticleIds":[0],"Articles":[{"ArticleId":0,"Quantity":0}],"Quantities":[{"PriceId":0,"Quantity":0,"OccupiesSpot":false}],"CustomerEmail":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"PriceSign":"String","CurrencyId":"String","TotalPrice":0,"TotalVatAmount":0,"TotalPriceBeforeRebate":0,"PriceDifference":0,"AppliedCodes":[{"RebateCodeSign":"String","RebateCodeValue":0,"RebateCodeType":{"Id":0,"Name":"String","Description":"String"},"RebateCodeId":0,"RebateAmount":0}],"PriceDetails":[{"Quantity":0,"Price":0,"VatAmount":0,"Description":"String"}]}