sendgrid/sendgrid-nodejs — pull request #32 by kenperkins (2012-04-17 17:32:43+00:00)
Title: Add support for entire Newsletter API area

## Caveat ##
**I don't expect this PR to be accepted as is, but I wanted to start the dialog about how and what form this might take.**

## Overview ##

I've added the support for all of the newsletter APIs with very crude error handling, input validation, minimal documentation, and no testing.

The APIs that are supported are:

* Newsletter
* Newsletter - Lists
* Newsletter - Lists - Email
* Newsletter - Schedule
* Newsletter - Recipients
* Newsletter - Identity

All of these are implemented using the [Request module](https://github.com/mikeal/request) which nicely abstracts away the particulars of using HTTP/HTTPS calls.

I've tentatively added these as sub objects of the master Sendgrid object, but I'm not convinced that is the best way to factor these, but this is good enough to get the ball rolling.

Here's a couple of examples:

```javascript

var Sendgrid = require('sendgrid'),
sendgrid = new Sendgrid('myuser', 'mypassword');

sendgrid.Newsletter.Lists.Email.add('mylist', {
email: 'ken@mydomain.com',
name: 'ken',
displayName: 'Ken Perkins'
}, function(err, result) {
if (err) {
console.dir(err);
process.exit(1);
}

console.dir(result.body);
});

sendgrid.Newsletter.Identity.add({
identity: 'testIdentity',
name: 'My Identity',
email: 'support@mydomain.com',
address: '12345 Anystreet S',
city: 'Seattle',
state: 'WA',
zip: '98104',
country: 'usa'
}, function(err, result) {

if (err) {
console.dir(err);
}

console.dir(result.body);
});
```