Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Web callback hooks for the Mailchimp api

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 config
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.textile
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
Octocat-spinner-32 panthoot.gemspec
README.textile

Pant-hoot

The pant-hoot is a vocalization of chimpanzees that begins with breathy, low-pitched hoots that makes a transition into a series of quicker, higher-pitched in-and-out pants building to a loud climax.

Pant-hoot is a gem that provides the API MailChimp expects for its webhooks, and then passes on those notifications to you in a sensible, Ruby-infused manner. If you’re using Rails, then it functions as a Rails Engine. Otherwise, you’ll have a Rack app to use as you see fit.

Usage

Add the gem to your Gemfile:

gem 'panthoot', '~> 0.2.0'

If you’re using Rails, this will automatically add a route at /panthoot/hooks to capture messages from MailChimp. Otherwise, mount the Rack app Panthoot::App.new to wherever you like. Make sure you add that URL to your MailChimp account settings, otherwise this will all be for naught.

The next step is to tell Panthoot that you want to be informed whenever MailChimp sends something your way. In Rails, stick the configuration in an initializer, but for Rack just make sure it’s set as part of your app load process.

ActiveSupport::Notifications.subscribe('subscribe.panthoot') do |*args|
  event        = ActiveSupport::Notifications::Event.new(*args)
  subscription = event.payload[:subscribe]
  fired_at     = event.payload[:fired_at]

  # use subscription data however you wish
end

The above sample is just listening to new subscriptions, but there’s other events as well – the event prefix matches the payload key in each case:

  • subscribe
  • unsubscribe
  • profile_update
  • email_address_change
  • email_cleaned
  • campaign_sending_status

As you can see in the example, each notification will provide an object with all the data from MailChimp, plus the time the notification was fired. When the notification is fired, you get to do your thing with the data provided. Have fun!

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Pull requests without tests may be rejected purely on that basis. You’ve been warned.

Credits

Copyright © 2013, Panthoot is developed and maintained by Pat Allan on behalf of Inspire9, and is released under the open MIT Licence.

Something went wrong with that request. Please try again.