Project

chimp_sync

0.0
No commit activity in last 3 years
No release in over 3 years
Synchronise your MailChimp list subscription details with your own data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.5.1
~> 4.0
~> 3.0.1
~> 1.3.9
~> 1.18.0

Runtime

~> 1.1
>= 0.2.1
 Project Readme

ChimpSync

ChimpSync keeps MailChimp list subscription details synced with your own data.

Installation

Add the gem to your application's Gemfile:

gem 'chimp_sync', '~> 0.0.1'

This gem uses Panthoot for receiving MailChimp webhooks. If you're using Rails, the endpoint is automatically connected to /panthoot/hooks. If you're not using Rails, then you'll want to mount Panthoot::App.new into your app somewhere.

Usage

In an initializer or similar, to ensure any changes made from MailChimp's side of things are reflected in your app:

# Repeat as needed for as many lists as required - the label argument must be
# unique for each, though.
ChimpSync.sync :my_label do |list|
  list.api_key = ENV['MAILCHIMP_API_KEY']
  list.id      = ENV['MAILCHIMP_LIST_ID']

  list.update_local = lambda { |email, subscribed|
    # email is the email address as a string, subscribed is a boolean
    # indicating the new subscription status via MailChimp.
    User.find_by(email: email).update_attributes(subscribed: subscribed)
  }
end

You'll also want to pass back local changes to MailChimp:

ChimpSync::Update.subscribed :my_label, user.email, user.subscribed

Contributing

  1. Fork it ( https://github.com/inspire9/chimp_sync/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Credits

Copyright (c) 2014, ChimpSync is developed and maintained by Pat Allan and Inspire9, and is released under the open MIT Licence.