@sendgrid/helpers
Advanced tools
Comparing version 7.5.0 to 7.6.0
@@ -26,2 +26,3 @@ 'use strict'; | ||
to: 'to@example.org', | ||
from: 'from@example.org', | ||
cc: ['cc1@example.org', 'cc2@example.org'], | ||
@@ -51,2 +52,3 @@ bcc: ['bcc1@example.org', 'bcc2@example.org'], | ||
expect(p.to[0].email).to.equal('to@example.org'); | ||
expect(p.from.email).to.equal('from@example.org'); | ||
expect(p.cc[0].email).to.equal('cc1@example.org'); | ||
@@ -53,0 +55,0 @@ expect(p.cc[1].email).to.equal('cc2@example.org'); |
@@ -6,2 +6,3 @@ #### Personalization helper specs | ||
- setTo() - set-to.spec.js | ||
- setFrom() - set-from.spec.js | ||
- addTo() - add-to.spec.js | ||
@@ -8,0 +9,0 @@ - setCc() - set-cc.spec.js |
@@ -34,2 +34,9 @@ 'use strict'; | ||
}); | ||
it('should set the from field', function() { | ||
p.setFrom('testfrom@example.org'); | ||
const json = p.toJSON(); | ||
expect(json).to.have.property('from'); | ||
expect(json.from).to.be.an.instanceof(EmailAddress); | ||
expect(json.from.email).to.equal('testfrom@example.org'); | ||
}); | ||
it('should set the cc field', function() { | ||
@@ -36,0 +43,0 @@ p.setCc('testcc@example.org'); |
@@ -5,2 +5,3 @@ import { EmailData, EmailJSON } from "./email-address"; | ||
to: EmailData | EmailData[], | ||
from?: EmailData, | ||
cc?: EmailData | EmailData[], | ||
@@ -18,2 +19,3 @@ bcc?: EmailData | EmailData[], | ||
to: EmailJSON | EmailJSON[]; | ||
from?: EmailJSON; | ||
cc?: EmailJSON[]; | ||
@@ -50,2 +52,7 @@ bcc?: EmailJSON[]; | ||
/** | ||
* Set from | ||
*/ | ||
setFrom(from: EmailData): void; | ||
/** | ||
* Add a single to | ||
@@ -52,0 +59,0 @@ */ |
@@ -56,3 +56,3 @@ 'use strict'; | ||
const { | ||
to, cc, bcc, subject, headers, customArgs, sendAt, | ||
to, from, cc, bcc, subject, headers, customArgs, sendAt, | ||
substitutions, substitutionWrappers, dynamicTemplateData, | ||
@@ -63,2 +63,3 @@ } = data; | ||
this.setTo(to); | ||
this.setFrom(from); | ||
this.setCc(cc); | ||
@@ -115,2 +116,12 @@ this.setBcc(bcc); | ||
/** | ||
* Set from | ||
* */ | ||
setFrom(from) { | ||
if (typeof from === 'undefined') { | ||
return; | ||
} | ||
this.from = EmailAddress.create(from); | ||
} | ||
/** | ||
* Add a single to | ||
@@ -315,3 +326,3 @@ */ | ||
const { | ||
to, cc, bcc, subject, headers, customArgs, sendAt, | ||
to, from, cc, bcc, subject, headers, customArgs, sendAt, | ||
substitutions, substitutionWrappers, dynamicTemplateData, | ||
@@ -354,2 +365,5 @@ } = this; | ||
} | ||
if (typeof from !== 'undefined') { | ||
json.from = from; | ||
} | ||
@@ -356,0 +370,0 @@ //Return as snake cased object |
{ | ||
"name": "@sendgrid/helpers", | ||
"description": "Twilio SendGrid NodeJS internal helpers", | ||
"version": "7.5.0", | ||
"version": "7.6.0", | ||
"author": "Twilio SendGrid <help@twilio.com> (sendgrid.com)", | ||
@@ -35,3 +35,3 @@ "contributors": [ | ||
}, | ||
"gitHead": "a3307fda9318973ef9410f604a4d117ff7548e24" | ||
"gitHead": "86235101d8f6d088bb97e85afd142c0521d86a57" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143002
85
4686