diff options
author | scottmotte <scott@scottmotte.com> | 2014-02-17 14:30:48 -0800 |
---|---|---|
committer | scottmotte <scott@scottmotte.com> | 2014-02-17 14:30:48 -0800 |
commit | 12e9ec3ce6ce82e186dfef6ef098f7ea04466dc4 (patch) | |
tree | 5f9507840c4611152c4104e09f85e892d5594799 /lib/email.js | |
parent | 32376abc8a40b610ce9ae53372714568c55e5b10 (diff) | |
download | sendgrid-nodejs-12e9ec3ce6ce82e186dfef6ef098f7ea04466dc4.zip sendgrid-nodejs-12e9ec3ce6ce82e186dfef6ef098f7ea04466dc4.tar.gz sendgrid-nodejs-12e9ec3ce6ce82e186dfef6ef098f7ea04466dc4.tar.bz2 |
addHeader use key, value approach to match up with other libraries
Diffstat (limited to 'lib/email.js')
-rw-r--r-- | lib/email.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/email.js b/lib/email.js index c369530..902dd46 100644 --- a/lib/email.js +++ b/lib/email.js @@ -52,9 +52,17 @@ function Email(params) { } } -Email.prototype.addHeader = function(object_literal) { - if (_.isObject(object_literal)) { - _.extend(this.headers, object_literal); +Email.prototype.addHeader = function(object_literal_or_key, value) { + if (typeof value === "undefined" || value === null) { + value = ""; + } + + if (_.isObject(object_literal_or_key)) { + _.extend(this.headers, object_literal_or_key); + } else { + var object_to_add = {} + object_to_add[object_literal_or_key] = value; + _.extend(this.headers, object_to_add); } }; |