BokaMera.API.Host

<back to all web services

CalculateTotalPriceOnService

The following routes are available for this service:
PUT/services/{Id}/calculatepriceCalculate price on serviceCalculate an price on a service.
import 'package:servicestack/servicestack.dart';

class RebateCodeTypeItem implements IConvertible
{
    int? Id;
    String? Name;
    String? Description;

    RebateCodeTypeItem({this.Id,this.Name,this.Description});
    RebateCodeTypeItem.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() => "RebateCodeTypeItem";
    TypeContext? context = _ctx;
}

class AppliedRebateCodesResponse implements IConvertible
{
    String? RebateCodeSign;
    int? RebateCodeValue;
    RebateCodeTypeItem? 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'],'RebateCodeTypeItem',context!);
        RebateCodeId = json['RebateCodeId'];
        RebateAmount = JsonConverters.toDouble(json['RebateAmount']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'RebateCodeSign': RebateCodeSign,
        'RebateCodeValue': RebateCodeValue,
        'RebateCodeType': JsonConverters.toJson(RebateCodeType,'RebateCodeTypeItem',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;

    /**
    * If you have selected to include the prices, here you can include the rebate codes
    */
    // @ApiMember(Description="If you have selected to include the prices, here you can include the rebate codes")
    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;

    CalculateTotalPriceOnService({this.CompanyId,this.Id,this.Interval,this.RebateCodeIds,this.Quantities});
    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!);
        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!)
    };

    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: 'testapi.bokamera.se', types: <String, TypeInfo> {
    'RebateCodeTypeItem': TypeInfo(TypeOf.Class, create:() => RebateCodeTypeItem()),
    '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 .other suffix or ?format=other

HTTP + 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,"Interval":{"To":"0001-01-01T00:00:00"},"RebateCodeIds":[0],"Quantities":[{"PriceId":0,"Quantity":0,"OccupiesSpot":false}]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"PriceSign":"String","CurrencyId":"String","TotalPrice":0,"TotalVatAmount":0,"TotalPriceBeforeRebate":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"}]}