Newslettre

While writing this Sendgrid Newsletter API client in ruby I noticed several flaws in their API conception. Something like, returning 401 Status code when resources cannot be found are pretty gross but anyway this client should be mostly complete (still work in progress, scheduling etc.).

Installation


    gem install newslettre

Usage

this is definitely going to change since it's tedious to pass the client instance around. Maybe there will be a top-level wrapper to give you access to all the modules the API defines (Identity, Newsletter, Recipients)

Right now it works like this…


  require 'newslettre'

  client = Newslettre::Client.new "[email protected]", "reallygoodpassword"

  # Accessing newsletters

  client.newsletters.to_a # => [{ "name" => "webdev" }] 

  client.newsletters.get("webdev") # => { "name", "subject" => "Latest Web Development News", "html" =>  "<html>...</html>" }

  client.newsletters.delete "webdev"

  # Accessing recipients of a newsletter

  client.newsletters.get("webdev").recipients.to_a # => [{ "list" => "web-developers" }]

  client.newsletters.get("webdev").recipients.delete "web-developers"

nearly the same goes for `Identity`, `Lists`, `Lists::Email` and `Letter::Recipients`

You can also use #lists and #identities as well as the nested emails in recipient lists.


  client.lists.get("web-developers").emails.delete "[email protected]", "[email protected]"

Development

though it is still far from complete, if you'd like to help out please submit pull request with passing specs (or scenarios)

you will need to add a config/newslettre.yml containing something like this:

sendgrid:
  username: "[email protected]"
  password: "reallysecurepassword"

identity:
  email: "[email protected]"
  name: "Lennart Melzer"
  address: "Where you live 15"
  city: "Downtown"
  state: "C"
  zip: "12345"
  country: "EF"

letter:
  name: "test"
  identity: "test-identity"
  subject: "A letter to the world!"
  html: "<html><body><h1>A rendered Headline</h1></body></html>"
  text: "An unrendered Headline"

emails:
  -
    email: [email protected]
    name: Some Body
  -
    email: [email protected]
    name: Someone Else

to make the specs pass