Class: CampaignMonitor::Client
- Inherits:
-
Object
- Object
- CampaignMonitor::Client
- Defined in:
- lib/campaign_monitor.rb
Overview
Provides access to the lists and campaigns associated with a client
Instance Attribute Summary collapse
-
#cm_client ⇒ Object
readonly
Returns the value of attribute cm_client.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#campaigns ⇒ Object
Example @client = new Client(12345) @campaigns = @client.campaigns.
-
#initialize(id, name = nil) ⇒ Client
constructor
Example @client = new Client(12345).
-
#lists ⇒ Object
Example @client = new Client(12345) @lists = @client.lists.
Constructor Details
#initialize(id, name = nil) ⇒ Client
Example
@client = new Client(12345)
170 171 172 173 174 |
# File 'lib/campaign_monitor.rb', line 170 def initialize(id, name=nil) @id = id @name = name @cm_client = CampaignMonitor.new end |
Instance Attribute Details
#cm_client ⇒ Object (readonly)
Returns the value of attribute cm_client.
166 167 168 |
# File 'lib/campaign_monitor.rb', line 166 def cm_client @cm_client end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
166 167 168 |
# File 'lib/campaign_monitor.rb', line 166 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
166 167 168 |
# File 'lib/campaign_monitor.rb', line 166 def name @name end |
Instance Method Details
#campaigns ⇒ Object
Example
@client = new Client(12345)
@campaigns = @client.campaigns
for campaign in @campaigns
puts campaign.subject
end
199 200 201 202 203 204 205 206 |
# File 'lib/campaign_monitor.rb', line 199 def campaigns response = @cm_client.Client_GetCampaigns("ClientID" => @id) unless response["Code"].to_i != 0 response["Campaign"].collect{|c| Campaign.new(c["CampaignID"].to_i, c["Subject"], c["SentDate"], c["TotalRecipients"].to_i)} else raise response["Code"] + " - " + response["Message"] end end |
#lists ⇒ Object
Example
@client = new Client(12345)
@lists = @client.lists
for list in @lists
puts list.name
end
183 184 185 186 187 188 189 190 |
# File 'lib/campaign_monitor.rb', line 183 def lists response = @cm_client.Client_GetLists("ClientID" => @id) unless response["Code"].to_i != 0 response["List"].collect{|l| List.new(l["ListID"].to_i, l["Name"])} else raise response["Code"] + " - " + response["Message"] end end |