Project

gogogibbon

0.0
No commit activity in last 3 years
No release in over 3 years
A wrapper for Gibbon containing useful helper methods.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2.2
 Project Readme

GoGoGibbon

GoGoGibbon is a simple extension of Gibbon that provides wrapper methods for subscribing and unsubscribing users to lists. It also works off of initialization files instead of environment variables.

Notice: GoGoGibbon versions 1.1.1 and prior are now deprecated, as the MailChimp API v1.3 has been officially deprecated. GoGoGibbon now uses MailChimp API v3.0 as of version 2.0.0, backed by Gibbon 2.2.4.

Rails Installation

  1. Add the GoGoGibbon gem entry to your Gemfile

    gem 'gogogibbon', :git => 'git://github.com/GoGoCarl/gogogibbon.git'
  2. Run bundle install

  3. Configure GoGoGibbon with your MailChimp information. You will need an API key from your MailChimp account, and the name of the list you to which you want new users subscribed. You can specify this in a global initialization file under config/initializers, or to get different behavior in development vs. production, specify thse in the appropriate config/enviroment/ file:

    GoGoGibbon::Config.api_key = 'Your API Key'
    GoGoGibbon::Config.subscribed = 'Subscription List'
  4. A restart is required to pick up new gems and configuration.

Additional Configuration

Optionally, you can name a cancellation list, and users will be removed from the subscription list and added to the cancellation list when calling cancel_user.

GoGoGibbon::Config.unsubscribed = 'Cancellation List'

Optionally, you can specify how you want error handled when you have misconfigured MailChimp:

GoGoGibbon::Config.on_fail = :error || :silent || :warn

:warn will print a message to the console, :error will thrown an Exception, and :silent will do nothing. The default is warn.

Gibbon, by default, throws errors for any problems that occur when communicating to the MailChimp API. If you want these errors thrown, you can use the following:

GoGoGibbon::Config.errors = :throw

Otherwise, errors will not be thrown, just a status indicator will be returned noting there was an error.

Usage

See lib/gogogibbon.rb for a list of all available methods. Of course, you can still use gibbon directly, these are simply helpers to speed up the process.

Quick Start

Out the box, GoGoGibbon has three helper methods that you can add to your ActiveModel to get you started.

  1. mailchimp_on_create will subscribe your user to the subscription list when the record is created. It will use the first_name, last_name, and email fields for this.

  2. mailchimp_on_update will update the user's mailmerge properties as well as email address when the user is updated. This will only occur if the fields have changed.

  3. mailchimp_on_destroy will call cancel_user, which removes the user from the subscription list and adds them to the cancellation list.

Each of these methods take a hash of options. The supported options are as follows:

  • :thread, when set to true, will run the mailchimp operation in a new thread.