Skip to content

Commit cedcae4

Browse files
author
SendGrid's DX Team
authored
Merge pull request #19 from mell0kat/set-batch-id
Adds setBatchId method
2 parents 53b1a25 + 80fd711 commit cedcae4

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

examples/example.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ header.setFilters({
5858
// You can set the send_at scheduling param using an UNIX timestamp.
5959
header.setSendAt(1409348513);
6060

61+
// setBatchId
62+
// You can set the batch_id scheduling param using a string.
63+
header.setBatchId('apples');
64+
6165
// setSendEachAt
6266
// You can set the send_each_at scheduling param using a list of UNIX timestamps.
6367
//header.setSendEachAt([1409348513, 14093485134]);
@@ -109,4 +113,4 @@ smtpTransport.sendMail(mailOptions, function(error, response) {
109113
} else {
110114
console.log("Message sent");
111115
}
112-
});
116+
});

lib/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var smtpapi = function smtpapi(header) {
1515
this.header.section = header.section || {};
1616
this.header.filters = header.filters || {};
1717
this.header.send_at = header.send_at || '';
18+
this.header.batch_id = header.batch_id || '';
1819
this.header.send_each_at = header.send_each_at || [];
1920
this.header.asm_group_id = header.asm_group_id || {};
2021
this.header.ip_pool = header.ip_pool || '';
@@ -97,6 +98,10 @@ smtpapi.prototype.setSendAt = function(send_at) {
9798
this.header.send_at = send_at;
9899
};
99100

101+
smtpapi.prototype.setBatchId = function(batch_id) {
102+
this.header.batch_id = batch_id;
103+
};
104+
100105
smtpapi.prototype.setSendEachAt = function(send_each_at) {
101106
this.header.send_at = '';
102107
this.header.send_each_at = send_each_at

test/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ describe('smtapi', function() {
105105
header.jsonString().should.eql(t.set_send_at);
106106
});
107107

108+
it('setBatchId', function() {
109+
header.setBatchId('apples');
110+
header.jsonString().should.eql(t.set_batch_id);
111+
});
112+
108113
it('setSendAt', function() {
109114
header.setSendEachAt([1409348513, 1409348514, 1409348515]);
110115
header.jsonString().should.eql(t.set_send_each_at);

test/smtpapi_test_strings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"add_filter": "{\"filters\":{\"footer\":{\"settings\":{\"text/html\":\"<strong>boo</strong>\"}}}}",
1616
"set_filters": "{\"filters\":{\"footer\":{\"setting\":{\"enable\":1,\"text/plain\":\"You can haz footers!\"}}}}",
1717
"set_send_at": "{\"send_at\":1409348513}",
18+
"set_batch_id": "{\"batch_id\":\"apples\"}",
1819
"set_send_each_at": "{\"send_each_at\":[1409348513,1409348514,1409348515]}",
1920
"add_send_each_at": "{\"send_each_at\":[1409348513,1409348514,1409348515]}",
2021
"set_asm_group_id": "{\"asm_group_id\":123}",

0 commit comments

Comments
 (0)