Performing API calls
Each application must perform a multitude of requests. The most common ones are:
quote
- to retrieve the price by the given custom input arguments;policy
- to create aoffer
(unpaid policy);payment
- to process a payment;lead
- to create a lead object (usually used for save-for-later functionality);
quote
, policy
and lead
requests are performed as soon as all the required information has been collected from the customer. Whereas payment
request is triggered only after clicking a predefined button.
But how can the required pieces of information that must be collected set? Read on for more information.
Field Definitions
Backend Field Definitions
If an API needs to be built, the API needs to know what pieces of information it can expect. It must also know the validation rules. This is done via the field definitions.
The backend field definitions are also used to validate the data in frontend. Though even if the dataset is not fully-valid, it may be still sent to backend (and there rejected). This is because there are some specific backend-only validation rules which frontend simply cannot do (like checking MX records of an email domain).
Dataset is sent to backend if all required
validation rules are passing.
For example, given this field definition:
Backend knows that the expected input will be something like this:
Frontend Field Definitions
Sometimes there are some things that need to be validated purely in the frontend and that must not be sent to the API. For example, this could be the acceptance to the privacy policy. Even though it must be validated that the customer has accepted it, the boolean data must not be sent to backend.
In this case, the rule for the privacy policy field sits in the frontend field definitions. The structure is exactly the same as the backend field definitions. Difference is in the location.
Backend field definitions sit in root level of a product (i.e. in a separate field). Whereas the frontend field definitions sit within the manifest config
section.
Defining Triggered Requests In The Manifest
The application must always know all the requests that it will need to trigger. If no requests have been configured - none will be triggered.
Request definition is done in the manifest config section.
Example request definition:
Transforming Customer Input Before Sending To API
This is a rather tricky topic which deserves a page of its own. See the request transformation guide for more information.
Last updated