hominid 2.2.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +23 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.rdoc +34 -93
- data/Rakefile +26 -36
- data/VERSION +1 -1
- data/hominid.gemspec +38 -33
- data/lib/hominid.rb +52 -27
- data/lib/hominid/campaign.rb +16 -680
- data/lib/hominid/list.rb +8 -452
- data/lib/hominid/security.rb +10 -34
- data/test/{test_helper.rb → helper.rb} +8 -0
- data/test/test_hominid.rb +29 -0
- metadata +65 -38
- data/.gitignore +0 -5
- data/lib/hominid/base.rb +0 -122
- data/lib/hominid/helper.rb +0 -129
- data/test/hominid_test.rb +0 -12
data/lib/hominid/campaign.rb
CHANGED
@@ -1,698 +1,34 @@
|
|
1
1
|
module Hominid
|
2
2
|
module Campaign
|
3
|
-
|
4
|
-
# Get all the campaigns for this account.
|
5
|
-
#
|
6
|
-
# Parameters:
|
7
|
-
# * filters (Hash) = A hash of filters to apply to query. See the Mailchimp API documentation for more info.
|
8
|
-
# * start (Integer) = Control paging of results.
|
9
|
-
# * limit (Integer) = Number of campaigns to return. Upper limit set at 1000.
|
10
|
-
#
|
11
|
-
# Returns:
|
12
|
-
# An array of campaigns.
|
13
|
-
#
|
14
|
-
def campaigns(filters = {}, start = 0, limit = 25)
|
15
|
-
call("campaigns", filters, start, limit)
|
16
|
-
end
|
17
|
-
|
3
|
+
|
18
4
|
# Find a campaign by id
|
19
|
-
#
|
20
|
-
# Parameters:
|
21
|
-
# * campaign_id (String) = The unique ID of the campaign to return.
|
22
|
-
#
|
23
|
-
# Returns:
|
24
|
-
# A single campaign.
|
25
|
-
#
|
26
5
|
def find_campaign_by_id(campaign_id)
|
27
|
-
|
6
|
+
campaigns({:campaign_id => campaign_id})['data']
|
28
7
|
end
|
29
|
-
|
8
|
+
|
30
9
|
# Find a campaign by web_id
|
31
|
-
#
|
32
|
-
# Parameters:
|
33
|
-
# * campaign_web_id (Integer) = The unique ID of the campaign to return.
|
34
|
-
#
|
35
|
-
# Returns:
|
36
|
-
# A single campaign.
|
37
|
-
#
|
38
10
|
def find_campaign_by_web_id(campaign_web_id)
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
# Find a campaign by name
|
43
|
-
#
|
44
|
-
# Parameters:
|
45
|
-
# * title (String) = The title of the campaign to return.
|
46
|
-
#
|
47
|
-
# Returns:
|
48
|
-
# An array of campaigns.
|
49
|
-
#
|
50
|
-
def find_campaigns_by_title(title)
|
51
|
-
call("campaigns", {:title => title})
|
52
|
-
end
|
53
|
-
|
54
|
-
# Find campaigns by list name
|
55
|
-
#
|
56
|
-
# Parameters:
|
57
|
-
# * list_name (String) = The name of the mailing list to return campaigns for.
|
58
|
-
# * start (Integer) = Control paging of results.
|
59
|
-
# * limit (Integer) = Number of campaigns to return. Upper limit set at 1000.
|
60
|
-
#
|
61
|
-
# Returns:
|
62
|
-
# An array of campaigns.
|
63
|
-
#
|
64
|
-
def find_campaigns_by_list_name(list_name, start = 0, limit = 25)
|
65
|
-
call("campaigns", {:list_id => find_list_id_by_name(list_name)}, start, limit)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Find campaigns by list id
|
69
|
-
#
|
70
|
-
# Parameters:
|
71
|
-
# * list_id (String) = The ID of the mailing list to return campaigns for.
|
72
|
-
# * start (Integer) = Control paging of results.
|
73
|
-
# * limit (Integer) = Number of campaigns to return. Upper limit set at 1000.
|
74
|
-
#
|
75
|
-
# Returns:
|
76
|
-
# An array of campaigns.
|
77
|
-
#
|
78
|
-
def find_campaigns_by_list_id(list_id, start = 0, limit = 25)
|
79
|
-
call("campaigns", {:list_id => list_id}, start, limit)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Find campaigns by type
|
83
|
-
#
|
84
|
-
# Parameters:
|
85
|
-
# * type (String) = One of: 'regular', 'plaintext', 'absplit', 'rss', 'inspection', 'trans', 'auto'
|
86
|
-
# * start (Integer) = Control paging of results.
|
87
|
-
# * limit (Integer) = Number of campaigns to return. Upper limit set at 1000.
|
88
|
-
#
|
89
|
-
# Returns:
|
90
|
-
# An array of campaigns.
|
91
|
-
#
|
92
|
-
def find_campaigns_by_type(type, start = 0, limit = 25)
|
93
|
-
call("campaigns", {:type => type}, start, limit)
|
94
|
-
end
|
95
|
-
|
96
|
-
# Create a new draft campaign to send.
|
97
|
-
#
|
98
|
-
# Parameters:
|
99
|
-
# * options (Hash) = A hash of options for creating this campaign including:
|
100
|
-
# * :list_id = (String) The ID of the list to send this campaign to.
|
101
|
-
# * :subject = (String) The subject of the campaign.
|
102
|
-
# * :from_email = (String) The email address this campaign will come from.
|
103
|
-
# * :from_name = (String) The name that this campaign will come from.
|
104
|
-
# * :to_email = (String) The To: name recipients will see.
|
105
|
-
# * :template_id = (Integer) The ID of the template to use for this campaign (optional).
|
106
|
-
# * :folder_id = (Integer) The ID of the folder to file this campaign in (optional).
|
107
|
-
# * :tracking = (Array) What to track for this campaign (optional).
|
108
|
-
# * :title = (String) Internal title for this campaign (optional).
|
109
|
-
# * :authenticate = (Boolean) Set to true to authenticate campaign (optional).
|
110
|
-
# * :analytics = (Array) Google analytics tags (optional).
|
111
|
-
# * :auto_footer = (Boolean) Auto-generate the footer (optional)?
|
112
|
-
# * :inline_css = (Boolean) Inline the CSS styles (optional)?
|
113
|
-
# * :generate_text = (Boolean) Auto-generate text from HTML email (optional)?
|
114
|
-
# * content (Hash) = The content for this campaign - use a struct with the following keys:
|
115
|
-
# * :html (String) = The HTML content of the campaign.
|
116
|
-
# * :text (String) = The text content of the campaign.
|
117
|
-
# * :url (String) = A URL to pull content from. This will override other content settings.
|
118
|
-
# * :archive (String) = To send a Base64 encoded archive file for Mailchimp to import all media from.
|
119
|
-
# * :archive_type (String) = Only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz. Defaults to zip. (optional)
|
120
|
-
# * segment_options (Hash) = Segmentation options. See the Mailchimp API documentation for more information.
|
121
|
-
# * type (String) = One of "regular", "plaintext", "absplit", "rss", "trans" or "auto".
|
122
|
-
# * type_opts (Hash) = An array of options for this campaign type. See the Mailchimp API documentation for for more information.
|
123
|
-
#
|
124
|
-
# Returns:
|
125
|
-
# The ID for the created campaign. (String)
|
126
|
-
#
|
127
|
-
def create_campaign(options = {}, content = {}, campaign_type = 'regular', segment_options = {}, type_opts = {})
|
128
|
-
call("campaignCreate", campaign_type, options, content, segment_options, type_opts)
|
129
|
-
# TODO: Should we return the new campaign instead of the ID returned from the API?
|
130
|
-
end
|
131
|
-
|
132
|
-
# List all the folders for a user account.
|
133
|
-
#
|
134
|
-
# Returns:
|
135
|
-
# An array of folders (or [] if none exist) for this account including:
|
136
|
-
# * folder_id (Integer) = Folder Id for the given folder, this can be used in the campaigns() function to filter on.
|
137
|
-
# * name (String) = Name of the given folder.
|
138
|
-
#
|
139
|
-
def folders
|
140
|
-
folders = call("campaignFolders")
|
141
|
-
folders == "" ? [] : folders
|
142
|
-
end
|
143
|
-
|
144
|
-
# Retrieve all templates defined for your user account.
|
145
|
-
#
|
146
|
-
# Returns:
|
147
|
-
# An array of templates for this campaign including:
|
148
|
-
# * id (Integer) = The ID of the template.
|
149
|
-
# * name (String) = The name of the template.
|
150
|
-
# * layout (String) = The layout of the template - "basic", "left_column", "right_column", or "postcard".
|
151
|
-
# * sections (Array) = An associative array of editable sections in the template that can accept custom HTML when sending a campaign.
|
152
|
-
#
|
153
|
-
def templates
|
154
|
-
call("campaignTemplates")
|
155
|
-
end
|
156
|
-
|
157
|
-
# Get all email addresses that complained about a given campaign.
|
158
|
-
#
|
159
|
-
# Parameters:
|
160
|
-
# * campaign_id (String) = The ID of the campaign.
|
161
|
-
# * start (Integer) = Page number to start at. Defaults to 0.
|
162
|
-
# * limit (Integer) = Number of results to return. Defaults to 500. Upper limit is 1000.
|
163
|
-
# * since (DateTime) = Only return email reports since this date. Must be in YYYY-MM-DD HH:II:SS format (GMT).
|
164
|
-
#
|
165
|
-
# Returns:
|
166
|
-
# An array of abuse reports for this list in the format:
|
167
|
-
#
|
168
|
-
def abuse_reports(campaign_id, start = 0, limit = 500, since = "2000-01-01 00:00:00")
|
169
|
-
call("campaignAbuseReports", campaign_id, start, limit, since)
|
170
|
-
end
|
171
|
-
alias :campaign_abuse_reports :abuse_reports
|
172
|
-
|
173
|
-
# Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
|
174
|
-
# suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary.
|
175
|
-
#
|
176
|
-
# Parameters:
|
177
|
-
# * campaign_id (String) = The ID of the campaign.
|
178
|
-
#
|
179
|
-
# Returns:
|
180
|
-
# An array of advice on the campaign's performance including:
|
181
|
-
# * msg (String) = Advice message.
|
182
|
-
# * type (String) = One of: negative, positive, or neutral.
|
183
|
-
#
|
184
|
-
def advice(campaign_id)
|
185
|
-
call("campaignAdvice", campaign_id)
|
186
|
-
end
|
187
|
-
alias :campaign_advice :advice
|
188
|
-
|
189
|
-
# Attach Ecommerce Order Information to a Campaign.
|
190
|
-
#
|
191
|
-
# Parameters:
|
192
|
-
# * campaign_id (String) = The ID of the campaign.
|
193
|
-
# * order (Hash) = A hash of order information including:
|
194
|
-
# * id (String) = The order id
|
195
|
-
# * email_id (String) = Email id of the subscriber (mc_eid query string)
|
196
|
-
# * total (Double) = Show only campaigns with this from_name.
|
197
|
-
# * shipping (String) = The total paid for shipping fees. (optional)
|
198
|
-
# * tax (String) = The total tax paid. (optional)
|
199
|
-
# * store_id (String) = A unique id for the store sending the order in
|
200
|
-
# * store_name (String) = A readable name for the store, typicaly the hostname. (optional)
|
201
|
-
# * plugin_id (String) = The MailChimp-assigned Plugin Id. Using 1214 for the moment.
|
202
|
-
# * items (Array) = The individual line items for an order, using the following keys:
|
203
|
-
# * line_num (Integer) = The line number of the item on the order. (optional)
|
204
|
-
# * product_id (Integer) = Internal product id.
|
205
|
-
# * product_name (String) = The name for the product_id associated with the item.
|
206
|
-
# * category_id (Integer) = Internal id for the (main) category associated with product.
|
207
|
-
# * category_name (String) = The category name for the category id.
|
208
|
-
# * qty (Double) = The quantity of items ordered.
|
209
|
-
# * cost (Double) = The cost of a single item (Ex. Not the extended cost of the line).
|
210
|
-
#
|
211
|
-
# Returns:
|
212
|
-
# True if successful, error code if not.
|
213
|
-
#
|
214
|
-
def add_order(campaign_id, order)
|
215
|
-
order = order.merge(:campaign_id => campaign_id)
|
216
|
-
call("campaignEcommAddOrder", order)
|
217
|
-
end
|
218
|
-
alias :campaign_ecomm_add_order :add_order
|
219
|
-
|
220
|
-
# Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google
|
221
|
-
# Analytics Add-on to be installed and configured.
|
222
|
-
#
|
223
|
-
# Parameters:
|
224
|
-
# * campaign_id (String) = The ID of the campaign.
|
225
|
-
#
|
226
|
-
# Returns:
|
227
|
-
# An array of analytics for the passed campaign including:
|
228
|
-
# * visits (Integer) = Number of visits.
|
229
|
-
# * pages (Integer) = Number of page views.
|
230
|
-
# * new_visits (Integer) = New visits recorded.
|
231
|
-
# * bounces (Integer) = Vistors who "bounced" from your site.
|
232
|
-
# * time_on_site (Double) =
|
233
|
-
# * goal_conversions (Integer) = Number of goals converted.
|
234
|
-
# * goal_value (Double) = Value of conversion in dollars.
|
235
|
-
# * revenue (Double) = Revenue generated by campaign.
|
236
|
-
# * transactions (Integer) = Number of transactions tracked.
|
237
|
-
# * ecomm_conversions (Integer) = Number Ecommerce transactions tracked.
|
238
|
-
# * goals (Array) = An array containing goal names and number of conversions.
|
239
|
-
#
|
240
|
-
def analytics(campaign_id)
|
241
|
-
call("campaignAnalytics", campaign_id)
|
242
|
-
end
|
243
|
-
|
244
|
-
# Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
|
245
|
-
# of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
|
246
|
-
# messages over 30 days old are subject to being removed.
|
247
|
-
#
|
248
|
-
# Parameters:
|
249
|
-
# * campaign_id (String) = The ID of the campaign.
|
250
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
251
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 50.
|
252
|
-
# * since (Date) = Pull only messages since this time - use YYYY-MM-DD format in GMT.
|
253
|
-
#
|
254
|
-
# Returns:
|
255
|
-
# An array of full bounce messages for this campaign including:
|
256
|
-
# * date (String) = Date/time the bounce was received and processed.
|
257
|
-
# * email (String) = The email address that bounced.
|
258
|
-
# * message (String) = The entire bounce message received.
|
259
|
-
#
|
260
|
-
def bounce_messages(campaign_id, start = 0, limit = 25, since = "2000-01-01")
|
261
|
-
call("campaignBounceMessages", campaign_id, start, limit, since)
|
262
|
-
end
|
263
|
-
|
264
|
-
# Return the list of email addresses that clicked on a given url, and how many times they clicked.
|
265
|
-
# Note: Requires the AIM module to be installed.
|
266
|
-
#
|
267
|
-
# Parameters:
|
268
|
-
# * campaign_id (String) = The ID of the campaign.
|
269
|
-
# * url (String) = The URL of the link that was clicked on.
|
270
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
271
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
272
|
-
#
|
273
|
-
# Returns:
|
274
|
-
# An array of structs containing email addresses and click counts including:
|
275
|
-
# * email (String) = Email address that opened the campaign.
|
276
|
-
# * clicks (Integer) = Total number of times the URL was clicked on by this email address.
|
277
|
-
#
|
278
|
-
def click_details(campaign_id, url, start = 0, limit = 1000)
|
279
|
-
call("campaignClickDetailAIM", campaign_id, url, start, limit)
|
280
|
-
end
|
281
|
-
alias :click_detail_aim :click_details
|
282
|
-
|
283
|
-
# Get an array of the urls being tracked, and their click counts for a given campaign.
|
284
|
-
#
|
285
|
-
# Parameters:
|
286
|
-
# * campaign_id (String) = The ID of the campaign.
|
287
|
-
#
|
288
|
-
# Returns:
|
289
|
-
# A struct of URLs and associated statistics including:
|
290
|
-
# * clicks (Integer) = Number of times the specific link was clicked.
|
291
|
-
# * unique (Integer) = Number of unique people who clicked on the specific link.
|
292
|
-
#
|
293
|
-
def click_stats(campaign_id)
|
294
|
-
call("campaignClickStats", campaign_id)
|
295
|
-
end
|
296
|
-
|
297
|
-
# Get the content (both html and text) for a campaign either as it would appear in the campaign archive
|
298
|
-
# or as the raw, original content.
|
299
|
-
#
|
300
|
-
# Parameters:
|
301
|
-
# * campaign_id (String) = The ID of the campaign.
|
302
|
-
# * for_archive (Boolean) = Controls whether we return the Archive version (true) or the Raw version (false), defaults to true.
|
303
|
-
#
|
304
|
-
# Returns:
|
305
|
-
# A struct containing all content for the campaign including:
|
306
|
-
# * html (String) = The HTML content used for the campgain with merge tags intact.
|
307
|
-
# * text (String) = The Text content used for the campgain with merge tags intact.
|
308
|
-
#
|
309
|
-
def content(campaign_id, for_archive = true)
|
310
|
-
call("campaignContent", campaign_id, for_archive)
|
311
|
-
end
|
312
|
-
alias :campaign_content :content
|
313
|
-
|
314
|
-
# Delete a campaign.
|
315
|
-
#
|
316
|
-
# Parameters:
|
317
|
-
# * campaign_id (String) = The ID of the campaign.
|
318
|
-
#
|
319
|
-
# Returns:
|
320
|
-
# True if successful, error code if not.
|
321
|
-
#
|
322
|
-
def delete(campaign_id)
|
323
|
-
call("campaignDelete", campaign_id)
|
324
|
-
end
|
325
|
-
alias :delete_campaign :delete
|
326
|
-
|
327
|
-
# Retrieve the tracked eepurl mentions on Twitter
|
328
|
-
#
|
329
|
-
# Parameters:
|
330
|
-
# * campaign_id (String) = The ID of the campaign.
|
331
|
-
#
|
332
|
-
# Returns:
|
333
|
-
# An array of containing tweets and retweets that include this campaign's eepurl
|
334
|
-
def eep_url_stats(campaign_id)
|
335
|
-
call("campaignEepUrlStats", campaign_id)
|
336
|
-
end
|
337
|
-
alias :campaign_eep_url_stats :eep_url_stats
|
338
|
-
|
339
|
-
# Get the top 5 performing email domains for this campaign.
|
340
|
-
#
|
341
|
-
# Parameters:
|
342
|
-
# * campaign_id (String) = The ID of the campaign.
|
343
|
-
#
|
344
|
-
# Returns:
|
345
|
-
# An array of email domains and their associated stats including:
|
346
|
-
# * domain (String) = Domain name or special "Other" to roll-up stats past 5 domains.
|
347
|
-
# * total_sent (Integer) = Total Email across all domains - this will be the same in every row.
|
348
|
-
# * emails (Integer) = Number of emails sent to this domain.
|
349
|
-
# * bounces (Integer) = Number of bounces.
|
350
|
-
# * opens (Integer) = Number of opens.
|
351
|
-
# * clicks (Integer) = Number of clicks.
|
352
|
-
# * unsubs (Integer) = Number of unsubscribes.
|
353
|
-
# * delivered (Integer) = Number of deliveries.
|
354
|
-
# * emails_pct (Integer) = Percentage of emails that went to this domain (whole number).
|
355
|
-
# * bounces_pct (Integer) = Percentage of bounces from this domain (whole number).
|
356
|
-
# * opens_pct (Integer) = Percentage of opens from this domain (whole number).
|
357
|
-
# * clicks_pct (Integer) = Percentage of clicks from this domain (whole number).
|
358
|
-
# * unsubs_pct (Integer) = Percentage of unsubs from this domain (whole number).
|
359
|
-
#
|
360
|
-
def email_domain_performance(campaign_id)
|
361
|
-
call("campaignEmailDomainPerformance", campaign_id)
|
11
|
+
campaigns['data'].find {|c| c["web_id"] == campaign_web_id}
|
362
12
|
end
|
363
|
-
alias :email_performance :email_domain_performance
|
364
13
|
|
365
|
-
#
|
366
|
-
|
367
|
-
|
368
|
-
# Parameters:
|
369
|
-
# * campaign_id (String) = The ID of the campaign.
|
370
|
-
# * email (String) = The email address to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns.
|
371
|
-
#
|
372
|
-
# Returns:
|
373
|
-
# An array of structs containing the actions including:
|
374
|
-
# * action (String) = The action taken (open or click).
|
375
|
-
# * timestamp (DateTime) = Time the action occurred.
|
376
|
-
# * url (String) = For clicks, the URL that was clicked.
|
377
|
-
#
|
378
|
-
def email_stats(campaign_id, email)
|
379
|
-
call("campaignEmailStatsAIM", campaign_id, email)
|
380
|
-
end
|
381
|
-
alias :email_stats_aim :email_stats
|
382
|
-
|
383
|
-
# Given a campaign and correct paging limits, return the entire click and open history with timestamps, ordered by time,
|
384
|
-
# for every user a campaign was delivered to.
|
385
|
-
# Note: Requires the AIM module to be installed.
|
386
|
-
#
|
387
|
-
# Parameters:
|
388
|
-
# * campaign_id (String) = The ID of the campaign.
|
389
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
390
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 1000.
|
391
|
-
#
|
392
|
-
# Returns:
|
393
|
-
# An array of structs containing actions (opens and clicks) for each email, with timestamps including:
|
394
|
-
# * action (String) = The action taken (open or click).
|
395
|
-
# * timestamp (DateTime) = Time the action occurred.
|
396
|
-
# * url (String) = For clicks, the URL that was clicked.
|
397
|
-
#
|
398
|
-
def email_stats_all(campaign_id, start = 0, limit = 100)
|
399
|
-
call("campaignEmailStatsAIMAll", campaign_id, start, limit)
|
400
|
-
end
|
401
|
-
alias :email_stats_aim_all :email_stats_all
|
402
|
-
|
403
|
-
# Retrieve the countries and number of opens tracked for each.
|
404
|
-
#
|
405
|
-
# Parameters:
|
406
|
-
# * campaign_id (String) = The ID of the campaign.
|
407
|
-
#
|
408
|
-
# Returns:
|
409
|
-
# An array of countries where the campaign was opened:
|
410
|
-
# * code (String) = The ISO3166 2 digit country code.
|
411
|
-
# * name (String) = The country name (if available).
|
412
|
-
# * opens (Integer) = The total number of opens that occurred in the country.
|
413
|
-
# * region_detail (Boolean) = Whether or not a subsequent call to campaignGeoOpensByCountry() will return anything
|
414
|
-
#
|
415
|
-
def geo_opens(campaign_id)
|
416
|
-
call("campaignGeoOpens", campaign_id)
|
417
|
-
end
|
418
|
-
alias :campaign_geo_opens :geo_opens
|
419
|
-
|
420
|
-
# Retrieve the regions and number of opens tracked for a certain country. Email address are not returned.
|
421
|
-
#
|
422
|
-
# Parameters:
|
423
|
-
# * campaign_id (String) = The ID of the campaign.
|
424
|
-
# * code (String) = An ISO3166 2 digit country code.
|
425
|
-
#
|
426
|
-
# Returns:
|
427
|
-
# An array of regions within the provided country where opens occurred:
|
428
|
-
# * code (String) = An internal code for the region. (can be blank)
|
429
|
-
# * name (String) = The name of the region (if available).
|
430
|
-
# * opens (Integer) = The total number of opens that occurred in that region.
|
431
|
-
#
|
432
|
-
def geo_opens_for_country(campaign_id, code)
|
433
|
-
call("campaignGeoOpensForCountry", campaign_id, code)
|
434
|
-
end
|
435
|
-
alias :campaign_geo_opens_for_country :geo_opens_for_country
|
436
|
-
|
437
|
-
# Get all email addresses with Hard Bounces for a given campaign.
|
438
|
-
#
|
439
|
-
# Parameters:
|
440
|
-
# * campaign_id (String) = The ID of the campaign.
|
441
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
442
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
443
|
-
#
|
444
|
-
# Returns:
|
445
|
-
# An array of email addresses with Hard Bounces.
|
446
|
-
#
|
447
|
-
def hard_bounces(campaign_id, start = 0, limit = 1000)
|
448
|
-
call("campaignHardBounces", campaign_id, start, limit)
|
449
|
-
end
|
450
|
-
|
451
|
-
# Retrieve the list of email addresses that did not open a given campaign.
|
452
|
-
# Note: Requires the AIM module to be installed.
|
453
|
-
#
|
454
|
-
# Parameters:
|
455
|
-
# * campaign_id (String) = The ID of the campaign.
|
456
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
457
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
458
|
-
#
|
459
|
-
# Returns:
|
460
|
-
# A list of email addresses that did not open a campaign.
|
461
|
-
#
|
462
|
-
def not_opened(campaign_id, start = 0, limit = 1000)
|
463
|
-
call("campaignNotOpenedAIM", campaign_id, start, limit)
|
464
|
-
end
|
465
|
-
alias :not_opened_aim :not_opened
|
466
|
-
|
467
|
-
# Retrieve the list of email addresses that opened a given campaign with how many times they opened.
|
468
|
-
# Note: this AIM function is free and does not actually require the AIM module to be installed.
|
469
|
-
#
|
470
|
-
# Parameters:
|
471
|
-
# * campaign_id (String) = The ID of the campaign.
|
472
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
473
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
474
|
-
#
|
475
|
-
# Returns:
|
476
|
-
# An array of structs containing email addresses and open counts including:
|
477
|
-
# * email (String) = Email address that opened the campaign.
|
478
|
-
# * open_count (Integer) = Total number of times the campaign was opened by this email address.
|
479
|
-
#
|
480
|
-
def opened(campaign_id, start = 0, limit = 1000)
|
481
|
-
call("campaignOpenedAIM", campaign_id, start, limit)
|
482
|
-
end
|
483
|
-
alias :opened_aim :opened
|
484
|
-
|
485
|
-
# Retrieve the Ecommerce Orders.
|
486
|
-
#
|
487
|
-
# Parameters:
|
488
|
-
# * campaign_id (String) = The ID of the campaign.
|
489
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
490
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 500.
|
491
|
-
# * since (DateTime) = Pull only messages since this time - use YYYY-MM-DD HH:II:SS format in GMT.
|
492
|
-
#
|
493
|
-
# Returns:
|
494
|
-
# An array of orders and their details for this campaign, including:
|
495
|
-
# * store_id (String) = The store id generated by the plugin used to uniquely identify a store.
|
496
|
-
# * store_name (String) = The store name collected by the plugin - often the domain name.
|
497
|
-
# * order_id (Integer) = The internal order id the store tracked this order by.
|
498
|
-
# * email (String) = The email address that received this campaign and is associated with this order.
|
499
|
-
# * order_total (Double) = The order total.
|
500
|
-
# * tax_total (Double) = The total tax for the order (if collected).
|
501
|
-
# * ship_total (Double) = The shipping total for the order (if collected).
|
502
|
-
# * order_date (String) = The date the order was tracked - from the store if possible, otherwise the GMT time received.
|
503
|
-
# * lines (Array) = Containing details of the order - product, category, quantity, item cost.
|
504
|
-
#
|
505
|
-
def orders(campaign_id, start = 0, limit = 100, since = "2001-01-01 00:00:00")
|
506
|
-
call("campaignEcommOrders", campaign_id, start, limit, since)
|
507
|
-
end
|
508
|
-
alias :ecomm_orders :orders
|
509
|
-
|
510
|
-
# Pause an AutoResponder orRSS campaign from sending.
|
511
|
-
#
|
512
|
-
# Parameters:
|
513
|
-
# * campaign_id (String) = The ID of the campaign.
|
514
|
-
#
|
515
|
-
# Returns:
|
516
|
-
# True if successful.
|
517
|
-
def pause(campaign_id)
|
518
|
-
call("campaignPause", campaign_id)
|
519
|
-
end
|
520
|
-
|
521
|
-
# Replicate a campaign.
|
522
|
-
#
|
523
|
-
# Parameters:
|
524
|
-
# * campaign_id (String) = The ID of the campaign.
|
525
|
-
#
|
526
|
-
# Returns:
|
527
|
-
# The ID of the newly created replicated campaign. (String)
|
528
|
-
#
|
529
|
-
def replicate(campaign_id)
|
530
|
-
call("campaignReplicate", campaign_id)
|
531
|
-
end
|
532
|
-
alias :replicate_campaign :replicate
|
533
|
-
|
534
|
-
# Resume sending an AutoResponder or RSS campaign.
|
535
|
-
#
|
536
|
-
# Parameters:
|
537
|
-
# * campaign_id (String) = The ID of the campaign.
|
538
|
-
#
|
539
|
-
# Returns:
|
540
|
-
# True if successful.
|
541
|
-
#
|
542
|
-
def resume(campaign_id)
|
543
|
-
call("campaignResume", campaign_id)
|
544
|
-
end
|
545
|
-
|
546
|
-
# Schedule a campaign to be sent in the future.
|
547
|
-
#
|
548
|
-
# Parameters:
|
549
|
-
# * campaign_id (String) = The ID of the campaign.
|
550
|
-
# * time (DateTime) = The time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in GMT.
|
551
|
-
# * time_b (DateTime) = The time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in GMT. (optional)
|
552
|
-
#
|
553
|
-
# Returns:
|
554
|
-
# True if successful.
|
555
|
-
#
|
556
|
-
def schedule(campaign_id, time = "#{1.day.from_now}", time_b = "")
|
557
|
-
call("campaignSchedule", campaign_id, time, time_b)
|
558
|
-
end
|
559
|
-
alias :schedule_campaign :schedule
|
560
|
-
|
561
|
-
# Send this campaign immediately.
|
562
|
-
#
|
563
|
-
# Parameters:
|
564
|
-
# * campaign_id (String) = The ID of the campaign to send.
|
565
|
-
#
|
566
|
-
# Returns:
|
567
|
-
# True if successful.
|
568
|
-
def send_now(campaign_id)
|
569
|
-
call("campaignSendNow", campaign_id)
|
570
|
-
end
|
571
|
-
|
572
|
-
# Send a test of this campaign to the provided email address(es).
|
573
|
-
#
|
574
|
-
# Parameters:
|
575
|
-
# * campaign_id (String) = The ID of the campaign.
|
576
|
-
# * emails (Array) = An array of email addresses to receive the test message.
|
577
|
-
# * send_type (String) = One of 'html', 'text' or '' (send both). Defaults to ''.
|
578
|
-
#
|
579
|
-
# Returns:
|
580
|
-
# True if successful.
|
581
|
-
#
|
582
|
-
def send_test(campaign_id, emails = {}, send_type = nil)
|
583
|
-
if send_type
|
584
|
-
call("campaignSendTest", campaign_id, emails, send_type)
|
585
|
-
else
|
586
|
-
call("campaignSendTest", campaign_id, emails)
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
# Get the URL to a customized VIP Report for the specified campaign and optionally send an email
|
591
|
-
# to someone with links to it. Note subsequent calls will overwrite anything already set for the
|
592
|
-
# same campign (eg, the password).
|
593
|
-
#
|
594
|
-
# Parameters:
|
595
|
-
# * campaign_id (String) = The ID of the campaign.
|
596
|
-
# * options (Hash) = A hash of parameters which can be used to configure the shared report, including: (optional)
|
597
|
-
# * header_type (String) = One of "text" or "image". Defaults to 'text'. (optional)
|
598
|
-
# * header_data (String) = If "header_type" is text, the text to display. If "header_type" is "image" a valid URL to an image file. Note that images will be resized to be no more than 500x150. Defaults to the Accounts Company Name. (optional)
|
599
|
-
# * secure (Boolean) = Whether to require a password for the shared report. Defaults to "true". (optional)
|
600
|
-
# * password (String) = If secure is true and a password is not included, we will generate one. It is always returned. (optional)
|
601
|
-
# * to_email (String) = Email address to share the report with - no value means an email will not be sent. (optional)
|
602
|
-
# * theme (Array) = An array containing either 3 or 6 character color code values for: "bg_color", "header_color", "current_tab", "current_tab_text", "normal_tab", "normal_tab_text", "hover_tab", "hover_tab_text". (optional)
|
603
|
-
# * css_url (String) = A link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) only if loaded via the "secure_url" - max 255 characters. (optional)
|
604
|
-
#
|
605
|
-
# Returns:
|
606
|
-
# A struct containing details for the shared report including:
|
607
|
-
# * title (String) = The Title of the Campaign being shared.
|
608
|
-
# * url (String) = The URL to the shared report.
|
609
|
-
# * secure_url (String) = The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned.
|
610
|
-
# * password (String) = If secured, the password for the report, otherwise this field will not be returned.
|
611
|
-
#
|
612
|
-
def share_report(campaign_id, options = {})
|
613
|
-
call("campaignShareReport", campaign_id, options)
|
614
|
-
end
|
615
|
-
|
616
|
-
# Get all email addresses with Soft Bounces for a given campaign.
|
617
|
-
#
|
618
|
-
# Parameters:
|
619
|
-
# * campaign_id (String) = The ID of the campaign.
|
620
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
621
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
622
|
-
#
|
623
|
-
# Returns:
|
624
|
-
# An array of email addresses with Soft Bounces.
|
625
|
-
#
|
626
|
-
def soft_bounces(campaign_id, start = 0, limit = 1000)
|
627
|
-
call("campaignSoftBounces", campaign_id, start, limit)
|
628
|
-
end
|
629
|
-
|
630
|
-
# Get all the relevant campaign statistics for this campaign.
|
631
|
-
#
|
632
|
-
# Parameters:
|
633
|
-
# * campaign_id (String) = The ID of the campaign.
|
634
|
-
#
|
635
|
-
# Returns:
|
636
|
-
# An array of statistics for this campaign including:
|
637
|
-
# * syntax_error (Integer) = Number of email addresses in campaign that had syntactical errors.
|
638
|
-
# * hard_bounces (Integer) = Number of email addresses in campaign that hard bounced.
|
639
|
-
# * soft_bounces (Integer) = Number of email addresses in campaign that soft bounced.
|
640
|
-
# * unsubscribes (Integer) = Number of email addresses in campaign that unsubscribed.
|
641
|
-
# * abuse_reports (Integer) = Number of email addresses in campaign that reported campaign for abuse.
|
642
|
-
# * forwards (Integer) = Number of times email was forwarded to a friend.
|
643
|
-
# * forwards_opens (Integer) = Number of times a forwarded email was opened.
|
644
|
-
# * opens (Integer) = Number of times the campaign was opened.
|
645
|
-
# * last_open (Date) = Date of the last time the email was opened.
|
646
|
-
# * unique_opens (Integer) = Number of people who opened the campaign.
|
647
|
-
# * clicks (Integer) = Number of times a link in the campaign was clicked.
|
648
|
-
# * unique_clicks (Integer) = Number of unique recipient/click pairs for the campaign.
|
649
|
-
# * last_click (Date) = Date of the last time a link in the email was clicked.
|
650
|
-
# * users_who_clicked (Integer) = Number of unique recipients who clicked on a link in the campaign.
|
651
|
-
# * emails_sent (Integer) = Number of email addresses campaign was sent to.
|
652
|
-
#
|
653
|
-
def stats(campaign_id)
|
654
|
-
call("campaignStats", campaign_id)
|
14
|
+
# Find a campaign by name
|
15
|
+
def find_campaigns_by_title(campaign_title)
|
16
|
+
campaigns({:title => campaign_title})['data']
|
655
17
|
end
|
656
|
-
alias :campaign_stats :stats
|
657
18
|
|
658
|
-
#
|
659
|
-
|
660
|
-
|
661
|
-
# * campaign_id (String) = The ID of the campaign.
|
662
|
-
# * name (String) = The parameter name.
|
663
|
-
# * value (Variable) = An appropriate value for the parameter.
|
664
|
-
#
|
665
|
-
# Returns:
|
666
|
-
# True if successful, error code if not.
|
667
|
-
#
|
668
|
-
def update(campaign_id, name, value)
|
669
|
-
call("campaignUpdate", campaign_id, name, value)
|
19
|
+
# Find campaigns by list name
|
20
|
+
def find_campaigns_by_list_name(list_name, *args)
|
21
|
+
campaigns({:list_id => find_list_id_by_name(list_name)}, *args)['data']
|
670
22
|
end
|
671
23
|
|
672
|
-
#
|
673
|
-
|
674
|
-
|
675
|
-
# * campaign_id (String) = The ID of the campaign.
|
676
|
-
#
|
677
|
-
# Returns:
|
678
|
-
# True if successful.
|
679
|
-
#
|
680
|
-
def unschedule(campaign_id)
|
681
|
-
call("campaignUnschedule", campaign_id)
|
24
|
+
# Find campaigns by list id
|
25
|
+
def find_campaigns_by_list_id(list_id, *args)
|
26
|
+
campaigns({:list_id => list_id}, *args)['data']
|
682
27
|
end
|
683
28
|
|
684
|
-
#
|
685
|
-
|
686
|
-
|
687
|
-
# * campaign_id (String) = The ID of the campaign.
|
688
|
-
# * start (Integer) = For large data sets, the page number to start at.
|
689
|
-
# * limit (Integer) = For large data sets, the number of results to return. Upper limit set at 15000.
|
690
|
-
#
|
691
|
-
# Returns:
|
692
|
-
# An array of email addresses that unsubscribed from this campaign.
|
693
|
-
#
|
694
|
-
def unsubscribes(campaign_id, start = 0, limit = 1000)
|
695
|
-
call("campaignUnsubscribes", campaign_id, start, limit)
|
29
|
+
# Find campaigns by type
|
30
|
+
def find_campaigns_by_type(campaign_type, *args)
|
31
|
+
campaigns({:type => campaign_type}, *args)['data']
|
696
32
|
end
|
697
33
|
|
698
34
|
end
|