Common Uses
- 05 Dec 2022
-
DarkLight
-
PDF
Common Uses
- Updated on 05 Dec 2022
-
DarkLight
-
PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
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?