Get Premium Amount API
The FTOS_IP_PremiumAmountAPI endpoint is responsible for running the premium amount Formulas attached to product items and getting the prices for each item.
A user gets the price for a product item configured for an insurance product of type Home.
var p = {
"insuranceTypeName": "Home",
"productCode": "BA_EMB",
"insuranceProductItemDetails": [{
"code": "HHR0",
"calculationDetails": {
"risks": [{
"Risk": "Earthquake",
"Module": "M1",
"Price": 0
}, {
"Risk": "Land Slide",
"Module": "M1",
"Price": 0
}, {
"Risk": "Floods",
"Module": "M1",
"Price": 0
}, {
"Risk": "Windstorm",
"Module": "M1",
"Price": 0
}],
"propertyInsuredAmount": 100000,
"propertyConstructionYear": 1980
}
}, {
"code": "HA",
"calculationDetails": {
"buildingInsuredAmount": 23.45,
"constructionYear": 100
}
}]
};
ebs.callActionByNameAsync("FTOS_IP_PremiumAmountAPI",p)
.then(function(e){
console.log(e)
})
Here is the list of data parameters included in the request:
| Parameter | Description |
|---|---|
| insuranceTypeName | The name of an Insurance Type configured in the system and stored on the FTOS_IP_InsuranceType entity. |
| productCode | The code of the Insurance Product. |
| insuranceProductItemDetails | Array with details related to the insured Product Item. The array is used to identify and run the formulas for the specific Item. |
| code | The code of the Item. |
| calculationDetails | Object containing the keys needed to run the formula. The object structure can be different for each item, based on the formula configuration. |
This is an example of a response:
{
"isSuccess": true,
"errorMessage": null,
"errorCode": null,
"result": [
{
"insuranceProductItemFormula": "EmbededBankAssurancePremiumAmountFormula",
"formulaResult": {
"risks": [
{
"Risk": "Earthquake",
"Module": "M1",
"Price": 0
},
{
"Risk": "Land Slide",
"Module": "M1",
"Price": 0
},
{
"Risk": "Floods",
"Module": "M1",
"Price": 0
},
{
"Risk": "Windstorm",
"Module": "M1",
"Price": 0
}
],
"propertyInsuredAmount": 100000,
"propertyConstructionYear": 1980,
"risksCalculatedPrices": [
{
"Risk": "Earthquake",
"Module": "M1",
"Price": 0.0054
},
{
"Risk": "Land Slide",
"Module": "M1",
"Price": 0.001
},
{
"Risk": "Floods",
"Module": "M1",
"Price": 0.001
},
{
"Risk": "Windstorm",
"Module": "M1",
"Price": 0.013
}
],
"baseQuotation": 0.0204,
"premiumAmount": 20.4
}
},
{
"insuranceProductItemFormula": "HomeAssistance",
"formulaResult": {
"buildingInsuredAmount": 23.45,
"constructionYear": 100,
"coefHomeAssistancePrice": 0.001,
"premiumAmount": 0.0002345
}
}
]
}
| Key | Description |
|---|---|
| Error code | Error code. |
| Error message | Error message. |
| isSuccess | Marks whether the request was successful or not. |
| result | Array of objects containing details about the prices. |
| insuranceProductItemFormula | Name of the FTOS_IP_InsuranceProductItemFormula record, containing the Formula attached to the Item. |
| formulaResult | The result returned by the Formula. |
The following are the error messages that can be encountered while calling the Premium Amount API:
| Code | Text | Description |
|---|---|---|
| ERR.IP.01 | ERR.IP.01 - Invalid request! | Missing parameters. |
| ERR.IP.02 | ERR.IP.02 - No product identified! | Your insurance product might be in Draft status. Activate your product. |
| ERR.IP.03 | ERR.IP.03 - Product doesn't have any product items configured! | There are no product items to calculate premiums for. Configure at least one product item for your insurance product. |
| ERR.IP.04 | ERR.IP.04 - Invalid insurance item code! | Invalid product item code. |
The FTOS_IP_PremiumAmountAPI endpoint calculates the premium amount for the items included in a product configuration. The endpoint runs the formulas assigned to each item, simulating the Test Scenario functionality available on the product level.
From the FTOS_IP_InsuranceProductAPIs library, the following functions are used for getting the price for the items:
This function validates the request fields.
Input parameters: inputData - The object containing the keys needed to call the endpoint.
Output parameters: An object containing the following keys to describe the result of the validation:
-
isSuccess- true/ false - The boolean that shows whether the validation is successful. -
errorMessage- A null value or an error message as described in the error messages list. -
errorCode- A null value or an error code as described in the error messages list. -
result= An empty array [] or an array with details about the price, as described in the response description section.
This function runs the formulas attached to the specified items - identified by the code provided in the request. The function uses other helper functions, implemented in the same library, to get the product details, the list of items, and the formulas attached to the specified items. The calculatePremium() function is called inside the endpoint only if the isSuccess key from the response of the validateRequest function is true.
Input parameters: inputData - The object containing the keys needed to call the endpoint.
Output parameters: An array containing objects with 2 keys:
-
insuranceProductItemFormula- The name of the formula used to calculate the price for the item. -
formulaResult- The actual result returned when calling the formula.