Class: CampaignMonitorParty

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

Constant Summary collapse

ENDPOINT =
'http://api.createsend.com/api/api.asmx/'

Instance Method Summary collapse

Constructor Details

#initialize(api_key, endpoint = ENDPOINT) ⇒ CampaignMonitorParty

Returns a new instance of CampaignMonitorParty.



10
11
12
13
# File 'lib/campaign_monitor_party.rb', line 10

def initialize(api_key, endpoint=ENDPOINT)
  @api_key = api_key
  @endpoint = endpoint
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, args = {}, test = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/campaign_monitor_party.rb', line 15

def method_missing(method_name, args={}, test=nil)
  if @endpoint !~ /\/$/
    self.class.post(@endpoint + '.' + method_name.to_s, :body => args.merge('ApiKey' => @api_key))
  else
    self.class.new(@api_key, @endpoint + method_name.to_s)
  end
end