Methods

In addition to properties and events, the Axitech Widget offers methods that enable dynamic interaction and configuration adjustments.

MethodDescription
loadInitializes the widget and its configuration using the provided API key and options.
applyConfigDynamically applies configuration changes to the widget after its initialization.

Method Details

load Method

The load method is used to initialize the widget with the provided configuration options. It offers two distinct methods of initialization, providing you with versatile choices for seamless integration based on your requirements.

  1. API Key-based Initialization: Employ your API key alongside the options JSON object to prime the widget for operation. This method provides direct configuration of the widget.
    load('API-KEY', {
      type: 'accident',
      clientID: 'your-client-id',
      // ... other properties
    });
    
  2. Secure Client ID and Web Token Initialization: For heightened security, utilize your client ID and a JSON web token. Encode the options JSON object using your API key. Ensure that you use your API key as the secret for encoding. Notably, the client ID in the options is redundant when using this method, as it is passed as the first parameter, so you do not necessarily need to add it to the options.
    load('CLIENT-ID', 'ENCODED-JSON-WEB-TOKEN', callbacks);
    

    Where callbacks is an optional object containing the following functions:
    • onSuccess: A function to handle successful submission.
    • onError: A function to handle any submission errors.
    • onChange: A function to handle changes in the widget data.

    For detailed instructions, refer to the Events section
    This additional parameter is necessary as you can't pass functions directly in a JWT string.

By offering multiple initialization methods, the load function empowers you to configure the widget with flexibility and security, ultimately enhancing the claim creation experience for your users.

applyConfig Method

The applyConfig method provides the capability to dynamically adjust the widget's configuration post-initialization. This dynamic feature enables precise refinement of the widget's behavior as your application evolves. It is important to note that, for security and performance considerations, this function will execute only if the data being submitted differs from the previous submission (if it exists). Additionally, there is a throttle of 500 milliseconds in place to prevent an excessive number of updates.

  1. Plain Object Configuration: By utilizing a plain object, you can effortlessly integrate updated configuration options. This method ensures that changes to the widget's behavior take effect immediately.
    applyConfig({
      theme: {
        primary: '#FF5733',
        secondary: '#6C7A89',
        // ... other theme properties
      },
      // ... other updated properties
    });
    
  2. Web Token Configuration: For heightened security, utilize a JSON web token. You can easily encode the options JSON object using your API key. Ensure that you use your API key as the secret for encoding. This method also ensures that changes to the widget's behavior take effect immediately.
    applyConfig('ENCODED-JSON-WEB-TOKEN');
    

By utilizing the applyConfig method with plain object configuration, you can seamlessly adjust the widget's behavior in real-time to cater to your evolving application requirements.