| PUT | /services/{Id}/calculateprice | Calculate price on service | Calculate an price on a service. |
|---|
import 'package:servicestack/servicestack.dart';
class RebateCodeTypeResponse implements IConvertible
{
int Id = 0;
String Name = "";
String Description = "";
RebateCodeTypeResponse({this.Id,this.Name,this.Description});
RebateCodeTypeResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
Id = json['Id'];
Name = json['Name'];
Description = json['Description'];
return this;
}
Map<String, dynamic> toJson() => {
'Id': Id,
'Name': Name,
'Description': Description
};
getTypeName() => "RebateCodeTypeResponse";
TypeContext? context = _ctx;
}
class AppliedRebateCodesResponse implements IConvertible
{
String RebateCodeSign = "";
int RebateCodeValue = 0;
RebateCodeTypeResponse RebateCodeType;
int RebateCodeId = 0;
double RebateAmount = 0;
AppliedRebateCodesResponse({this.RebateCodeSign,this.RebateCodeValue,this.RebateCodeType,this.RebateCodeId,this.RebateAmount});
AppliedRebateCodesResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
RebateCodeSign = json['RebateCodeSign'];
RebateCodeValue = json['RebateCodeValue'];
RebateCodeType = JsonConverters.fromJson(json['RebateCodeType'],'RebateCodeTypeResponse',context!);
RebateCodeId = json['RebateCodeId'];
RebateAmount = JsonConverters.toDouble(json['RebateAmount']);
return this;
}
Map<String, dynamic> toJson() => {
'RebateCodeSign': RebateCodeSign,
'RebateCodeValue': RebateCodeValue,
'RebateCodeType': JsonConverters.toJson(RebateCodeType,'RebateCodeTypeResponse',context!),
'RebateCodeId': RebateCodeId,
'RebateAmount': RebateAmount
};
getTypeName() => "AppliedRebateCodesResponse";
TypeContext? context = _ctx;
}
class TotalPricePriceDetail implements IConvertible
{
int Quantity = 0;
double Price = 0;
double VatAmount = 0;
String Description = "";
TotalPricePriceDetail({this.Quantity,this.Price,this.VatAmount,this.Description});
TotalPricePriceDetail.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
Quantity = json['Quantity'];
Price = JsonConverters.toDouble(json['Price']);
VatAmount = JsonConverters.toDouble(json['VatAmount']);
Description = json['Description'];
return this;
}
Map<String, dynamic> toJson() => {
'Quantity': Quantity,
'Price': Price,
'VatAmount': VatAmount,
'Description': Description
};
getTypeName() => "TotalPricePriceDetail";
TypeContext? context = _ctx;
}
class TotalPriceInformationResponse implements IConvertible
{
String PriceSign = "";
String CurrencyId = "";
double TotalPrice = 0;
double TotalVatAmount = 0;
double TotalPriceBeforeRebate = 0;
double PriceDifference = 0;
List<AppliedRebateCodesResponse> AppliedCodes = [];
List<TotalPricePriceDetail> PriceDetails = [];
TotalPriceInformationResponse({this.PriceSign,this.CurrencyId,this.TotalPrice,this.TotalVatAmount,this.TotalPriceBeforeRebate,this.PriceDifference,this.AppliedCodes,this.PriceDetails});
TotalPriceInformationResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
PriceSign = json['PriceSign'];
CurrencyId = json['CurrencyId'];
TotalPrice = JsonConverters.toDouble(json['TotalPrice']);
TotalVatAmount = JsonConverters.toDouble(json['TotalVatAmount']);
TotalPriceBeforeRebate = JsonConverters.toDouble(json['TotalPriceBeforeRebate']);
PriceDifference = JsonConverters.toDouble(json['PriceDifference']);
AppliedCodes = JsonConverters.fromJson(json['AppliedCodes'],'List<AppliedRebateCodesResponse>',context!);
PriceDetails = JsonConverters.fromJson(json['PriceDetails'],'List<TotalPricePriceDetail>',context!);
return this;
}
Map<String, dynamic> toJson() => {
'PriceSign': PriceSign,
'CurrencyId': CurrencyId,
'TotalPrice': TotalPrice,
'TotalVatAmount': TotalVatAmount,
'TotalPriceBeforeRebate': TotalPriceBeforeRebate,
'PriceDifference': PriceDifference,
'AppliedCodes': JsonConverters.toJson(AppliedCodes,'List<AppliedRebateCodesResponse>',context!),
'PriceDetails': JsonConverters.toJson(PriceDetails,'List<TotalPricePriceDetail>',context!)
};
getTypeName() => "TotalPriceInformationResponse";
TypeContext? context = _ctx;
}
class PriceInterval implements IConvertible
{
/**
* The start date and time for the price to be calculated. Normally the booking start datetime.
*/
// @ApiMember(Description="The start date and time for the price to be calculated. Normally the booking start datetime.", IsRequired=true)
DateTime From = DateTime(0);
/**
* 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.
*/
// @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.")
DateTime? To;
PriceInterval({this.From,this.To});
PriceInterval.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
From = JsonConverters.fromJson(json['From'],'DateTime',context!);
To = JsonConverters.fromJson(json['To'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'From': JsonConverters.toJson(From,'DateTime',context!),
'To': JsonConverters.toJson(To,'DateTime',context!)
};
getTypeName() => "PriceInterval";
TypeContext? context = _ctx;
}
class ArticleToCreateBase implements IConvertible
{
int ArticleId = 0;
int Quantity = 0;
ArticleToCreateBase({this.ArticleId,this.Quantity});
ArticleToCreateBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
ArticleId = json['ArticleId'];
Quantity = json['Quantity'];
return this;
}
Map<String, dynamic> toJson() => {
'ArticleId': ArticleId,
'Quantity': Quantity
};
getTypeName() => "ArticleToCreateBase";
TypeContext? context = _ctx;
}
class QuantityToBook implements IConvertible
{
/**
* 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="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)
int PriceId = 0;
/**
* Set the number of spots or resources you want to book on the specific price category
*/
// @ApiMember(Description="Set the number of spots or resources you want to book on the specific price category", IsRequired=true)
int Quantity = 0;
/**
* If the quantity you add should occupy a spot. Default is true. If no it will only be a row that includes price information.
*/
// @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.")
bool OccupiesSpot;
QuantityToBook({this.PriceId,this.Quantity,this.OccupiesSpot});
QuantityToBook.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
PriceId = json['PriceId'];
Quantity = json['Quantity'];
OccupiesSpot = json['OccupiesSpot'];
return this;
}
Map<String, dynamic> toJson() => {
'PriceId': PriceId,
'Quantity': Quantity,
'OccupiesSpot': OccupiesSpot
};
getTypeName() => "QuantityToBook";
TypeContext? context = _ctx;
}
class CalculateTotalPriceOnService implements ICompany, IConvertible
{
/**
* The company id, if empty will use the company id for the user you are logged in with.
*/
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.")
String? CompanyId;
/**
* Id of the service
*/
// @ApiMember(Description="Id of the service", IsRequired=true, ParameterType="path")
int Id = 0;
/**
* Optional booking id. If provided, the response will also contain the price difference compared to the existing booking price.
*/
// @ApiMember(Description="Optional booking id. If provided, the response will also contain the price difference compared to the existing booking price.")
int? BookingId;
/**
* The price interval to be used for calculations
*/
// @ApiMember(Description="The price interval to be used for calculations", IsRequired=true)
PriceInterval Interval;
/**
* Rebate codes applied to booking
*/
// @ApiMember(Description="Rebate codes applied to booking")
List<int> RebateCodeIds = [];
/**
* 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="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.")
List<int> ArticleIds = [];
/**
* 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="Articles (with quantity) that should be included in the price calculation. The articles must be of type ServiceAddonArticle and connected to the service.")
List<ArticleToCreateBase> Articles = [];
/**
* If you have selected to include the prices, here you can include the quantities to book to get the correct total price.
*/
// @ApiMember(Description="If you have selected to include the prices, here you can include the quantities to book to get the correct total price.")
List<QuantityToBook> Quantities = [];
/**
*
*/
// @ApiMember(Description="")
String CustomerEmail = "";
CalculateTotalPriceOnService({this.CompanyId,this.Id,this.BookingId,this.Interval,this.RebateCodeIds,this.ArticleIds,this.Articles,this.Quantities,this.CustomerEmail});
CalculateTotalPriceOnService.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
CompanyId = json['CompanyId'];
Id = json['Id'];
BookingId = json['BookingId'];
Interval = JsonConverters.fromJson(json['Interval'],'PriceInterval',context!);
RebateCodeIds = JsonConverters.fromJson(json['RebateCodeIds'],'List<int>',context!);
ArticleIds = JsonConverters.fromJson(json['ArticleIds'],'List<int>',context!);
Articles = JsonConverters.fromJson(json['Articles'],'List<ArticleToCreateBase>',context!);
Quantities = JsonConverters.fromJson(json['Quantities'],'List<QuantityToBook>',context!);
CustomerEmail = json['CustomerEmail'];
return this;
}
Map<String, dynamic> toJson() => {
'CompanyId': CompanyId,
'Id': Id,
'BookingId': BookingId,
'Interval': JsonConverters.toJson(Interval,'PriceInterval',context!),
'RebateCodeIds': JsonConverters.toJson(RebateCodeIds,'List<int>',context!),
'ArticleIds': JsonConverters.toJson(ArticleIds,'List<int>',context!),
'Articles': JsonConverters.toJson(Articles,'List<ArticleToCreateBase>',context!),
'Quantities': JsonConverters.toJson(Quantities,'List<QuantityToBook>',context!),
'CustomerEmail': CustomerEmail
};
getTypeName() => "CalculateTotalPriceOnService";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'testapi.bokamera.se', types: <String, TypeInfo> {
'RebateCodeTypeResponse': TypeInfo(TypeOf.Class, create:() => RebateCodeTypeResponse()),
'AppliedRebateCodesResponse': TypeInfo(TypeOf.Class, create:() => AppliedRebateCodesResponse()),
'TotalPricePriceDetail': TypeInfo(TypeOf.Class, create:() => TotalPricePriceDetail()),
'TotalPriceInformationResponse': TypeInfo(TypeOf.Class, create:() => TotalPriceInformationResponse()),
'List<AppliedRebateCodesResponse>': TypeInfo(TypeOf.Class, create:() => <AppliedRebateCodesResponse>[]),
'List<TotalPricePriceDetail>': TypeInfo(TypeOf.Class, create:() => <TotalPricePriceDetail>[]),
'PriceInterval': TypeInfo(TypeOf.Class, create:() => PriceInterval()),
'ArticleToCreateBase': TypeInfo(TypeOf.Class, create:() => ArticleToCreateBase()),
'QuantityToBook': TypeInfo(TypeOf.Class, create:() => QuantityToBook()),
'CalculateTotalPriceOnService': TypeInfo(TypeOf.Class, create:() => CalculateTotalPriceOnService()),
'List<ArticleToCreateBase>': TypeInfo(TypeOf.Class, create:() => <ArticleToCreateBase>[]),
'List<QuantityToBook>': TypeInfo(TypeOf.Class, create:() => <QuantityToBook>[]),
});
Dart 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"}]}