How to create mail chimp list using gibbon gem in Rails?

I have created a rails app with rails 3.2 and ruby 2.1.2. I have used gibbon gem for accessing mail chimp API for create/edit/delete mail chimp list and also to manage subscribers. I am unable to create new mail chimp list using methods provided by gibbon. But I am able to get already created(default lists in mail chimp web app) lists. I want to know how to create a mail chimp list. I did not find examples for the same in github page.

Upvotes: 0

Views: 1181

Answers (1)

Eventually I got the solution. I can create mail chimp list using following code by using Gibbon 2.2.4.

gibbon = Gibbon::Request.new()
params = {
    "name" => name,
    "contact" => {
        "company" => "Your Company",
        "address1" => "address one",
        "address2" => "address two",
        "city" => "city",
        "state" => "state",
        "zip" => "zip-code",
        "country" => "country name",
        "phone" => "phone"
    },
    "permission_reminder" => "You are receiving this email, because you subscribed our product.",
    "campaign_defaults" => {
        "from_name" => "Test user",
        "from_email" => "[email protected]",
        "subject" => "",
        "language" => "en"
    },
    "email_type_option" => true
}

mail_chimp_list = gibbon.lists.create(body: params)

my gibbon.rb file looks like

Gibbon::Request.api_endpoint = "https://****.api.mailchimp.com"
Gibbon::Request.api_key = "api-key"
Gibbon::Request.timeout = 15

Upvotes: 1

Related Questions