diff options
author | scottmotte <scott@scottmotte.com> | 2013-12-18 16:49:49 -0800 |
---|---|---|
committer | scottmotte <scott@scottmotte.com> | 2013-12-18 16:49:49 -0800 |
commit | a8b066022f79cb636a17d30001a781f8686a3447 (patch) | |
tree | 852b7ddb0e38f377d291d9a0ac488efd274dac3f /lib/smtpapi_headers.js | |
parent | 195edbcb55de927120f148f89339b5f800b793a5 (diff) | |
download | sendgrid-nodejs-a8b066022f79cb636a17d30001a781f8686a3447.zip sendgrid-nodejs-a8b066022f79cb636a17d30001a781f8686a3447.tar.gz sendgrid-nodejs-a8b066022f79cb636a17d30001a781f8686a3447.tar.bz2 |
Replaces smtpapi_header with xsmtpapi nodejs module
Diffstat (limited to 'lib/smtpapi_headers.js')
-rw-r--r-- | lib/smtpapi_headers.js | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/lib/smtpapi_headers.js b/lib/smtpapi_headers.js deleted file mode 100644 index 410fe0b..0000000 --- a/lib/smtpapi_headers.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; - -var _ = require('lodash'); - -function SmtpapiHeaders() { - this.to = []; - this.sub = {}; - this.unique_args = {}; - this.category = []; - this.filters = {}; - this.section = {}; -} - -SmtpapiHeaders.prototype.addTo = function(to) { - if (_.isArray(to)) { - this.to = this.to.concat(to); - } else { - this.to.push(to); - } -}; - -SmtpapiHeaders.prototype.addSubVal = function(key, val) { - if (_.isArray(val)) { - this.sub[key] = val; - } else { - this.sub[key] = [val]; - } -}; - -SmtpapiHeaders.prototype.setUniqueArgs = function(val) { - if (_.isObject(val)) { - this.unique_args = val; - } -}; - -SmtpapiHeaders.prototype.addUniqueArgs = function(val) { - if (_.isObject(val)) { - _.extend(this.unique_args, val); - } -}; - -SmtpapiHeaders.prototype.setCategory = function(val) { - if (_.isArray(val)) { - this.category = val; - } else { - this.category = [val]; - } -}; - -SmtpapiHeaders.prototype.addCategory = function(val) { - if (_.isArray(val)) { - this.category.concat(val); - } else { - this.category.push(val); - } -}; - -SmtpapiHeaders.prototype.setSection = function(val){ - if (_.isObject(val)) { - this.section = val; - } -}; - -SmtpapiHeaders.prototype.addSection = function(val){ - if (_.isObject(val)) { - _.extend(this.section, val); - } -}; - -SmtpapiHeaders.prototype.setFilterSetting = function(filters) { - this.filters = filters; -}; - -SmtpapiHeaders.prototype.addFilterSetting = function(filter, setting, val) { - if (!this.filters[filter]) { - this.filters[filter] = {}; - } - - if (!this.filters[filter]['settings']) { - this.filters[filter]['settings'] = {}; - } - - this.filters[filter]['settings'][setting] = val; -}; - -SmtpapiHeaders.prototype.toJson = function() { - var data = _.clone(this); - _.each(data, function(v, k, list) { - if (_.isEmpty(v)) { - delete list[k]; - } - }); - var json = JSON.stringify(data); - return json.replace(/(["\]}])([,:])(["\[{])/, '$1$2 $3'); -}; - -module.exports = SmtpapiHeaders; |