Access Data

Overview

After successfully launching the SDK, and configuring the SDK; the next step is to access the data. There are two ways to access the data.

  • API Method
  • Callback Method

API Method

This method requires users to fetch the data once the SDK successfully links the policy carrier account. The callback "onSuccess()" would be used to get the Connection ID which is used to get data from the API's which is triggered when user insurance carrier account has been successfully retrieved from the insurance carrier. A connection ID will be assigned to this event and be supplied to the callback function with metadata like Connection ID, Selected Carrier and Sync Type in the parameter to be later used for the REST API.

As a first step, initialise the onSuccess method inside the script tag and send through to the fize.configure() function as demonstrated below:

<html lang="en">
  <head>
  <script src="https://cdn.getfize.com/sdk/v1.0/getfize.js"></script>
</head>
<body>
    <div id="launchFize">Launch Fize</div>
<script>

      const onSuccess = (metadata) => {
        console.log("on success callback called", metadata)
      }

      (function () {
        var handler = FIZE.configure({
          client_id: "FIZE_PROVIDED_CLIENT_ID",
          onSuccess: onSuccess
        });

        document.getElementById("launchFize").onclick = () => handler.launch();

      })();
</script>
</body>
</html>

A sample of the response is demonstrated below:

onSuccess(metadata)
metadata: {
  connectionId: "testConnectionId",
  selectedCarrier: "progressive",
  sync_type: "login",
}

Implement API

There are two different types of api to fetch the data.

Incremental API Method

This APIs are can be used to get the partial data as soon as the Fize System fetches the policy data. User can first check the status of section with policy status API and fetch the data on basis of status of individual section.

The below recipes show a sample integration to consume the connectionId received from the onSuccess callback to initially check the status of the connectionId with the Policy Request Status API and then implement the Policies API to get the full policy details.

  • Get Policy Status
  • Get Policy Details

Sync API Method

This APIs are can be used to get the data once the Fize System completely fetches the full policy data. User can first check the status of data fetched and make the API call to fetch the data once it is COMPLETED.

The below recipes show a sample integration to consume the connectionId received from the onSuccess callback to initially check the status of the connectionId with the Policy Request Status API and then implement the Policies API to get the full policy details.

Callback Method

This method can be used to get data through callback methods. Different callbacks are defined and it can be passed during the configuring of Fize SDK in configure method. More details and response structure can be found out in Callback Functions page.

CallbacksDescription
onFullPolicyDetailsCompleteTriggered when the connection_id's complete data is available after the successful completion of linking the policies.
onPolicyBasicDetailsCompleteTriggered when connection_id's basic details are available after the successful completion of linking the policies.
onPolicyDocumentsCompleteTriggered when connection_id's document details are available after the successful completion of linking the policies.
onPolicyHolderDetailsCompleteTriggered when connection_id's policy holder details are available after the successful completion of linking the policies.
onPolicyBasicDetailsPartialCompleteTriggered when connection_id's partial basic details data are available after the successful completion of linking the policies.
onPolicyDocumentsPartialCompleteTriggered when connection_id's partial documents details are available after the successful completion of linking the policies.
onPolicyHolderPartialCompleteTriggered when connection_id's partial policy holders details are available after the successful completion of linking the policies.
onFullPolicyDetailsPartialCompleteTriggered when connection_id's partial full policy details are available after the successful completion of linking the policies.
onPolicyBasicDetailsErrorTriggered when any error comes while fetching the basic details.
onPolicyDocumentsErrorTriggered when any error comes while fetching the document details.
onPolicyHolderDetailsErrorTriggered when any error comes while fetching the policy holder details.
onFullPolicyDetailsErrorTriggered when any error comes while fetching the full policy details.
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Demo</title>
  </head>

  <body>
    <script src="https://cdn.getfize.com/sdk/v1.0/getfize.js"></script>
    <a href="#" id="launchFize">Launch Fize</a>
    <div id="fize-element"></div>
    <script>

      const onFullPolicyDetailsCompleteCallBack = data => {
        console.log("onFullPolicyDetailsComplete", data);
      };
      const onPolicyBasicDetailsPartialCompleteCallBack = data => {
        console.log("onPolicyBasicDetailsPartialComplete", data);
      };
      const onPolicyDocumentsErrorCallBack = data => {
        console.log("onPolicyDocumentsError", data);
      };

      let handler = FIZE.configure({
        client_id: "FIZE_PROVIDED_CLIENT_ID",
        launch_immediate: true,
        onFullPolicyDetailsComplete: onFullPolicyDetailsCompleteCallBack,
        onPolicyBasicDetailsPartialComplete: onPolicyBasicDetailsPartialCompleteCallBack,
        onPolicyDocumentsError: onPolicyDocumentsErrorCallBack,
      });

      document.getElementById("launchFize").onclick = () => handler.launch();

    </script>
  </body>
</html>

What’s Next