Common Uses
  • 05 Dec 2022
  • Dark
    Light
  • PDF

Common Uses

  • Dark
    Light
  • PDF

Article summary

The two most common uses of the Adapter Utils are:

  • Making a request to an external system.

    • For example: Authentications, translations, data formatting, and throttling requests.

    • Formatting an error object to make it consistent with all other errors.

  • A third call is being added to return metrics information on the adapter.

// 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.