-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from aydrian/ISSUE-86
Added Recipient List Update method, Docs, and Examples
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
var key = 'YOURAPIKEY' | ||
, SparkPost = require('sparkpost') | ||
, client = new SparkPost(key) | ||
, options = { | ||
id: 'EXISTING_TEST_ID' | ||
, name: 'Test Recipient List' | ||
, recipients: [ | ||
{ | ||
address: { | ||
email: '[email protected]' | ||
} | ||
} | ||
, { | ||
address: { | ||
email: '[email protected]' | ||
} | ||
} | ||
, { | ||
address: { | ||
email: '[email protected]' | ||
} | ||
} | ||
] | ||
}; | ||
|
||
client.recipientLists.update(options, function(err, res) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log(res.body); | ||
console.log('Congrats you can use our SDK!'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,51 @@ describe('Recipient Lists Library', function() { | |
}); | ||
}); | ||
|
||
describe('update Method', function() { | ||
var test_list = [ | ||
{ | ||
address: { | ||
email: '[email protected]', | ||
name: 'test' | ||
} | ||
} | ||
]; | ||
|
||
it('should call client put method with the appropriate uri', function(done) { | ||
var options = { | ||
id: 'test_list', | ||
recipients: test_list | ||
}; | ||
|
||
recipientLists.update(options, function(err, data) { | ||
expect(client.put.firstCall.args[0].uri).to.equal('recipient-lists/' + options.id); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should throw an error if id is missing', function(done) { | ||
recipientLists.update(null, function(err) { | ||
expect(err.message).to.equal('recipients list id is required'); | ||
expect(client.put).not.to.have.been.called; | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should allow num_rcpt_errors to be set in options', function(done) { | ||
var options = { | ||
id: 'test_list', | ||
recipients: test_list, | ||
num_rcpt_errors: 3 | ||
}; | ||
|
||
recipientLists.update(options, function(err, data) { | ||
expect(client.put.firstCall.args[0].qs).to.deep.equal({num_rcpt_errors: 3}); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('delete Method', function() { | ||
it('should call client delete method with the appropriate uri', function(done) { | ||
recipientLists.delete('test', function(err, data) { | ||
|