Class: MonkeyParty::Base

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/monkey_party/base.rb

Direct Known Subclasses

List

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/monkey_party/base.rb', line 6

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

Class Method Details

.api_keyObject



22
23
24
# File 'lib/monkey_party/base.rb', line 22

def api_key
  MonkeyParty.api_key
end

.default_optionsObject



26
27
28
29
30
# File 'lib/monkey_party/base.rb', line 26

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

.get(path, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/monkey_party/base.rb', line 11

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