Mailchimpv3

A ruby library for Mailchimp API V3.0, you can manage your lists and add members to them.

Installation

Add this line to your application's Gemfile:

gem 'mailchimpv3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mailchimpv3

Usage

Initialize the client with your API_KEY

api_client = Mailchimpv3::API.new "API_KEY"

Lists

All

You can now list all your lists

api_client = Mailchimpv3::API.new "API_KEY"
api_client.lists().all()

Find

Find a list based on its id

api_client = Mailchimpv3::API.new "API_KEY"
api_client.lists().find("id")

You can also specify the params that you want to recieve

api_client = Mailchimpv3::API.new "API_KEY"
api_client.lists().find("id", {fields: 'lists.id, lists.name, lists.contact,
                    lists.permission_reminder,lists.campaign_defaults,
                    lists.email_type_option,lists.stats.member_count'})

Create new list

You can now create a new list with the name, contact info, the permission reminder and the campaign defaults. Verify Mailchimp API 3.0 Docs for more info.

api = Mailchimpv3::API.new correct_key
api.list(name: "alive",
        contact:
          { :company => "MailChimp",
            :address1 => "675 Ponce De Leon Ave NE",
            :address2 => "Suite 5000",
            :city=> "Atlanta",
            :state=>"GA",
            :zip=> "30308",
            :country=>"US",
            :phone => ""
          },
        permission_reminder: "You're receiving this email because you signed up for updates about",
        campaign_defaults:
          { :from_name=>"Freddie",
            :from_email=>"[email protected]",
            :subject=>"News",
            :language=>"es"
          }
      ).save()

Add members

Add a new member with the email and status

api_client = Mailchimpv3::API.new "API_KEY"
list = api.list().find("f355f76299")
list.addmember("[email protected]","suscribed")

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Xosmond/mailchimpv3.

NOTE: You must sign your commits.

License

The gem is available as open source under the terms of the MIT License.