diff options
author | scottmotte <scott@scottmotte.com> | 2014-05-28 15:10:23 -0700 |
---|---|---|
committer | scottmotte <scott@scottmotte.com> | 2014-05-28 15:10:23 -0700 |
commit | 882ca106f508a2f09af9f772c438686966bbe79d (patch) | |
tree | b6d9fedc8dba3010bddf43b021bdaf94b7896197 /lib/email.js | |
parent | b39924fc1fee9fc2e8754c4cb6259d7521a0b38a (diff) | |
download | sendgrid-nodejs-882ca106f508a2f09af9f772c438686966bbe79d.zip sendgrid-nodejs-882ca106f508a2f09af9f772c438686966bbe79d.tar.gz sendgrid-nodejs-882ca106f508a2f09af9f772c438686966bbe79d.tar.bz2 |
Update to latest smtpapi nodejs lib
Diffstat (limited to 'lib/email.js')
-rw-r--r-- | lib/email.js | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/lib/email.js b/lib/email.js index 902dd46..9fb57e3 100644 --- a/lib/email.js +++ b/lib/email.js @@ -1,34 +1,17 @@ "use strict"; var FileHandler = require('./file_handler'); -var smtpapi = require('smtpapi'); +var smtpapi_lib = require('smtpapi'); var _ = require('lodash'); var request = require('request'); var fs = require('fs'); -/** - * Class to handle storing the properties relative to an email. - * - * @param {Object} params - * @param {string|array} params.to The to address(es) of the email - * @param {string|array} params.toname The display name of the email recipients - * @param {string} params.from The from address of the email - * @param {string} params.fromname The display name of the email sender - * @param {SmtpapiHeaders} params.smtpapi The SendGrid x-smtpapi headers object - * @param {string} params.subject The subject of the email - * @param {string} params.text The text/plain content of an email - * @param {string} params.html The text/html content of an email - * @param {string|array} params.bcc The bcc address(es) of the email - * @param {Date} params.date The date of the email - * @param {object} params.headers The custom headers on an email - */ function Email(params) { - params = params || {}; this.to = params.to || []; this.from = params.from || ''; - this.smtpapi = params.smtpapi || new smtpapi.Header(); + this.smtpapi = params.smtpapi || new smtpapi_lib(); this.subject = params.subject || ''; this.text = params.text || ''; this.html = params.html || ''; @@ -209,23 +192,12 @@ Email.prototype._formatFileForNodeMailer = function(file) { } }; -/** - * There needs to be at least 1 to address, or else the mail won't send. - * This method modifies the data that will be sent via either Rest - * - * @param {object} data The data parameter to send via Rest - */ Email.prototype.updateMissingTo = function(data) { - if (this.smtpapi.to && this.smtpapi.to.length > 0) { + if (this.smtpapi.jsonObject().to && this.smtpapi.jsonObject().to.length > 0) { data.to = this.from; } }; -/** - * This method is used to show if there are files on this email object - * - * @return boolean - */ Email.prototype.hasFiles = function() { return this.files.length > 0; }; |