Sha256: 33ecdfd708cda2271230c4bc1563abb16fa90ba4291e40c4457ca86981d80119

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

module MonkeyParty
  class Base
    include HTTParty
    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
        MonkeyParty.api_key
      end

      def default_options
        {
          :base_uri => "http://#{MonkeyParty.data_center}.api.mailchimp.com/1.2"
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
monkey_party-0.3.2 lib/monkey_party/base.rb
monkey_party-0.3.1 lib/monkey_party/base.rb
monkey_party-0.3.0 lib/monkey_party/base.rb