Skip to content

Commit

Permalink
Add missing bcc methods
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiezane committed May 6, 2015
1 parent 9a3fdb1 commit 9910bf1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,27 @@ email.setCcs(['[email protected]', '[email protected]');
sendgrid.send(email, function(err, json) { });
```

#### addBcc

You can add one or multiple BCC addresses using `addBcc`.

```javascript
var email = new sendgrid.Email();
email.addBcc('[email protected]');
email.addBcc('[email protected]');
sendgrid.send(email, function(err, json) { });
```

#### setBccs

You can multiple BCC addresses using `setBccs`.

```javascript
var email = new sendgrid.Email();
email.setBccs(['[email protected]', '[email protected]');
sendgrid.send(email, function(err, json) { });
```

#### setSubject

```javascript
Expand Down
8 changes: 8 additions & 0 deletions lib/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ Email.prototype.setCcs = function(cc) {
this.cc = cc;
};

Email.prototype.addBcc = function(bcc) {
this.bcc.push(bcc);
};

Email.prototype.setBccs = function(bcc) {
this.bcc = bcc;
};

Email.prototype.setSubject = function(subject) {
this.subject = subject;
};
Expand Down
27 changes: 27 additions & 0 deletions test/lib/email.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,33 @@ describe('Email', function () {
expect(email.cc).to.eql(['[email protected]', '[email protected]']);
});

it('should be possible to addBcc', function() {
var email = new Email();
expect(email.bcc).to.eql([]);
email.addBcc('[email protected]');
expect(email.bcc).to.eql(['[email protected]']);
email.addBcc('[email protected]');
expect(email.bcc).to.eql(['[email protected]', '[email protected]']);
});

it('should be possible to setBccs', function() {
var email = new Email();
expect(email.bcc).to.eql([]);
email.setBccs(['[email protected]']);
expect(email.bcc).to.eql(['[email protected]']);
email.setBccs(['[email protected]']);
expect(email.bcc).to.eql(['[email protected]']);
});

it('should be possible to setBccs and addBcc', function() {
var email = new Email();
expect(email.bcc).to.eql([]);
email.setBccs(['[email protected]']);
expect(email.bcc).to.eql(['[email protected]']);
email.addBcc('[email protected]');
expect(email.bcc).to.eql(['[email protected]', '[email protected]']);
});

describe('files', function() {
it('should support adding attachments via path', function() {
var email = new Email();
Expand Down

0 comments on commit 9910bf1

Please sign in to comment.