Class: MaleChimp::Base
- Inherits:
-
Object
- Object
- MaleChimp::Base
- Defined in:
- lib/malechimp.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(api_key, url = API::URL) ⇒ Base
constructor
Try to grab the API key out of env and use the default end-point URL.
-
#list(name) ⇒ Object
Find a list by name.
-
#lists ⇒ Object
Returns all of the mailing lists in Chimp.
-
#server ⇒ Object
Zie oh so wunderful API shinannigans.
Constructor Details
#initialize(api_key, url = API::URL) ⇒ Base
Try to grab the API key out of env and use the default end-point URL
19 20 21 |
# File 'lib/malechimp.rb', line 19 def initialize(api_key, url=API::URL) @api_key, @url = api_key, url end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
16 17 18 |
# File 'lib/malechimp.rb', line 16 def api_key @api_key end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
16 17 18 |
# File 'lib/malechimp.rb', line 16 def url @url end |
Instance Method Details
#list(name) ⇒ Object
Find a list by name.
32 33 34 |
# File 'lib/malechimp.rb', line 32 def list(name) lists.find{ |l| l.name == name } end |
#lists ⇒ Object
Returns all of the mailing lists in Chimp.
24 25 26 27 28 29 |
# File 'lib/malechimp.rb', line 24 def lists # In MailChimps infinite wisdom, they implemented REST inside of RPC, so you see stupid stuff like the .data root key. @lists ||= call('lists')['data'].map do |list| List.new(self, list) end end |
#server ⇒ Object
Zie oh so wunderful API shinannigans
37 38 39 |
# File 'lib/malechimp.rb', line 37 def server @server ||= XMLRPC::Client.new2(url) end |