adobe / acc-js-sdk

A JavaScript SDK for Adobe Campaign Classic
Apache License 2.0
21 stars 20 forks source link

Add onBeforeCall / onAfterCall observers #62

Closed mkiki closed 1 year ago

mkiki commented 1 year ago

Add an interception mechanism to make it possible for an observer to modify SOAP call parameters before making the SOAP calls and modify return values before they are returned to the caller

Description

In order to have a central place to properly intercept call, some refactoring has been done.

The central place to make SOAP calls is the _makeInterceptableSoapCall function. This function is in charge of calling the beforeSoapCall and afterSoapCall observers, and to serialize and deserialize the XML into the expected representation. This code was inlined in _callMethod before, it's now more structured and split into multiple functions (_writeSoapCallParameters, _makeSoapCall, and _readSoapCallResult). The XtkMethodParam type is also introduced to represent a parameter of a SOAP call. A side effect of this refactoring is that the SoapMethodCall object now has a isStatic member which indiates if the SOAP call is static or not.

How Has This Been Tested?

New unit tests

Types of changes

Checklist: