restRequestSender is an object that implements an abstraction level the actual REST
request sending operation by exposing an object that implements an abstraction level the actual
sending operation, allowing complex implementations to vary the behavior of all rest operations.
It can be either called directly, as in Example-1-Direct,
or it can be used to allow functions that wrap the rest operations, as in Example-2-Wrap
or it can be replaced with a different object that implements those methods differently,
for instance, additional calls (rest of otherwise) can be made before or after any rest calls,
headers (such as security, checksum, token headers, etc.) can be added to all messages, etc.
Examples:
// call the first Get, then if successful, call the secondvareventChannel=require("./bootstrap/setupEventChannel")();varrestRequestSender=require("./infrastructure/restRequestSender");restRequestSender.initialize({eventChannel:eventChannel});functioncallGetandGet(restOperation1,restOperation2){restRequestSender.sendGet(restOp).then(function(response1){this.logger.info("[response1] "+JSON.stringify(response1));// send second get only if first successfulrestRequestSender.sendGet(restOp).then(function(response2){this.logger.info("[response2] "+JSON.stringify(response2))}},function(error1){this.logger.warning("[Error1] "+error1);});}
Sets the request method to POST and sends out the operation. Return result is
the promise which will resolved in future. Body is mandated on POST request.
Sets the request method to PATCH and sends out the operation. Return result is
the promise which will resolved in future. Body is mandated on PATCH request.
The [promise](https://www.npmjs.com/package/q) object that represents the return value or the thrown exception that may eventually be provided.
Examples:
// issue a patch and log success or failure based on the returned promisethis.restRequestSender.sendPatch(restOp).then(function(response){this.logger.info("[Patch success] "+JSON.stringify(response));},function(error){this.logger.warning("[Patch failure] "+error);});
Sets the request method to PUT and sends out the operation. Return result is
the promise which will resolved in future. Body is mandated on PUT request.