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 "somebody@yourdomain.com", "reallygoodpassword"
client.newsletters.to_a
client.newsletters.get("webdev")
client.newsletters.delete "webdev"
client.newsletters.get("webdev").recipients.to_a
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 "selective@hosted.com", "programmatic@failure.com"
Last but not least, to schedule an already existing newsletter:
client.newsletters.get("webdev").schedule! :at => Time.now
client.newsletters.get("webdev").schedule
client.newsletters.get("webdev").deschedule!
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: "somebody@yourdomain.com"
password: "reallysecurepassword"
identity:
email: "info@yourdomain.com"
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: somebody@yourdomain.com
name: Some Body
-
email: someone@else.com
name: Someone Else
to make the specs pass