Giter Site home page Giter Site logo

feralchimp's Introduction

Feralchimp

Feralchimp is a Ruby based API wrapper for the MailChimp API v2.0.

Installation:

gem "feralchimp", github: "reviewed/feralchimp"

Options:

  • Feralchimp.api_key = Mailchimp key w/ region part.
  • You can also optionally set ENV["MAILCHIMP_API_KEY"] too
  • Feralchimp.timeout = Defaults: 5

There is one setter called exportar (Spanish for export) that is a public but private API method so that the class can communicate with the instance when a user chains using export. This variable is always reset back to false each time #call is called. While it won't hurt anything if you play with it (such as setting it to true,) just be warned it's internal and it's state is always reset even if it's already false and setting it to any value but false or nil will just result in you hitting the Export API.

Normal API Usage:

Feralchimp.api_key = api_key
Feralchimp.new.lists #=> {}
Feralchimp.lists #=> {}

Feralchimp.new(:api_key => api_key).lists # => {}

Using the class creates a new instance each run but you also have the option to create your own persistant instance so you can control key state. When creating a new instance you can send an optional api key which will be set for that instance only.

Export API Usage:

Feralchimp.new.export.list(:id => list_id) #=> [{}]
Feralchimp.export.list(:id => list_id) #=> [{}]

Feralchimp.new(:api_key => api_key).export.list(:id => list_id)

According to the Mailchimp spec it will send a plain text list of JSON arrays delimited by \n, with the first JSON array being the header (AKA the hash keys) keeping in line with this we actually parse this list for you, in that we take the first JSON array and zip it into an array, like so:

# What Mailchimp gives us:
# ["header1", "header2"]
# ["array1_v1", "array1_v2"]
# ["array2_v1", "array2_v2"]

# What we give you:

[
  {"header1" => "array1_v1", "header2" => "array1_v2" }
  {"header1" => "array2_v1", "header2" => "array2_v2" }
]

This means that to work with the Export API you need do nothing more special than you already do because we handle all the hard work, if you can call it hard work considering it required very little extra code.

API Payloads

Feralchimp.new.list_members(:id => list_id)
Feralchimp.list_members(:id => list_id)
Feralchimp.new(:api_key => api_key).list_members(:id => list_id)

Feralchimp accepts a hash based payload. This payload is not tracked by us and all we do is transform it and post it so if you would like to know more about what payloads you might need to send to Mailchimp please visit the Mailchimp API docs.

feralchimp's People

Contributors

conroywhitney avatar casto101 avatar

Watchers

Jason Harrison avatar Auston Bunsen avatar Luke Bergen avatar Sunil Doshi avatar James Cloos avatar  avatar Sea-Anna Thompson avatar

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.