Call to the Adapter Libraries
  • 05 Dec 2022
  • Dark
    Light
  • PDF

Call to the Adapter Libraries

  • Dark
    Light
  • PDF

Article Summary

Call to Adapter Libraries

The last part of the API methods includes the call to the adapter libraries.

  • The entity must match the name of the entity directory.

  • The action must match the name of the action in the action.json file.

  • The returnDataFlag tells the adapter libraries whether to send back data or return a success/fail flag.

  • You can customize what happens when errors occur as well as alter the data that is returned from the adapter.

  • Remember: Translation is less work if you define the schema and allow the adapter libraries to handle it. There may be cases, however, where you need to modify the data being returned.

Example: Call to Adapter Library in adapter.js

// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest(‘entity’, ‘action', reqObj, true, (irReturnData, irReturnError) => {
  // if we received an error or there is no response on the results
  // return an error
  if (irReturnError) {
    /* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
    return callback(null, irReturnError);
  }
  if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
    const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response’, [‘action’], null, null, null);
    log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
    return callback(null, errorObj);
  }

  /* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
  // return the response
  return callback(irReturnData, null);
});

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.