Part 2: Generating insurance quotes

Learn how to generate a personalised quote over the Root API or Dashboard.

Useful documentation

Overview and success criteria

✅ A quote can be created via API, or the Root Dashboard, with the correct premium.
✅ Quote data validation passes according to the specifications.
✅ Unit tests are written for the quote creation.
✅ Schemas have been created to get a quote on the Root Dashboard.

In this section, we want to be able to get a personalised quote over the Root API or Dashboard. To successfully achieve this, follow these four general steps:

  1. Create a quote validation schema with Joi that abides by the specifications below.
  2. Return a quote package with the correct pricing logic specified below.
  3. Write the corresponding schema in the quote-schema.json file.
  4. Create unit tests that thoroughly test validation, and pricing, and that the expected quote package is being created.

📹

Watch our explainer videos:

Watch the following videos to learn more about the policy lifecycle on Root and how to generate insurance quotes:

Quote validation, pricing and creation

When we receive specifications from clients, the team will capture business rules, input parameters and the pricing logic for the quote creation to be built. We will follow the same pattern in this section.

Business rules

RefDetails
Q1The policy start date must be provided, and it must fall within the next 60 days from quote creation.
Q2The cover amount (sum insured) must be provided, and it must fall between R10,000.00 and R100,000.00 inclusive.
Q3The year of birth of the dinosaur must be provided. The date of birth must be within 50 years of the current year (in the past).
Q4The dinosaur species must be one of the following [Tyrannosaurus Rex, Stegosaurus, Velociraptor, Diplodocus, Iguanodon].
Q5The policyholder must indicate whether the dinosaur’s health checks are up to date.

Pricing logic
Dinosure’s actuaries have determined that the monthly premium should be calculated as follows.

Core premium in rand = cover amount in cents ( 0.01 (age * 0.001))

Species dependent adjustment:
Tyrannosaurus Rex: 0.81 core premium
Stegosaurus: 1.19
core premium
Velociraptor: 0.76 core premium
Brachiosaurus: 1.32
core premium
Iguanodon: 1.07 * core premium

If health checks are not up to date, add R250 p/m to the premium.

Input parameters
Take note that the type parameter is validated by the platform and need not be validated again in the validateQuoteRequest function, but it does need to be provided in the payload to create a quote.

typestringdinosure_{{your_name}}_ext_dev
start_datedateDefined in the business rules
cover_amountintegerDefined in the business rules
birth_datedateDefined in the business rules
speciesstringDefined in the business rules
health_checks_updatedbooleanDefined in the business rules

All of the parameters defined here need to be stored in the module data of the quotePackage, and subsequently be carried over to the application and policy.

Testing
The scenarios below should have unit tests written for them to show that the logic has been implemented correctly:
A payload with valid data passes validateQuoteRequest
A payload with invalid data fails validateQuoteRequest
A 20-year-old Tyrannosaurus Rex with R90,000.00 has a premium of R1458.00
A 36-year-old Velociraptor with R50,000.00 has a premium of R1368.00
A 16-year-old Brachiosaurus with R65,000.00 has a premium of R1372.80

🏅

If you're doing the Root certification:

Once you’ve worked through the changes above, submit it as a pull request into the main branch on your Github repository. In the PR description, copy and answer the questions below in the last section Part Specific Questions. Message your facilitator to review the PR when ready.

Question: What part of the quote generation was the most confusing or difficult to get right?

You can proceed to the next part without being blocked by the facilitator, but be sure to branch off of this part’s branch to ensure that these workings are in place for the next part. You will be required to ship a new PR for the next Part.