Git Product home page Git Product logo

gibbon's Introduction

gibbon

Gibbon is an API wrapper for MailChimp's API.

Build Status

Important Notes

Please read MailChimp's Getting Started Guide.

Gibbon 3.0.0+ returns a Gibbon::Response instead of the response body directly. Gibbon::Response exposes the parsed response body and headers.

Installation

$ gem install gibbon

Requirements

A MailChimp account and API key. You can see your API keys here.

Usage

First, create a one-time use instance of Gibbon::Request:

gibbon = Gibbon::Request.new(api_key: "your_api_key")

Note Only reuse instances of Gibbon after terminating a call with a verb, which makes a request. Requests are light weight objects that update an internal path based on your call chain. When you terminate a call chain with a verb, a request instance makes a request and resets the path.

You can set an individual request's timeout and open_timeout like this:

gibbon.timeout = 30
gibbon.open_timeout = 30

You can read about timeout and open_timeout in the Net::HTTP doc.

Now you can make requests using the resources defined in MailChimp's docs. Resource IDs are specified inline and a CRUD (create, retrieve (or get), update, upsert, or delete) verb initiates the request. upsert lets you update a record, if it exists, or insert it otherwise where supported by MailChimp's API.

Note upsert requires Gibbon version 2.1.0 or newer!

You can specify headers, params, and body when calling a CRUD method. For example:

gibbon.lists.retrieve(headers: {"SomeHeader": "SomeHeaderValue"}, params: {"query_param": "query_param_value"})

Note get can be substituted for retrieve as of Gibbon version 3.4.1 or newer!

Of course, body is only supported on create, update, and upsert calls. Those map to HTTP POST, PATCH, and PUT verbs respectively.

You can set api_key, timeout, open_timeout, faraday_adapter, proxy, symbolize_keys, logger, and debug globally:

Gibbon::Request.api_key = "your_api_key"
Gibbon::Request.timeout = 15
Gibbon::Request.open_timeout = 15
Gibbon::Request.symbolize_keys = true
Gibbon::Request.debug = false

For example, you could set the values above in an initializer file in your Rails app (e.g. your_app/config/initializers/gibbon.rb).

Assuming you've set an api_key on Gibbon, you can conveniently make API calls on the class itself:

Gibbon::Request.lists.retrieve

You can also set the environment variable MAILCHIMP_API_KEY and Gibbon will use it when you create an instance:

gibbon = Gibbon::Request.new

Note Substitute an underscore if a resource name contains a hyphen.

Pass symbolize_keys: true to use symbols (instead of strings) as hash keys in API responses.

gibbon = Gibbon::Request.new(api_key: "your_api_key", symbolize_keys: true)

MailChimp's resource documentation is a list of available resources.

Debug Logging

Pass debug: true to enable debug logging to STDOUT.

gibbon = Gibbon::Request.new(api_key: "your_api_key", debug: true)

Custom logger

Ruby Logger.new is used by default, but it can be overrided using:

gibbon = Gibbon::Request.new(api_key: "your_api_key", debug: true, logger: MyLogger.new)

Logger can be also set by globally:

Gibbon::Request.logger = MyLogger.new

Examples

Lists

Fetch first page of lists:

gibbon.lists.retrieve

Retrieving a specific list looks like:

gibbon.lists(list_id).retrieve

Retrieving a specific list's members looks like:

gibbon.lists(list_id).members.retrieve

Subscribers

Get first page of subscribers for a list:

gibbon.lists(list_id).members.retrieve

By default the Mailchimp API returns 10 results. To set the count to 50:

gibbon.lists(list_id).members.retrieve(params: {"count": "50"})

And to retrieve the next 50 members:

gibbon.lists(list_id).members.retrieve(params: {"count": "50", "offset": "50"})

And to retrieve only subscribed members

gibbon.lists(list_id).members.retrieve(params: {"count": "50", "offset": "50", "status": "subscribed"})

Subscribe a member to a list:

gibbon.lists(list_id).members.create(body: {email_address: "[email protected]", status: "subscribed", merge_fields: {FNAME: "First Name", LNAME: "Last Name"}})

If you want to upsert instead, you would do the following:

gibbon.lists(list_id).members(lower_case_md5_hashed_email_address).upsert(body: {email_address: "[email protected]", status: "subscribed", merge_fields: {FNAME: "First Name", LNAME: "Last Name"}})

You can also unsubscribe a member from a list:

gibbon.lists(list_id).members(lower_case_md5_hashed_email_address).update(body: { status: "unsubscribed" })

Get a specific member's information (open/click rates etc.) from MailChimp:

gibbon.lists(list_id).members(lower_case_md5_hashed_email_address).retrieve

Permanently delete a specific member from a list:

gibbon.lists(list_id).members(lower_case_md5_hashed_email_address).actions.delete_permanent.create

Tags

Tags are a flexible way to organize (slice and dice) your list: for example, you can send a campaign directly to one or more tags.

Add tags to a subscriber:

gibbon.lists(list_id).members(Digest::MD5.hexdigest(lower_case_email_address)).tags.create(
  body: {
    tags: [{name:"referred-from-xyz", status:"active"},{name:"pro-plan",status:"active"}]
  }
)

Batch Operations

Any API call that can be made directly can also be organized into batch operations. Performing batch operations requires you to generate a hash for each individual API call and pass them as an Array to the Batch endpoint.

# Create a new batch job that will create new list members
gibbon.batches.create(body: {
  operations: [
    {
      method: "POST",
      path: "lists/#{ list_id }/members",
      body: "{...}" # The JSON payload for PUT, POST, or PATCH
    },
    ...
  ]
})

This will create a new batch job and return a Batch response. The response will include an id attribute which can be used to check the status of a particular batch job.

Checking on a Batch Job
gibbon.batches(batch_id).retrieve
Response Body (i.e. response.body)
{
  "id"=>"0ca62e43cc",
  "status"=>"started",
  "total_operations"=>1,
  "finished_operations"=>1,
  "errored_operations"=>0,
  "submitted_at"=>"2016-04-19T01:16:58+00:00",
  "completed_at"=>"",
  "response_body_url"=>""
}

Note This response truncated for brevity. Reference the MailChimp API documentation for Batch Operations for more details.

Fields

Only retrieve ids and names for fetched lists:

gibbon.lists.retrieve(params: {"fields": "lists.id,lists.name"})

Only retrieve emails for fetched lists:

gibbon.lists(list_id).members.retrieve(params: {"fields": "members.email_address"})

Campaigns

Get first page of campaigns:

campaigns = gibbon.campaigns.retrieve

Fetch the number of opens for a campaign

email_stats = gibbon.reports(campaign_id).retrieve["opens"]

Create a new campaign:

recipients = {
  list_id: list_id,
  segment_opts: {
    saved_segment_id: segment_id
  }
}
settings = {
  subject_line: "Subject Line",
  title: "Name of Campaign",
  from_name: "From Name",
  reply_to: "[email protected]"
}

body = {
  type: "regular",
  recipients: recipients,
  settings: settings
}

begin
  gibbon.campaigns.create(body: body)
rescue Gibbon::MailChimpError => e
  puts "Houston, we have a problem: #{e.message} - #{e.raw_body}"
end

Add content to a campaign:

(Please note that Mailchimp does not currently support dynamic replacement of mc:edit areas in their drag-and-drop templates using their API. Custom templates can be used instead.)

body = {
  template: {
    id: template_id,
    sections: {
      "name-of-mc-edit-area": "Content here"
    }
  }
}

gibbon.campaigns(campaign_id).content.upsert(body: body)

Send a campaign:

gibbon.campaigns(campaign_id).actions.send.create

Schedule a campaign:

body = {
  schedule_time: "2016-06-27 20:00:00"
}
gibbon.campaigns(campaign_id).actions.schedule.create(body: body)

Interests

Interests are a little more complicated than other parts of the API, so here's an example of how you would set interests during at subscription time or update them later. The ID of the interests you want to opt in or out of must be known ahead of time so an example of how to find interest IDs is also included.

Subscribing a member to a list with specific interests up front:

gibbon.lists(list_id).members.create(body: {email_address: user_email_address, status: "subscribed", interests: {some_interest_id: true, another_interest_id: true}})

Updating a list member's interests:

gibbon.lists(list_id).members(member_id).update(body: {interests: {some_interest_id: true, another_interest_id: false}})

So how do we get the interest IDs? When you query the API for a specific list member's information:

gibbon.lists(list_id).members(member_id).retrieve

The response body (i.e. response.body) looks someting like this (unrelated things removed):

{"id"=>"...", "email_address"=>"...", ..., "interests"=>{"3def637141"=>true, "f7cc4ee841"=>false, "fcdc951b9f"=>false, "3daf3cf27d"=>true, "293a3703ed"=>false, "72370e0d1f"=>false, "d434d21a1c"=>false, "bdb1ff199f"=>false, "a54e78f203"=>false, "c4527fd018"=>false} ...}

The API returns a map of interest ID to boolean value. Now we to get interest details so we know what these interest IDs map to. Looking at this doc page, we need to do this:

gibbon.lists(list_id).interest_categories.retrieve

To get a list of interest categories. That gives us something like (again, this is the response.body):

{"list_id"=>"...", "categories"=>[{"list_id"=>"...", "id"=>"0ace7aa498", "title"=>"Food Preferences", ...}] ...}

In this case, we're interested in the ID of the "Food Preferences" interest, which is 0ace7aa498. Now we can fetch the details for this interest group:

gibbon.lists(list_id).interest_categories("0ace7aa498").interests.retrieve

That response gives the interest data, including the ID for the interests themselves, which we can use to update a list member's interests or set them when we call the API to subscribe her or him to a list.

Error handling

Gibbon raises an error when the API returns an error.

Gibbon::MailChimpError has the following attributes: title, detail, body, raw_body, status_code. Some or all of these may not be available depending on the nature of the error. For example:

begin
  gibbon.lists(list_id).members.create(body: body)
rescue Gibbon::MailChimpError => e
  puts "Houston, we have a problem: #{e.message} - #{e.raw_body}"
end

Other

Overriding Gibbon's API endpoint (i.e. if using an access token from OAuth and have the api_endpoint from the metadata):

Gibbon::Request.api_endpoint = "https://us1.api.mailchimp.com"
Gibbon::Request.api_key = your_access_token_or_api_key

You can set an optional proxy url like this (or with an environment variable MAILCHIMP_PROXY):

gibbon.proxy = 'http://your_proxy.com:80'

You can set a different Faraday adapter during initialization:

gibbon = Gibbon::Request.new(api_key: "your_api_key", faraday_adapter: :net_http)

Migrating from Gibbon 1.x

Gibbon 2.x+ exposes a different API from version 1.x. This is because Gibbon maps to MailChimp's API and because version 3 of the API is quite different from version 2. First, the name of the primary class has changed from API to Request. And the way you pass an API key during initialization is different. A few examples below.

Initialization

Gibbon 1.x:

gibbon = Gibbon::API.new("your_api_key")

Gibbon 2.x+:

gibbon = Gibbon::Request.new(api_key: "your_api_key")

MailChimp API 3 is a RESTful API, so Gibbon's syntax now requires a trailing call to a verb, as described above.

Fetching Lists

Gibbon 1.x:

gibbon.lists.list

Gibbon 2.x+:

gibbon.lists.retrieve

Fetching List Members

Gibbon 1.x:

gibbon.lists.members({:id => list_id})

Gibbon 2.x+:

gibbon.lists(list_id).members.retrieve

Subscribing a Member to a List

Gibbon 1.x:

gibbon.lists.subscribe({:id => list_id, :email => {:email => "[email protected]"}, :merge_vars => {:FNAME => "Bob", :LNAME => "Smith"}})

Gibbon 2.x+:

gibbon.lists(list_id).members.create(body: {email_address: "[email protected]", status: "subscribed", merge_fields: {FNAME: "Bob", LNAME: "Smith"}})

Thanks

Thanks to everyone who has contributed to Gibbon's development.

Copyright

  • Copyright (c) 2010-2022 Amro Mousa. See LICENSE.txt for details.
  • MailChimp (c) 2001-2022 The Rocket Science Group.

gibbon's People

Contributors

amro avatar csutter avatar digitalmoksha avatar dwkns avatar freemanoid avatar fsluis avatar gloaec avatar hoffm avatar jc4p avatar kale avatar kale-mc avatar killthekitten avatar kirs avatar krsmurata avatar matthiasrms avatar mattmanning avatar mberlanda avatar michaelklishin avatar mscoutermarsh avatar nellshamrell avatar olivierlacan avatar pat avatar pcai avatar petergoldstein avatar ravenchorus avatar sanemat avatar scottwater avatar shayfrendt avatar skalnik avatar sprachprofi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gibbon's Issues

How to update subscriber, its working fine for adding new subscriber

I am using below code to add new subscriber to MailChimp but its not working for updating scriber..

can anyone help me how to update existing subscriber to mailchimp?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PerceptiveMCAPI.Types;
using PerceptiveMCAPI;
using PerceptiveMCAPI.Methods;
using System.Web.UI.MobileControls;
namespace FilmAppWeb.Mailchip
{
public class MailChip
{
public void AddMailChip(String first_name, String last_name, String email)
{
List lstsub = new List();
Subscriber scb = new Subscriber();

    scb.email = email;
    scb.first_name = first_name;
    scb.last_name = last_name;

    lstsub.Add(scb);
    listBatchSubscribe_method(lstsub);
}

public void listBatchSubscribe_method(List<Subscriber> SubscriberList)
{
    listBatchSubscribeInput input = new listBatchSubscribeInput();
    // any directive overrides
    input.api_Validate = true;
    input.api_AccessType = EnumValues.AccessType.Serial;
    input.api_OutputType = EnumValues.OutputType.JSON;
    // method parameters
    input.parms.apikey = MCAPISettings.default_apikey;
    input.parms.id = System.Configuration.ConfigurationManager.AppSettings["ListID"];
    input.parms.double_optin = false;
    input.parms.replace_interests = true;
    input.parms.update_existing = true;
    //

    List<Dictionary<string, object>> batch =
    new List<Dictionary<string, object>>();
    foreach (Subscriber sub_rec in SubscriberList)
    {
        Dictionary<string, object> entry = new Dictionary<string, object>();
        entry.Add("EMAIL", sub_rec.email);
        // entry.Add("EMAIL_TYPE", sub_rec.email_type);
        entry.Add("FNAME", sub_rec.first_name);
        entry.Add("LNAME", sub_rec.last_name);
        //DateTime next_payment = sub_rec.last_payment.AddMonths(1);
        //entry.Add("NEXTPAY", next_payment);
        batch.Add(entry);
    }
    input.parms.batch = batch;
    // execution
    listBatchSubscribe cmd = new listBatchSubscribe(input);
    listBatchSubscribeOutput output = cmd.Execute();
    // output, format with user control
    if (output.api_ErrorMessages.Count > 0)
    {
        //showResults(output.api_Request, output.api_Response, // raw data
        //output.api_ErrorMessages, output.api_ValidatorMessages); // & errors

        //string apikey = System.Configuration.ConfigurationManager.AppSettings["mailchimpapikey"];
        //string listId = System.Configuration.ConfigurationManager.AppSettings["ListID"];

        //var inputs = new listInterestGroupingsInput(apikey, listId);
        //var lig = new listInterestGroupings(inputs);
        //var success = lig.Execute(inputs);
    }
    else
    {
        //show_listBatch1.Display(output);
        //campaignFoldersInput inputs = new campaignFoldersInput("459dad38ff06152f5eba1c4c7b3776b4-us3");
        //inputs.api_Validate = true;
        //inputs.api_AccessType = EnumValues.AccessType.Serial;
        //inputs.api_OutputType = EnumValues.OutputType.JSON;
        //// method parameters
        //inputs.parms.apikey = MCAPISettings.default_apikey;
        //inputs.parms.apikey = "459dad38ff06152f5eba1c4c7b3776b4-us3";

        //campaignFolders folders = new campaignFolders(inputs);
        //campaignFoldersOutput outputs = folders.Execute();
    }
}
public class Subscriber
{

    public object first_name;
    public object last_name;
    public object email_type;
    public DateTime last_payment;
    public object email { get; set; }

}

}

OpenSSL::SSL::SSLError problem

2.1.1 :007 > gb.lists.list
OpenSSL::SSL::SSLError: hostname "api.mailchimp.com" does not match the server certificate
    from /Users/mmahalwy/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/openssl/ssl.rb:139:in `post_connection_check'
    from /Users/mmahalwy/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:922:in `connect'
    from /Users/mmahalwy/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /Users/mmahalwy/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /Users/mmahalwy/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1369:in `request'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/rack-mini-profiler-0.9.1/lib/patches/net_patches.rb:7:in `block in request_with_mini_profiler'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/rack-mini-profiler-0.9.1/lib/mini_profiler/profiling_methods.rb:40:in `step'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/rack-mini-profiler-0.9.1/lib/patches/net_patches.rb:6:in `request_with_mini_profiler'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty/request.rb:93:in `perform'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty.rb:521:in `perform_request'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/httparty-0.13.1/lib/httparty.rb:473:in `post'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/gibbon-1.1.2/lib/gibbon/api_category.rb:28:in `call'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/gibbon-1.1.2/lib/gibbon/api_category.rb:48:in `method_missing'
    from (irb):7
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands/console.rb:90:in `start'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands/console.rb:9:in `start'
    from /Users/mmahalwy/.rvm/gems/ruby-2.1.1/gems/railties-4.0.4/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'2.1.1 :008 > 

Global variables in initializer for Rails

I have an initializer titled mailchimp.rb in my /lib directory with the following:

Gibbon::API.api_key = "API_KEY_HERE"

In console if i run Gibbon::API.new the api_key is not set. Any reason why this wouldn't work?

More sensible exceptions to easier error-handling

Hello there,

Thanks for this awesome project, it have helped us a lot during our work.

However, we have a problem, with errors like this:

<Gibbon::MailChimpError: MailChimp API Error: [email protected] 
is already subscribed to list Developer test. <a href="http://billetto.us5.
list-manage.com/subscribe/send-email?u=SOMETHING&id=SOMETHING_ELSE&e=SOMETHING_ELSE2=">Click here to update your profile.
</a>(code 214)>

We are not interested in exactly this error to show up in our exception-list. This is a user error, that we want to ignore when we see it.

To catch an exception like this is pretty darn ugly because we will have to put it in a wrapper and actually look a the return, or the error code ((code 214)).

Could we push for some more sensible exceptions?

There is a lot of exceptions to take care of: http://apidocs.mailchimp.com/api/rtfm/exceptions.field.php

Gibbon Does Not Return Error Message (Error Handling)

When using rescue Gibbon::MailChimpError I am putting the Gibbon::API.errors in a flash.now, instead of getting "some text explaining the error" I get something like: "#Gibbon::APICategory:0x00000001cc60b8"

If I don't have the rescue block in and I submit params that raise an error (e.g. an email that is already subscribed to the list) I get "MailChimp API Error: {submitted email} is already subscribed to {list}. Click here to update your profile. (code 214)" from action controller.

I would expect Gibbon::API.errors to return this message as this is what the Gibbon documentation for error handling states?

I'm sure I'm doing something wrong as I get the API error that I would expect from Mailchimp without having the rescue block in, I guess it is just unclear to me as to where I can pull error messages out through Gibbon?

Issue with double_optin

Hi, I've just set up a new mailchimp account & list. Is there any reason why this api call, results in the user receiving the double optin email? Is there anything I need to do on the mailchimp webinterface?

gb.lists.subscribe({:id => 'my_list_id', :double_optin => false, :send_welcome => false, :email => {email: user.email}})

MailChimp API Error: You must specify a email value (code -100)

Hi, trying to subscribe an email to an existing list but failing:

Gibbon::API.lists.subscribe( { :id => 'foofoo', :email_address => '[email protected]' } )
Gibbon::MailChimpError: MailChimp API Error: You must specify a email value (code -100)

An API key has been registered and I can successfully see all my lists.
Any idea why this is happening?

campignCreate is not exported by this server

Hi,

when i'm trying to create a campaign on our server, i'm getting this error:
result:code-90errorMethod campignCreate is not exported by this server

I tried running it locally and the code seemed to work just fine.
I'm issuing the create_campaign create from within a controller's create (POST) action, does it have something to do with that?

Any idea what's this error?

Thanks,
Roy

Issue with welcome email not being sent

gb.lists.subscribe({:id => list_id, :email => {:email => 'email_address'}, :merge_vars => {:FNAME => 'First Name', :LNAME => 'Last Name'}, :double_optin => false})

When using the code above the welcome email is not sent even though in the readme it says that it will.

Rails server or console wont start after installing gibbon

After installing the gibbon gem to my app, I get an error message while trying to start the server or the console.

[1] $ rails s                                                                                                                                                                
/Users/lurraca/.rvm/gems/[email protected]/gems/gibbon-0.4.6/lib/gibbon.rb:8:in `<class:Gibbon>': undefined method `default_timeout' for Gibbon:Class (NoMethodError)
    from /Users/lurraca/.rvm/gems/[email protected]/gems/gibbon-0.4.6/lib/gibbon.rb:5:in `<top (required)>'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
    from /Users/lurraca/.rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
    from /Users/lurraca/Desktop/projects/pixelpt/shop.pr-web.rails/config/application.rb:6:in `<top (required)>'
    from /Users/lurraca/.rvm/gems/[email protected]/gems/railties-3.2.11/lib/rails/commands.rb:53:in `require'
    from /Users/lurraca/.rvm/gems/[email protected]/gems/railties-3.2.11/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /Users/lurraca/.rvm/gems/[email protected]/gems/railties-3.2.11/lib/rails/commands.rb:50:in `tap'
    from /Users/lurraca/.rvm/gems/[email protected]/gems/railties-    3.2.11/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Yet another SSL::SSLError issue

Hi,

if call gb = Gibbon::API.new('XXXXXXXXXXXXXXXXXXX-us4') get:

OpenSSL::SSL::SSLError (hostname "us1.api.mailchimp.com." does not match the server certificate):

note us1in the url. This happens both with api_keys created with mailchimp panel that those generated with omniauth-mailchimp.

Have tried also with:

      token = 'xxxxxxxxxxxxxxxx-us4'
      gb = Gibbon::API.new(token, {api_endpoint:
        "https://#{token.split(//).last(3).join}.api.mailchimp.com."})

Same error but in this case the url have us4.

MailChimp API through proxy

According to the post found in their google group, the MailChimp API does not support communicating via a proxy.

I have read that there are some patches like this one, and I would like to know if it possible to implement this in Gibbon. If so, kindly point me to the "right direction", i.e. which modules and files I should look into, and then I will make a pull request, assuming you want this workaround to be part of the gem.

Thank you.

edit/update email

Can the mailchimp api call (.listupdatemember) be used? I am having problems using this call

I appreciate any help...Thanks!

After creating a campaign I can't schedule it

I create a campaign using campaign_create function and I store the result in campaign_id variable:

campaign_id = mailchimp.campaign_create(
    :type => 'regular',
    :options => {
      :subject => "xxxxx",
      :list_id => list["id"],
      :from_email => 'xxxxx',
      :from_name => 'xxxxx',
      :template_id => 'xxxxx'
    },
    :content => {
      'html_main' => 'xxxxx'
    }
)

After that, I want to schedule the campaign using campaign_schedule function but it returns an error:

mailchimp.campaign_schedule(
  :cid => campaign_id,
  :schedule_time => (Date.today+3.days).to_s(:db) 
)
=> {"error"=>"Invalid Campaign ID: \"308ce5e39d\"", "code"=>300}

I have checked if campaign with that id exists and it seems to be ok. Any ideas?

Thank you.

Psych::SyntaxError: couldn't parse YAML

Ruby 1.9.2-p180, Rails 3.1.0.rc4.

The following error occurs for API call I've tried.

> mc = Gibbon::API.new("MY_API_KEY")
 => #<Gibbon::API:0x000001033822d8 @apikey="MY_API_KEY", @default_params={:apikey=>"MY_API_KEY"}> 
ruby-1.9.2-p180 :012 > mc.campaigns
Psych::SyntaxError: couldn't parse YAML at line 1 column 218
    from /Users/jonmccartie/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse'
    from /Users/jonmccartie/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
    from /Users/jonmccartie/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:119:in `parse'
    from /Users/jonmccartie/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:106:in `load'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/crack-0.1.8/lib/crack/json.rb:12:in `parse'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/parser.rb:116:in `json'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/parser.rb:136:in `parse_supported_format'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/parser.rb:103:in `parse'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/parser.rb:66:in `call'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/request.rb:217:in `parse_response'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/request.rb:189:in `handle_response'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty/request.rb:71:in `perform'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty.rb:390:in `perform_request'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/httparty-0.7.8/lib/httparty.rb:358:in `post'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/gibbon-0.1.6/lib/gibbon.rb:31:in `call'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/gibbon-0.1.6/lib/gibbon.rb:46:in `method_missing'
    from (irb):12
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:45:in `start'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/railties-3.1.0.rc4/lib/rails/commands/console.rb:8:in `start'
    from /Users/jonmccartie/.rvm/gems/ruby-1.9.2-p180@default/gems/railties-3.1.0.rc4/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'

Some responses not decoded correctly

campaign_create is meant to return the campaign_id but it is returned without decoding i.e. surrounded by quotation marks

campaign_send is meant to return a boolean, but instead returns a string (true/false)

using ActiveSupport::JSON.decode instead of JSON.parse appears to resolve this.

Unsubscribe example

Minor, but it'd be useful to see an example in the readme of unsubscribing a single user with the gem. I couldn't find that listed anywhere but dug into the mailchimp API and took a flier and it worked. Let the people know it can be done! :)

(this is from within the User.rb model in a before_destroy callback, hence the "self")

def unsubscribe
mailchimp = Gibbon::API.new
result = mailchimp.lists.unsubscribe({
:id => ENV["MAILCHIMP_LIST_ID"],
:email => {:email => self.email},
:delete_member => true, # this is NOT the default value
:send_notify => true,
:send_goodbye => true
})
Rails.logger.info("Unsubscribed #{self.email} from MailChimp") if result
end

Documentation unclear about how to use 'start' and 'limit' options with 'lists.members' call

... and probably other calls that require they be passed in an 'opts' hash.

For example, I want to paginate through a list of 37,000 user accounts (the Export API does not return the rich data I want, for example, the subscription status 'unsubscribed' or 'subscribed') ...

I saw in the Mailchimp documentation that this is possible:
http://apidocs.mailchimp.com/api/2.0/lists/members.php

So, I tried passing 'start' and 'limit' settings like so (this is how you have documented it for listing campaigns and such):

lists.members({:id => MAILCHIMP_LIST_ID, :start => 0, :limit => 1})

... but that doesn't work. Eventually (30m later) I realized I needed to do it like so:

lists.members({:id => MAILCHIMP_LIST_ID, :opts => {:start => 0, :limit => 1}})

Could be helpful to make a note of that in the documentation, or at least, this issue will help others who search for it.

Thanks!
Kevin Trowbridge

How to update list subscriber, its working fine for adding new subscriber

I am using below code to add new scriber to mailchimp but its not working for updating scriber..

can anyone help me how to update existing subscriber to mailchimp?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PerceptiveMCAPI.Types;
using PerceptiveMCAPI;
using PerceptiveMCAPI.Methods;
using System.Web.UI.MobileControls;
namespace FilmAppWeb.Mailchip
{
public class MailChip
{
public void AddMailChip(String first_name, String last_name, String email)
{
List lstsub = new List();
Subscriber scb = new Subscriber();

        scb.email = email;
        scb.first_name = first_name;
        scb.last_name = last_name;

        lstsub.Add(scb);
        listBatchSubscribe_method(lstsub);
    }

    public void listBatchSubscribe_method(List<Subscriber> SubscriberList)
    {
        listBatchSubscribeInput input = new listBatchSubscribeInput();
        // any directive overrides
        input.api_Validate = true;
        input.api_AccessType = EnumValues.AccessType.Serial;
        input.api_OutputType = EnumValues.OutputType.JSON;
        // method parameters
        input.parms.apikey = MCAPISettings.default_apikey;
        input.parms.id = System.Configuration.ConfigurationManager.AppSettings["ListID"];
        input.parms.double_optin = false;
        input.parms.replace_interests = true;
        input.parms.update_existing = false;
        //

        List<Dictionary<string, object>> batch =
        new List<Dictionary<string, object>>();
        foreach (Subscriber sub_rec in SubscriberList)
        {
            Dictionary<string, object> entry = new Dictionary<string, object>();
            entry.Add("EMAIL", sub_rec.email);
            // entry.Add("EMAIL_TYPE", sub_rec.email_type);
            entry.Add("FNAME", sub_rec.first_name);
            entry.Add("LNAME", sub_rec.last_name);
            //DateTime next_payment = sub_rec.last_payment.AddMonths(1);
            //entry.Add("NEXTPAY", next_payment);
            batch.Add(entry);
        }
        input.parms.batch = batch;
        // execution
        listBatchSubscribe cmd = new listBatchSubscribe(input);
        listBatchSubscribeOutput output = cmd.Execute();
        // output, format with user control
        if (output.api_ErrorMessages.Count > 0)
        {
            //showResults(output.api_Request, output.api_Response, // raw data
            //output.api_ErrorMessages, output.api_ValidatorMessages); // & errors

            //string apikey = System.Configuration.ConfigurationManager.AppSettings["mailchimpapikey"];
            //string listId = System.Configuration.ConfigurationManager.AppSettings["ListID"];

            //var inputs = new listInterestGroupingsInput(apikey, listId);
            //var lig = new listInterestGroupings(inputs);
            //var success = lig.Execute(inputs);
        }
        else
        {
            //show_listBatch1.Display(output);
            //campaignFoldersInput inputs = new campaignFoldersInput("459dad38ff06152f5eba1c4c7b3776b4-us3");
            //inputs.api_Validate = true;
            //inputs.api_AccessType = EnumValues.AccessType.Serial;
            //inputs.api_OutputType = EnumValues.OutputType.JSON;
            //// method parameters
            //inputs.parms.apikey = MCAPISettings.default_apikey;
            //inputs.parms.apikey = "459dad38ff06152f5eba1c4c7b3776b4-us3";

            //campaignFolders folders = new campaignFolders(inputs);
            //campaignFoldersOutput outputs = folders.Execute();
        }
    }
    public class Subscriber
    {

        public object first_name;
        public object last_name;
        public object email_type;
        public DateTime last_payment;
        public object email { get; set; }

    }
}

}

undefined method `new' for Gibbon:Module (NoMethodError)

Latest version of gibbon gem gives me this error below. Reverted back to 0.4.6 to.

$ rails c
/Users/liouyang/Development/code/Walker/goatee/config/initializers/mailchimp.rb:1:in `<top (required)>': undefined method `new' for Gibbon:Module (NoMethodError)
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/engine.rb:609:in `block (2 levels) in <class:Engine>'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/engine.rb:608:in `each'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/engine.rb:608:in `block in <class:Engine>'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:210:in `block (2 levels) in each_strongly_connected_component_from'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:209:in `block in each_strongly_connected_component_from'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:44:in `each'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:44:in `tsort_each_child'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:203:in `each_strongly_connected_component_from'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
    from /Users/liouyang/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/liouyang/Development/code/Walker/goatee/config/environment.rb:5:in `<top (required)>'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
    from /Users/liouyang/.rvm/gems/ruby-1.9.3-p194/gems/railties-4.0.0/lib/rails/commands.rb:63:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Raise error if batch command partially failed

Operations such as lists.batch_subscribe return errors in an errors array, rather than a single error value that the response handler expects. At the moment if an error occurs during that operation gibbon silently returns.

As we can't raise individual errors for each error in the array we have two choices:

  1. Raise a Gibbon::MailChimpError for the first error in the array
  2. Introduce a new Gibbon::MultipleMailChimpErrors to encapsulate all of the errors

Thoughts?

csv parser doesnt understand quoted fields

Timestamp columns are quoted with comma in them, system where the files comes from doesn't allow changing delimiter.

ERROR: extra data after last expected column
CONTEXT: COPY five9_contacts, line 2: "1,"Tue, 6 Nov 2012 12:31:29","Thu, 6 Dec 2012 17:27:50",0,Gabby Balajadia,9252988468,,,Gabby,Balajad..."

How to add a user to a specific group while subscribing to a list

I am running this on console and its adding user in my subscribed_list. Works like charm.

  gb.lists.subscribe({:id => list_id, :email => {:email => '[email protected]'}, :merge_vars => {:FNAME => 'Mohit', :LNAME => 'Jain', }, :double_optin => false})

Now I want to subscriber to groups: Like I have a group " User Type" which has some predefined 4 values. How can I map this User Type in subscribe method?

JSON Parse Error

I just recently upgraded to Rails 3.1 and in the process I caught an issue with the list_subscribe method, it was a JSON parse error as shown here: https://gist.github.com/1680053

I downgraded gibbon back to 0.3.1 and everything ran fine.

Setting custom timeout doesn't seem to do anything

I'm doing a batch subscribe, and the default 30s wasn't long enough. I tried setting it to 600, but it's still timing out in 30s

    gb.timeout = 600

    raise gb.timeout.inspect

The above line returns 'nil'

Unable to unset once set merge variable

I have an integer merge variable that using the Mailchimp website I can unset by clearing the field. However, calling .lists.batch_subscribe with update_existing: true and merge_vars: { test_var: nil } does not unset test_var, it just leaves the existing value in there.

Performing the same query with :test_var set to a non nil value works fine.

(Apologies if this is not a gibbon issue but an API one, but theres no support links in the README!)

undefined method `ssl_implied?' for HttpParty Request

I think lastest httparty gem get some udpates that broke current gibbon version ?

Could you tell me what is the correct httparty version you are using.

This is extracted from my Gemfile.lock :

gibbon (0.3.5)
httparty (> 0.6.0)
httparty (> 0.6.0)
json (> 1.4.0)
json (> 1.4.0)
rdoc

[...]

httparty (0.9.0)
multi_json (~> 1.0)
multi_xml

Gibbon does not speak Ruby

g = Gibbon::API.new(MAILCHIMP_API_KEY)
#=> #<Gibbon::API:0x00000007ad89d0 @api_key="KEY", @api_endpoint=nil, @timeout=nil, @throws_exceptions=nil, @default_params={:apikey=>"KEY"}>

g.templates
#=> #<Gibbon::APICategory:0x00000007100cc8 @category_name="templates", @api_key="KEY", @api_endpoint=nil, @default_params={:apikey=>"KEY"}, @throws_exceptions=true, @timeout=30>

g.respond_to?(:templates)
#=> false

g.methods.include?(:templates)
#=> false

I believe that g.respond_to?(:templates) should return true. Maybe via g.respond_to_missing?(:templates) ? What do you think?

undefined method `dump' for MultiJson:Module

API calls fail for me because of an apparent multi_json issue.

Some of my reading suggests that Farraday and Httparty can't existing together. Is this true?

Also, I've got sever versions of multi_json installed in this project

multi_json (1.6.1, 1.5.0, 1.3.7, 1.3.6, 1.3.5, 1.3.4, 1.3.2, 1.1.0, 1.0.4)

It's conceivable that Gibbon is using the wrong one. Is it possible to specify the correct version of multi_json to use? Which version would you recommend?

Trace:

1.9.2p290 :002 > campaigns = gb.campaigns({:start => 0, :limit => 100})
NoMethodError: undefined method dump' for MultiJson:Module from /Users/eblatt/.rvm/gems/ruby-1.9.2-p290/gems/gibbon-0.4.4/lib/gibbon.rb:41:incall'
from /Users/eblatt/.rvm/gems/ruby-1.9.2-p290/gems/gibbon-0.4.4/lib/gibbon.rb:66:in `method_missing'
from (irb):2

Subscribes to wrong list

Here is the code for subscribing a new user to a list.
I am using the direct list id that mailchimp provides in my list settings. However, for some reason it subcribes to the wrong list.

Any ideas of why this is occuring?

gb = Gibbon.new

gb.list_subscribe(:id => "***********", :email_address => @user.email, :merge_vars => {'fname' => @user.first_name, 'lname' => @user.last_name }, :email_type => "html", :double_optin => false, :send_welcome => false)

Thanks!

Error installing gibbon under jRuby

Hi,

trying to install the gibbon gem under jruby 1.6.1 I get the following error with a (very very long) stacktrace.

$ gem install gibbon
System.java:-2:in `arraycopy': java.lang.ArrayIndexOutOfBoundsException
  from DefaultResolver.java:111:in `makeTime'
  from DefaultResolver.java:277:in `create'
  from DefaultResolver.java:317:in `handleScalar'
  from DefaultResolver.java:435:in `orgHandler'
  from DefaultResolver.java:455:in `node_import'
  from DefaultResolver$s$1$0$node_import.gen:65535:in `call'
  from CachingCallSite.java:137:in `call'
  from RubyLoadHandler.java:40:in `handle'
  from Parser.java:300:in `addNode'
  from DefaultYAMLParser.java:676:in `yyparse'
  from Parser.java:290:in `yechtparse'
  from Parser.java:284:in `parse'
  from YParser.java:152:in `load'
  from YParser$s$0$1$load.gen:65535:in `call'
  from JavaMethod.java:630:in `call'
  from DynamicMethod.java:205:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from CallOneArgNode.java:57:in `interpret'
  from LocalAsgnNode.java:123:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from CallOneArgNode.java:57:in `interpret'
  from LocalAsgnNode.java:123:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from CallOneArgNode.java:57:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from RescueNode.java:216:in `executeBody'
  from RescueNode.java:120:in `interpretWithJavaExceptions'
  from RescueNode.java:110:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from FCallOneArgNode.java:36:in `interpret'
  from InstAsgnNode.java:95:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from EnsureNode.java:96:in `interpret'
  from BeginNode.java:83:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from WhenOneArgNode.java:36:in `whenSlowTest'
  from WhenOneArgNode.java:46:in `when'
  from CaseNode.java:133:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
  from InterpretedBlock.java:374:in `evalBlockBody'
  from InterpretedBlock.java:347:in `yield'
  from InterpretedBlock.java:304:in `yield'
  from Block.java:130:in `yield'
  from YieldNode.java:112:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
  from InterpretedBlock.java:374:in `evalBlockBody'
  from InterpretedBlock.java:295:in `yield'
  from InterpretedBlock.java:229:in `yieldSpecific'
  from Block.java:99:in `yieldSpecific'
  from RubyKernel.java:1418:in `loop'
  from RubyKernel$s$0$0$loop.gen:65535:in `call'
  from CachingCallSite.java:272:in `cacheAndCall'
  from CachingCallSite.java:114:in `callBlock'
  from CachingCallSite.java:123:in `callIter'
  from FCallNoArgBlockNode.java:32:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:169:in `call'
  from DefaultMethod.java:171:in `call'
  from CachingCallSite.java:272:in `cacheAndCall'
  from CachingCallSite.java:114:in `callBlock'
  from CachingCallSite.java:123:in `callIter'
  from CallNoArgBlockNode.java:64:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:255:in `call'
  from DefaultMethod.java:203:in `call'
  from CachingCallSite.java:312:in `cacheAndCall'
  from CachingCallSite.java:182:in `callBlock'
  from CachingCallSite.java:186:in `call'
  from RubyClass.java:806:in `newInstance'
  from RubyClass$i$newInstance.gen:65535:in `call'
  from JavaMethod.java:283:in `call'
  from WrapperMethod.java:62:in `call'
  from CachingCallSite.java:302:in `cacheAndCall'
  from CachingCallSite.java:173:in `call'
  from FCallTwoArgNode.java:38:in `interpret'
  from LocalAsgnNode.java:123:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from EnsureNode.java:96:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:255:in `call'
  from DefaultMethod.java:203:in `call'
  from CachingCallSite.java:312:in `cacheAndCall'
  from CachingCallSite.java:182:in `callBlock'
  from CachingCallSite.java:186:in `call'
  from CallTwoArgBlockPassNode.java:62:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:298:in `call'
  from DefaultMethod.java:219:in `call'
  from CachingCallSite.java:332:in `cacheAndCall'
  from CachingCallSite.java:216:in `callBlock'
  from CachingCallSite.java:225:in `callIter'
  from CallThreeArgBlockNode.java:64:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:276:in `call'
  from DefaultMethod.java:211:in `call'
  from CachingCallSite.java:322:in `cacheAndCall'
  from CachingCallSite.java:207:in `call'
  from FCallThreeArgNode.java:40:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
  from InterpretedBlock.java:374:in `evalBlockBody'
  from InterpretedBlock.java:347:in `yield'
  from InterpretedBlock.java:304:in `yield'
  from Block.java:130:in `yield'
  from RubyIO.java:1121:in `open'
  from RubyKernel.java:298:in `open'
  from RubyKernel$s$0$2$open.gen:65535:in `call'
  from DynamicMethod.java:217:in `call'
  from CachingCallSite.java:312:in `cacheAndCall'
  from CachingCallSite.java:182:in `callBlock'
  from CachingCallSite.java:191:in `callIter'
  from FCallTwoArgBlockNode.java:34:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from RescueNode.java:216:in `executeBody'
  from RescueNode.java:120:in `interpretWithJavaExceptions'
  from RescueNode.java:110:in `interpret'
  from BeginNode.java:83:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from IfNode.java:119:in `interpret'
  from IfNode.java:119:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:233:in `call'
  from DefaultMethod.java:195:in `call'
  from CachingCallSite.java:302:in `cacheAndCall'
  from CachingCallSite.java:173:in `call'
  from CallTwoArgNode.java:59:in `interpret'
  from InstAsgnNode.java:95:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from RescueNode.java:216:in `executeBody'
  from RescueNode.java:120:in `interpretWithJavaExceptions'
  from RescueNode.java:110:in `interpret'
  from BeginNode.java:83:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:147:in `call'
  from DefaultMethod.java:163:in `call'
  from CachingCallSite.java:262:in `cacheAndCall'
  from CachingCallSite.java:105:in `call'
  from VCallNode.java:85:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:255:in `call'
  from DefaultMethod.java:203:in `call'
  from CachingCallSite.java:312:in `cacheAndCall'
  from CachingCallSite.java:182:in `callBlock'
  from CachingCallSite.java:186:in `call'
  from RubyClass.java:806:in `newInstance'
  from RubyClass$i$newInstance.gen:65535:in `call'
  from JavaMethod.java:283:in `call'
  from CachingCallSite.java:302:in `cacheAndCall'
  from CachingCallSite.java:173:in `call'
  from CallTwoArgNode.java:59:in `interpret'
  from DAsgnNode.java:110:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
  from InterpretedBlock.java:374:in `evalBlockBody'
  from InterpretedBlock.java:347:in `yield'
  from InterpretedBlock.java:304:in `yield'
  from Block.java:130:in `yield'
  from RubyArray.java:1595:in `eachCommon'
  from RubyArray.java:1602:in `each'
  from RubyArray$i$0$0$each.gen:65535:in `call'
  from CachingCallSite.java:272:in `cacheAndCall'
  from CachingCallSite.java:114:in `callBlock'
  from CachingCallSite.java:123:in `callIter'
  from CallNoArgBlockNode.java:64:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:233:in `call'
  from DefaultMethod.java:195:in `call'
  from CachingCallSite.java:302:in `cacheAndCall'
  from CachingCallSite.java:173:in `call'
  from CallTwoArgNode.java:59:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from RescueNode.java:216:in `executeBody'
  from RescueNode.java:120:in `interpretWithJavaExceptions'
  from RescueNode.java:110:in `interpret'
  from BeginNode.java:83:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from ASTInterpreter.java:111:in `INTERPRET_BLOCK'
  from InterpretedBlock.java:374:in `evalBlockBody'
  from InterpretedBlock.java:347:in `yield'
  from InterpretedBlock.java:304:in `yield'
  from Block.java:130:in `yield'
  from RubyArray.java:1595:in `eachCommon'
  from RubyArray.java:1602:in `each'
  from RubyArray$i$0$0$each.gen:65535:in `call'
  from CachingCallSite.java:272:in `cacheAndCall'
  from CachingCallSite.java:114:in `callBlock'
  from CachingCallSite.java:123:in `callIter'
  from CallNoArgBlockNode.java:64:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:147:in `call'
  from DefaultMethod.java:163:in `call'
  from CachingCallSite.java:262:in `cacheAndCall'
  from CachingCallSite.java:105:in `call'
  from VCallNode.java:85:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from IfNode.java:119:in `interpret'
  from IfNode.java:119:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from CallSpecialArgNode.java:67:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from CaseNode.java:138:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from FCallOneArgNode.java:36:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from RescueNode.java:216:in `executeBody'
  from RescueNode.java:120:in `interpretWithJavaExceptions'
  from RescueNode.java:110:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from CallOneArgNode.java:57:in `interpret'
  from NewlineNode.java:103:in `interpret'
  from BlockNode.java:71:in `interpret'
  from ASTInterpreter.java:74:in `INTERPRET_METHOD'
  from InterpretedMethod.java:190:in `call'
  from DefaultMethod.java:179:in `call'
  from CachingCallSite.java:282:in `cacheAndCall'
  from CachingCallSite.java:139:in `call'
  from /Users/einar/.rvm/rubies/jruby-1.6.1/bin/gem:25:in `chained_0_rescue_1$RUBY$SYNTHETIC__file__'
  from /Users/einar/.rvm/rubies/jruby-1.6.1/bin/gem:24:in `__file__'
  from /Users/einar/.rvm/rubies/jruby-1.6.1/bin/gem:-1:in `load'
  from Ruby.java:671:in `runScript'
  from Ruby.java:575:in `runNormally'
  from Ruby.java:424:in `runFromMain'
  from Main.java:278:in `doRunFromMain'
  from Main.java:198:in `internalRun'
  from Main.java:164:in `run'
  from Main.java:148:in `run'
  from Main.java:128:in `main'

Rejects emails with plus signs

Any email that contains a plus sign (which is actually valid) MailChimp sends back an "email invalid" error message. When using the form from MailChimp there are no problems with this. So I guess this is about how gibbon processes the data for transmission.

Unknown method "list_interest_groupings/first"

I have initialize my mailchimp object but when i try to get grouping_id igot following error
(rdb:34) mc.grouping_id
*** Gibbon::MailChimpError Exception: MailChimp API Error: Unknown method "list_interest_groupings/first" (code -32601)

RubyGems version does not match docs

A few folks (including me) have run into an issue where adding gem 'gibbon' to their gemfile is pulling down the older version of Gibbon, which is out of sync with the current docs.

I understand you're updating Gibbon for the new 2.0 API (and thank you for doing it!), but you may want to update the Readme to reflect the fact that people need to download from github vs. rubygems to get the features discussed in the doc.

See StackOverflow describing this issue here: http://stackoverflow.com/questions/17228587/why-does-gibbon-throw-uninitialized-constant-gibbonapi-nameerror/

Thanks again for your work on Gibbon! <3

Install broken because of ruby version required by httparty

Hello,

My install just broke because my project is using Ruby 1.9.2 and the last HTTParty requires Ruby version 1.9.3

Not sure how you want to fix this, but I guess the gemspec of Gibbon should either specify the same Ruby version, or specify a HTTParty version prior to this change (like 0.11.0).

This is what I did to deal with the problem:
Instead of letting Bundler deal with this particular dependency, I did gem install httparty -v '0.11.0' and then gem install gibbon.

mig

Update users groups

So I have four groups for MailChimp users:

[
{"name"=>"Free Customers", "interested"=>true},
{"name"=>"Subscribers", "interested"=>false},
{"name"=>"Paying Customers", "interested"=>false},
{"name"=>"Test", "interested"=>true}
]
I have a quick question, at the time when I subscribe a user to MailChimp list, I definetely should have an option to add a user to one or the other group. And then I would like to change based on the user status (either the user is Free or Paid). There is even an API call for this purpose: http://apidocs.mailchimp.com/api/2.0/lists/update-member.php

However it is a bit confusing what sort of merge variables should I put for the group update. As the group change sits really deep...

info["data"].first["merges"]["GROUPINGS"].first["groups"]
Could you please tell me how to change a group of interest of users?

I'm using

Rails 4.0.0
Ruby 2
Gibbon 1.1
MailChimp v2

Requests hanging in Rails?

I am attempting to add some Mailchimp integration to a Rails app. However, all of the requests I make inside of Rails hang indefinitely.

I made the same call (directly from the docs) gb.campaigns.list({:start => 0, :limit => 100}) which works in irb but does not work inside of Rails. I am using the same code in both to make the calls, and I also ensured that API keys are set correctly.

Any ideas why it might not work inside of Rails?

Support API 2.0

Today Mailchimp launches the 2.0 API, which differs from the 1.3 version. I'm new to Mailchimp and I want to start development with the edge version (when our stuff will go to production, the edge will be already stable).

I'm trying to decide which gem should I use and I want to know, will gibbon have support of the 2.0 API or not. If it will be so, then what must be changed and how can I contribute?

Thank you.

API Call (listSubscribe) with merge_vars set not working

I am doing some test API calls to my MailChimp account and I am trying to subscribe a new user to a test list and I am submitting the merge_vars in with the call, but none of the variables are getting set.

Here is my test code:

mc.listSubscribe({:id => "list_id_here", :email_address => "[email protected]", :merge_vars => ["FNAME" => "Chimpy", "LNAME" => "Chimperson"], :double_optin => false})

Add subscribe to lists

Hi,

I'm trying

list = gb.listSubscribe({:id => 'b2c5557688', :email_address => '[email protected]'})

that line reurns true, but is not added to the list, Is something wrong ? or how I can add subscribes to my lists ?

Thanks, regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.