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;
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;
RebateCodeTypeResponse? RebateCodeType;
int? RebateCodeId;
double? RebateAmount;
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;
double? Price;
double? VatAmount;
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;
double? TotalVatAmount;
double? TotalPriceBeforeRebate;
List<AppliedRebateCodesResponse>? AppliedCodes;
List<TotalPricePriceDetail>? PriceDetails;
TotalPriceInformationResponse({this.PriceSign,this.CurrencyId,this.TotalPrice,this.TotalVatAmount,this.TotalPriceBeforeRebate,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']);
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,
'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;
/**
* 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 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;
/**
* 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;
/**
* 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.Interval,this.RebateCodeIds,this.Quantities,this.CustomerEmail});
CalculateTotalPriceOnService.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
CompanyId = json['CompanyId'];
Id = json['Id'];
Interval = JsonConverters.fromJson(json['Interval'],'PriceInterval',context!);
RebateCodeIds = JsonConverters.fromJson(json['RebateCodeIds'],'List<int>',context!);
Quantities = JsonConverters.fromJson(json['Quantities'],'List<QuantityToBook>',context!);
CustomerEmail = json['CustomerEmail'];
return this;
}
Map<String, dynamic> toJson() => {
'CompanyId': CompanyId,
'Id': Id,
'Interval': JsonConverters.toJson(Interval,'PriceInterval',context!),
'RebateCodeIds': JsonConverters.toJson(RebateCodeIds,'List<int>',context!),
'Quantities': JsonConverters.toJson(Quantities,'List<QuantityToBook>',context!),
'CustomerEmail': CustomerEmail
};
getTypeName() => "CalculateTotalPriceOnService";
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;
/**
* 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;
/**
* 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;
}
TypeContext _ctx = TypeContext(library: 'api.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()),
'CalculateTotalPriceOnService': TypeInfo(TypeOf.Class, create:() => CalculateTotalPriceOnService()),
'List<QuantityToBook>': TypeInfo(TypeOf.Class, create:() => <QuantityToBook>[]),
'QuantityToBook': TypeInfo(TypeOf.Class, create:() => QuantityToBook()),
});
Dart CalculateTotalPriceOnService DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
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: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CalculateTotalPriceOnService xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<CustomerEmail>String</CustomerEmail>
<Id>0</Id>
<Interval>
<From>0001-01-01T00:00:00</From>
<To>0001-01-01T00:00:00</To>
</Interval>
<Quantities>
<QuantityToBook>
<OccupiesSpot>false</OccupiesSpot>
<PriceId>0</PriceId>
<Quantity>0</Quantity>
</QuantityToBook>
</Quantities>
<RebateCodeIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</RebateCodeIds>
</CalculateTotalPriceOnService>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <TotalPriceInformationResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <AppliedCodes> <AppliedRebateCodesResponse> <RebateAmount>0</RebateAmount> <RebateCodeId>0</RebateCodeId> <RebateCodeSign>String</RebateCodeSign> <RebateCodeType> <Description>String</Description> <Id>0</Id> <Name>String</Name> </RebateCodeType> <RebateCodeValue>0</RebateCodeValue> </AppliedRebateCodesResponse> </AppliedCodes> <CurrencyId>String</CurrencyId> <PriceDetails> <TotalPricePriceDetail> <Description>String</Description> <Price>0</Price> <Quantity>0</Quantity> <VatAmount>0</VatAmount> </TotalPricePriceDetail> </PriceDetails> <PriceSign>String</PriceSign> <TotalPrice>0</TotalPrice> <TotalPriceBeforeRebate>0</TotalPriceBeforeRebate> <TotalVatAmount>0</TotalVatAmount> </TotalPriceInformationResponse>