Sha256: cddb1bdbac34a7cfcfa467bfc62884935488f325cd3954296f62c84ffa72b879

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

require "ruby-debug"
module MonkeyParty
  class Base
    include HTTParty
    base_uri 'http://api.mailchimp.com/1.1/'
    default_params :output => "xml"

    def initialize(attrs = {})
      attrs.each{ |key, value| self.send("#{key}=", value) }
    end

    class << self
      def get(path, options = {})
        #fix the format because Mail Chimp doesn't pass the proper header
        options[:format] = :xml
        result = super
        
        if result.body =~ /<error /i
          raise MonkeyParty::Error.parse(result.body)
        end
        result
      end

      def api_key
        configatron.mailchimp.api_key
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dpickett-monkey_party-0.0.1 lib/monkey_party/base.rb