diff options
author | Adam Buczynski <adambuczynski@gmail.com> | 2016-07-27 11:28:32 +1200 |
---|---|---|
committer | Adam Buczynski <adambuczynski@gmail.com> | 2016-07-27 11:28:32 +1200 |
commit | d051d8f055631619f51719648f7e6e29005623fd (patch) | |
tree | bf079bb6a33211ca994e77dbdb8cb3a3132e3345 | |
parent | 1342ecde82d7af2f5098632b467563b17d9b8d5d (diff) | |
download | sendgrid-nodejs-d051d8f055631619f51719648f7e6e29005623fd.zip sendgrid-nodejs-d051d8f055631619f51719648f7e6e29005623fd.tar.gz sendgrid-nodejs-d051d8f055631619f51719648f7e6e29005623fd.tar.bz2 |
Use get empty request helper
-rw-r--r-- | lib/sendgrid.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js index 2c5cb6b..d083c2a 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -3,10 +3,15 @@ var package_json = require('./../package.json'); var emptyRequest = require('sendgrid-rest').emptyRequest; +//Helper to get empty request +function getEmptyRequest() { + return JSON.parse(JSON.stringify(emptyRequest)); +} + // SendGrid allows for quick and easy access to the v3 Web API function SendGrid(apiKey, host, globalHeaders) { var Client = require('sendgrid-rest').Client; - var globalRequest = this.emptyRequest(); + var globalRequest = getEmptyRequest(); globalRequest.host = host || 'api.sendgrid.com'; globalRequest.headers['Authorization'] = 'Bearer '.concat(apiKey); globalRequest.headers['Accept'] = 'application/json'; @@ -21,9 +26,7 @@ function SendGrid(apiKey, host, globalHeaders) { } var client = new Client(globalRequest); - this.emptyRequest = function() { - return JSON.parse(JSON.stringify(emptyRequest)); - }; + this.emptyRequest = getEmptyRequest; // Interact with the API with this function this.API = function(request, callback) { @@ -39,5 +42,5 @@ function SendGrid(apiKey, host, globalHeaders) { module.exports = { SendGrid: SendGrid, - emptyRequest: SendGrid.emptyRequest(), + emptyRequest: getEmptyRequest(), }; |