Skip to content

Commit

Permalink
Fixed jshint issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
aydrian committed Apr 17, 2015
1 parent c748b21 commit 71136d7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,26 @@ var resolveUri = function( origin, uri ) {
return uri;
};

var SparkPost = function(apiKey, options) {

// only options passed in
var handleOptions = function(apiKey, options) {
if (typeof apiKey === 'object') {
options = apiKey;

this.apiKey = process.env.SPARKPOST_API_KEY;
options.key = process.env.SPARKPOST_API_KEY;
} else {
options = options || {};

this.apiKey = apiKey || process.env.SPARKPOST_API_KEY;
options.key = apiKey;
}

options.origin = options.origin || options.endpoint || defaults.origin;

return options;
};

var SparkPost = function(apiKey, options) {

options = handleOptions(apiKey, options);

this.apiKey = options.key || process.env.SPARKPOST_API_KEY;

if(typeof this.apiKey === 'undefined') {
throw new Error('Client requires an API Key.');
}
Expand All @@ -46,7 +53,7 @@ var SparkPost = function(apiKey, options) {
}, options.headers);

//Optional client config
this.origin = options.origin || options.endpoint || defaults.origin;
this.origin = options.origin;
this.strictSSL = typeof options.strictSSL !== 'undefined' ? options.strictSSL : defaults.strictSSL;
this.apiVersion = options.apiVersion || defaults.apiVersion;

Expand Down

0 comments on commit 71136d7

Please sign in to comment.