mc 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -5
- data/lib/mc.rb +0 -1
- data/lib/mc/commands/campaigns.rb +171 -37
- data/lib/mc/commands/export.rb +16 -17
- data/lib/mc/commands/lists-group.rb +10 -11
- data/lib/mc/commands/lists-webhook.rb +7 -5
- data/lib/mc/commands/lists.rb +2 -2
- data/lib/mc/commands/reports.rb +90 -21
- data/lib/mc/commands/search.rb +23 -2
- data/lib/mc/commands/users.rb +1 -1
- data/lib/mc/commands/vip.rb +2 -2
- data/lib/mc/helper.rb +3 -2
- data/lib/mc/version.rb +1 -1
- data/lib/mc/writer.rb +35 -11
- data/test/run_all.rb +61 -0
- data/test/run_all.sh +137 -0
- metadata +6 -3
- data/lib/mc/report.rb +0 -140
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8f8d203b64e7fc4bb9d8eef9046c9b19e9523f
|
4
|
+
data.tar.gz: e166b76e2f1035134a0ec8f252632fa7e519048e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f513d06962d7249b7ed24f1e678f9d8224cabafbf1f4eb31468121543a54dd8b464d87c4aa645e2258b97e3863443f8030d2c1f54ebacf9046c1cb805ff2772f
|
7
|
+
data.tar.gz: 02e4247298512e1e77ced931fbf42db8cc8bd15ba73af87bca7fc487a54d4c89c75d1c0c52e4c639310bbd3a43660758f2c58b6e9803870579c211d2153fe3a3
|
data/README.md
CHANGED
@@ -40,17 +40,17 @@ You should see something similar to:
|
|
40
40
|
COMMANDS
|
41
41
|
campaigns - Campaign related tasks
|
42
42
|
ecomm - Ecomm related actions
|
43
|
-
export - Export
|
43
|
+
export - Export list, ecomm, or activity streams (no caching)
|
44
44
|
gallery - Manage images and documents that are in your account
|
45
45
|
help - Shows a list of commands or help for one command
|
46
46
|
helper - Basic admin funtions
|
47
47
|
initconfig - Initialize the config file using current global options
|
48
48
|
lists - View information about lists and subscribers
|
49
|
-
reports -
|
49
|
+
reports - View various campaign level reporting
|
50
50
|
search - Search campaigns and members
|
51
51
|
templates - Manage templates within your account
|
52
|
-
users -
|
53
|
-
|
52
|
+
users - Manage and invite MailChimp user accounts
|
53
|
+
vips - Check activity and add/remove/list members
|
54
54
|
|
55
55
|
|
56
56
|
You can get details on specific subcommands by:
|
@@ -62,6 +62,9 @@ You can get details on specific subcommands by:
|
|
62
62
|
## With Great Power
|
63
63
|
With this tool you'll be able to access your account in ways that will bypass confirmations and limits that you'll find within the regular MailChimp web application. So for example, you can unsubscribe users and send campaigns without any conformation using the correct command and parameters. Caching, as mentioned above, is setup to avoid hitting your account too much, but care still needs to be taken. Lastly, before using this tool it is highly recommended that you read the [MailChimp API faq](http://apidocs.mailchimp.com/api/faq/) and especially note the 'best practices' listed within it.
|
64
64
|
|
65
|
+
## Want Updates?
|
66
|
+
|
67
|
+
Of course this repo has to have an associated MailChimp list (only used to update you on new version releases): http://eepurl.com/K8Vcj
|
65
68
|
|
66
69
|
## Config File
|
67
70
|
To create a config file at ~/.mailchimp you can run:
|
@@ -71,7 +74,7 @@ To create a config file at ~/.mailchimp you can run:
|
|
71
74
|
You can then edit that file and include any defaults you want to set. I would highly recommend at a minimal including the api key and a default list:
|
72
75
|
|
73
76
|
:apikey: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-usx
|
74
|
-
:
|
77
|
+
:list: xxxxxxxxxx
|
75
78
|
|
76
79
|
> Note: once you get your api key you can get the list id by running 'mc list lists'.
|
77
80
|
|
data/lib/mc.rb
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
desc 'Campaign related tasks'
|
2
2
|
command :campaigns do |c|
|
3
|
+
c.desc 'Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content'
|
4
|
+
c.command :content do |s|
|
5
|
+
s.desc 'Select view type - [archive], preview, or raw'
|
6
|
+
s.flag :view
|
7
|
+
|
8
|
+
s.desc 'Select the format - [html, text]'
|
9
|
+
s.flag :output
|
10
|
+
s.action do |global,options,args|
|
11
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
12
|
+
view = required_option(:view, options[:view], "archive")
|
13
|
+
email = ""
|
14
|
+
|
15
|
+
results = @mailchimp_cached.campaigns_content(:cid => cid, :options => {:view => view, :email => email})
|
16
|
+
|
17
|
+
if options[:output] == 'html'
|
18
|
+
puts results['html']
|
19
|
+
elsif options[:output] == 'text'
|
20
|
+
puts results['text']
|
21
|
+
else
|
22
|
+
@output.as_hash results
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
3
26
|
|
4
27
|
c.desc 'Create Campaign'
|
5
28
|
c.command :create do |s|
|
@@ -122,85 +145,126 @@ command :campaigns do |c|
|
|
122
145
|
end
|
123
146
|
end
|
124
147
|
|
125
|
-
c.desc '
|
126
|
-
c.command :
|
148
|
+
c.desc 'Delete Campaign'
|
149
|
+
c.command :delete do |s|
|
127
150
|
s.desc 'Campaign ID'
|
128
151
|
s.flag :cid
|
129
152
|
|
130
153
|
s.action do |global,options,args|
|
131
154
|
cid = required_argument("Need to supply a campaign id", options[:cid])
|
132
|
-
print "
|
133
|
-
@mailchimp.
|
155
|
+
print "Deleting campaign #{cid}... "
|
156
|
+
@mailchimp.campaigns_send_test(:cid=> cid)["complete"] ? puts("done!") : puts("ut oh, no can do!")
|
134
157
|
end
|
135
158
|
end
|
136
159
|
|
137
|
-
c.desc '
|
138
|
-
c.command :
|
160
|
+
c.desc 'Get the list of campaigns and their details matching the specified filters'
|
161
|
+
c.command :list do |s|
|
162
|
+
s.desc 'List ID'
|
163
|
+
s.flag :list
|
164
|
+
s.desc "Return campaigns of a specific status - 'sent', 'saved', 'paused', 'schedule', 'sending'"
|
165
|
+
s.flag :status
|
166
|
+
s.desc "Return campaigns of a specific type - 'regular', 'plaintext', 'absplit', 'rss', 'auto'"
|
167
|
+
s.flag :type
|
168
|
+
s.desc 'Number of campaigns to display'
|
169
|
+
s.flag :limit, :default_value => 50
|
170
|
+
|
171
|
+
# s.switch :first
|
172
|
+
# s.flag :start, :default_value => 0
|
173
|
+
# s.flag :sort_field, :default_value => 'create_time'
|
174
|
+
# s.flag :sort_dir, :default_value => 'DESC'
|
175
|
+
|
176
|
+
s.action do |global,options,args|
|
177
|
+
#by design not including global[:list], although that goes against norm. however,
|
178
|
+
#seems to not fit well with this command and not possible to negate it
|
179
|
+
results = @mailchimp_cached.campaigns_list(:limit => options[:limit], :filters => {:list_id => options[:list], :status => options[:status], :type => options[:type]})
|
180
|
+
@output.standard results['data'], :fields => [:id, :title, :status, :send_time, :emails_sent, :archive_url]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
c.desc 'Check to see if campaign is ready to send'
|
185
|
+
c.command :ready do |s|
|
139
186
|
s.desc 'Campaign ID'
|
140
187
|
s.flag :cid
|
141
188
|
|
142
|
-
s.desc '
|
143
|
-
s.
|
144
|
-
|
145
|
-
s.desc 'Time to schedule campaign at in HH:MM:SS format'
|
146
|
-
s.flag :time, :default_value => '08:00:00'
|
189
|
+
s.desc 'Use last created campaign id'
|
190
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
147
191
|
|
148
192
|
s.action do |global,options,args|
|
149
|
-
cid =
|
150
|
-
puts
|
193
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
194
|
+
puts cid
|
195
|
+
|
196
|
+
@output.standard @mailchimp_cached.campaigns_ready(:cid=> cid)
|
151
197
|
end
|
152
198
|
end
|
153
199
|
|
154
|
-
c.desc '
|
155
|
-
c.command
|
200
|
+
c.desc 'Replicate a campaign.'
|
201
|
+
c.command :replicate do |s|
|
156
202
|
s.desc 'Campaign ID'
|
157
203
|
s.flag :cid
|
158
204
|
|
159
205
|
s.action do |global,options,args|
|
160
|
-
cid = required_argument("Need to supply a campaign id",
|
161
|
-
emails = required_argument("Need to supply at least one email to send test campaign to.", args)
|
206
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
162
207
|
|
163
|
-
|
164
|
-
@mailchimp.campaigns_send_test(:cid=> cid, :test_emails => emails)["complete"] ? puts("done!") : puts("ut oh, no can do!")
|
208
|
+
@output.as_hash @mailchimp_cached.campaigns_replicate(:cid=> cid)
|
165
209
|
end
|
166
210
|
end
|
167
211
|
|
168
|
-
c.desc '
|
169
|
-
c.command :
|
212
|
+
c.desc 'Resume sending an AutoResponder or RSS campaign'
|
213
|
+
c.command :resume do |s|
|
170
214
|
s.desc 'Campaign ID'
|
171
215
|
s.flag :cid
|
172
216
|
|
173
217
|
s.action do |global,options,args|
|
174
|
-
cid = required_argument("Need to supply a campaign id",
|
175
|
-
|
176
|
-
@
|
218
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
219
|
+
|
220
|
+
@output.as_raw @mailchimp_cached.campaigns_resume(:cid=> cid)
|
177
221
|
end
|
178
222
|
end
|
179
223
|
|
180
|
-
c.desc '
|
181
|
-
c.command
|
182
|
-
s.
|
183
|
-
s.flag :
|
184
|
-
|
185
|
-
s.
|
186
|
-
s.flag :
|
224
|
+
c.desc 'Schedule a campaign to be sent in batches sometime in the future'
|
225
|
+
c.command 'schedule-batch' do |s|
|
226
|
+
s.desc 'Campaign ID'
|
227
|
+
s.flag :cid
|
228
|
+
|
229
|
+
s.desc 'Date to schedule campaign in YYYY-MM-DD format'
|
230
|
+
s.flag :date
|
231
|
+
|
232
|
+
s.desc 'Time to schedule campaign at in HH:MM:SS format'
|
233
|
+
s.flag :time
|
234
|
+
|
235
|
+
s.desc 'Number of batches to send (2 - 26)'
|
236
|
+
s.flag :batches, :default_value => 2
|
237
|
+
|
238
|
+
s.desc 'Number of minutes between each batch (5, 10, 15, 20, 25, 30, 60)'
|
239
|
+
s.flag :stagger, :default_value => 5
|
240
|
+
|
187
241
|
s.action do |global,options,args|
|
188
|
-
|
242
|
+
cid = required_argument("Need to supply a campaign id", options[:cid])
|
243
|
+
date = required_option(:date, options[:date])
|
244
|
+
time = required_option(:time, options[:time])
|
245
|
+
|
246
|
+
puts @mailchimp.campaigns_schedule(:cid => cid, :schedule_time => date + ' ' + time, :num_batches => options[:batches], :stagger_mins => options[:stagger])
|
189
247
|
end
|
190
248
|
end
|
191
249
|
|
192
|
-
c.desc '
|
193
|
-
c.command :
|
250
|
+
c.desc 'Schedule Campaign'
|
251
|
+
c.command :schedule do |s|
|
194
252
|
s.desc 'Campaign ID'
|
195
253
|
s.flag :cid
|
196
254
|
|
197
|
-
s.
|
198
|
-
|
255
|
+
s.desc 'Date to schedule campaign in YYYY-MM-DD format'
|
256
|
+
s.flag :date, :default_value => (Time.now + 86400).strftime("%Y-%m-%d")
|
199
257
|
|
200
|
-
|
258
|
+
s.desc 'Time to schedule campaign at in HH:MM:SS format'
|
259
|
+
s.flag :time, :default_value => '08:00:00'
|
260
|
+
|
261
|
+
s.action do |global,options,args|
|
262
|
+
cid = required_argument("Need to supply a campaign id", options[:cid])
|
263
|
+
puts @mailchimp.campaigns_schedule(:cid => cid, :schedule_time => options[:date] + ' ' + options[:time])
|
201
264
|
end
|
202
265
|
end
|
203
266
|
|
267
|
+
c.desc 'Allows one to test their segmentation rules before creating a campaign using them'
|
204
268
|
c.command "segment-test" do |s|
|
205
269
|
s.desc 'List ID'
|
206
270
|
s.flag :id
|
@@ -224,4 +288,74 @@ command :campaigns do |c|
|
|
224
288
|
puts @mailchimp.campaigns_segment_test(:list_id => id, :options => segment)
|
225
289
|
end
|
226
290
|
end
|
291
|
+
|
292
|
+
c.desc 'Send Campaign Now'
|
293
|
+
c.command :send do |s|
|
294
|
+
s.desc 'Campaign ID'
|
295
|
+
s.flag :cid
|
296
|
+
|
297
|
+
s.action do |global,options,args|
|
298
|
+
cid = required_argument("Need to supply a campaign id", options[:cid])
|
299
|
+
print "Sending campaign #{cid}... "
|
300
|
+
@mailchimp.campaigns_send(:cid => cid)["complete"] ? puts("done!") : puts("ut oh, no can do!")
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
c.desc 'Send Test Campaign'
|
305
|
+
c.command 'send-test' do |s|
|
306
|
+
s.desc 'Campaign ID'
|
307
|
+
s.flag :cid
|
308
|
+
|
309
|
+
s.action do |global,options,args|
|
310
|
+
cid = required_argument("Need to supply a campaign id", options[:cid])
|
311
|
+
emails = required_argument("Need to supply at least one email to send test campaign to.", args)
|
312
|
+
|
313
|
+
print "Sending test for campaign #{cid}... "
|
314
|
+
@mailchimp.campaigns_send_test(:cid=> cid, :test_emails => emails)["complete"] ? puts("done!") : puts("ut oh, no can do!")
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
c.desc 'Unschedule a campaign that is scheduled to be sent in the future'
|
319
|
+
c.command :unschedule do |s|
|
320
|
+
s.desc 'Campaign ID'
|
321
|
+
s.flag :cid
|
322
|
+
|
323
|
+
s.action do |global,options,args|
|
324
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
325
|
+
|
326
|
+
@output.as_raw @mailchimp_cached.campaigns_unschedule(:cid=> cid)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
c.desc 'Get the HTML template content sections for a campaign'
|
331
|
+
c.command 'template-content' do |s|
|
332
|
+
s.desc 'Campaign ID'
|
333
|
+
s.flag :cid
|
334
|
+
|
335
|
+
s.action do |global,options,args|
|
336
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
337
|
+
|
338
|
+
@output.as_hash @mailchimp_cached.campaigns_template_content(:cid=> cid)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
c.desc 'Update just about any setting besides type for a campaign that has not been sent'
|
343
|
+
c.command :update do |s|
|
344
|
+
s.desc 'Campaign ID'
|
345
|
+
s.flag :cid
|
346
|
+
|
347
|
+
s.desc 'Parameter name to change'
|
348
|
+
s.flag :name
|
349
|
+
|
350
|
+
s.desc 'Value to set parameter to'
|
351
|
+
s.flag :value
|
352
|
+
|
353
|
+
s.action do |global,options,args|
|
354
|
+
cid = required_argument("Need to supply a campaign id", args.first)
|
355
|
+
name = required_option(:name, options[:name])
|
356
|
+
value = required_option(:value, options[:value])
|
357
|
+
|
358
|
+
@output.as_hash @mailchimp.campaigns_update(:cid=> cid, :name => name, :value => value)
|
359
|
+
end
|
360
|
+
end
|
227
361
|
end
|
data/lib/mc/commands/export.rb
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
desc 'Export'
|
1
|
+
desc 'Export list, ecomm, or activity streams (no caching)'
|
2
|
+
long_desc 'Uses the Export API and will stream results. These commands do not do any caching, and thus you should be careful about running these multiple times. A typical way to use this command would be to redirect output to a file. Example: mc export activity --cid 1234567 > campaign_activity.txt'
|
2
3
|
command :export do |c|
|
3
4
|
# list ( string apikey, string id, string status array segment, string since )
|
4
5
|
c.desc 'Exports/dumps members of a list and all of their associated details.'
|
5
6
|
c.command :list do |s|
|
6
|
-
|
7
|
-
c.flag :id
|
7
|
+
s.flag :status
|
8
8
|
|
9
|
-
|
9
|
+
s.desc "Use either 'any' or 'all'"
|
10
|
+
s.flag :match, :default_value => 'all'
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
c.desc 'Condition in the format field,op,value'
|
15
|
-
c.flag :condition
|
12
|
+
s.desc 'Condition in the format field,op,value'
|
13
|
+
s.flag :condition
|
16
14
|
|
17
15
|
s.action do |global,options,args|
|
18
|
-
id =
|
16
|
+
id = required_argument(:id, args.first, global[:list])
|
19
17
|
|
20
18
|
if options[:condition]
|
21
19
|
segment = {}
|
@@ -35,8 +33,8 @@ command :export do |c|
|
|
35
33
|
# ecommOrders ( string since )
|
36
34
|
c.desc 'Dumps all Ecommerce Orders for an account'
|
37
35
|
c.command :ecommm do |s|
|
38
|
-
|
39
|
-
|
36
|
+
s.desc 'Ecomm orders since a specific date'
|
37
|
+
s.flag :since
|
40
38
|
|
41
39
|
s.action do |global,options,args|
|
42
40
|
@mailchimp.export_ecomm_orders.each do |order|
|
@@ -46,15 +44,16 @@ command :export do |c|
|
|
46
44
|
end
|
47
45
|
|
48
46
|
# campaignSubscriberActivity ( string apikey, string id, boolean include_empty, string since )
|
47
|
+
c.desc 'Dumps all Subscriber Activity for the requested campaign'
|
49
48
|
c.command :activity do |s|
|
50
|
-
|
51
|
-
|
49
|
+
s.desc 'Export all subscribers even if they have no activity'
|
50
|
+
s.switch :include_empty, :negatable => false
|
52
51
|
|
53
|
-
|
54
|
-
|
52
|
+
s.desc 'Use last created campaign id'
|
53
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
55
54
|
|
56
55
|
s.action do |global,options,args|
|
57
|
-
cid = options[:
|
56
|
+
cid = required_argument("Missing or invalid campaign id", args.first, get_last_campaign_id(options[:lcid]))
|
58
57
|
|
59
58
|
@mailchimp.export_campaign_subscriber_activity(:id => cid).each do |activity|
|
60
59
|
puts activity
|
@@ -1,3 +1,4 @@
|
|
1
|
+
desc 'View information about lists and subscribers'
|
1
2
|
command :lists do |lists|
|
2
3
|
lists.desc 'Manage groups'
|
3
4
|
lists.command :group do |c|
|
@@ -26,7 +27,7 @@ command :lists do |lists|
|
|
26
27
|
s.action do |global,options,args|
|
27
28
|
id = required_argument(:id, options[:id], global[:list])
|
28
29
|
group_name = required_argument("Need to provide a group name.", args).first
|
29
|
-
@output.standard @mailchimp.
|
30
|
+
@output.standard @mailchimp.lists_interest_group_del(:id => id, :group_name => group_name, :grouping_id => options['grouping-id'])
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -41,7 +42,9 @@ command :lists do |lists|
|
|
41
42
|
|
42
43
|
s.action do |global,options,args|
|
43
44
|
id = required_argument(:id, options[:id], global[:list])
|
44
|
-
|
45
|
+
old = required_option(:old, options[:old])
|
46
|
+
new = required_option(:new, options[:new])
|
47
|
+
@output.standard @mailchimp.lists_interest_group_update(:id => id, :old_name => old, :new_name => new, :grouping_id => options['grouping-id'])
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -57,20 +60,16 @@ command :lists do |lists|
|
|
57
60
|
|
58
61
|
s.action do |global,options,args|
|
59
62
|
id = required_argument(:id, options[:id], global[:list])
|
60
|
-
@output.standard @
|
63
|
+
@output.standard @mailchimp.lists_interest_grouping_add(:id => id, :name => options[:name], :type => options[:type])
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
64
67
|
# lists/interest-grouping-del (string apikey, int grouping_id)
|
65
68
|
c.desc 'Delete an existing Interest Grouping'
|
66
69
|
c.command :delete do |s|
|
67
|
-
s.desc 'list id'
|
68
|
-
s.flag :id
|
69
|
-
|
70
70
|
s.action do |global,options,args|
|
71
|
-
|
72
|
-
|
73
|
-
@output.standard @mailchimp_cached.lists_
|
71
|
+
grouping_id = required_argument("Must provide the grouping id", args.first)
|
72
|
+
@output.standard @mailchimp.lists_interest_grouping_del(:grouping_id => grouping_id)
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
@@ -83,7 +82,7 @@ command :lists do |lists|
|
|
83
82
|
|
84
83
|
s.action do |global,options,args|
|
85
84
|
id = required_argument(:id, options[:id], global[:list])
|
86
|
-
@output.standard @
|
85
|
+
@output.standard @mailchimp.lists_interest_grouping_update(:grouping_id => options[:grouping_id], :name => options[:name], :value => options[:value])
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
@@ -96,7 +95,7 @@ command :lists do |lists|
|
|
96
95
|
|
97
96
|
s.action do |global,options,args|
|
98
97
|
id = required_argument(:id, options[:id], global[:list])
|
99
|
-
@output.
|
98
|
+
@output.as_hash @mailchimp_cached.lists_interest_groupings(:id => id, :counts => options[:counts])
|
100
99
|
end
|
101
100
|
end
|
102
101
|
|
@@ -8,9 +8,10 @@ command :lists do |lists|
|
|
8
8
|
s.flag :id
|
9
9
|
|
10
10
|
s.action do |global,options,args|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
id = required_option(:id, options[:id], global[:list])
|
12
|
+
url = required_argument("Need a url", args.first)
|
13
|
+
|
14
|
+
@output.standard @mailchimp.lists_webhook_add(:id => id, :url => url)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
@@ -21,9 +22,10 @@ command :lists do |lists|
|
|
21
22
|
s.flag :id
|
22
23
|
|
23
24
|
s.action do |global,options,args|
|
24
|
-
s.flag :url
|
25
25
|
id = required_argument(:id, options[:id], global[:list])
|
26
|
-
|
26
|
+
url = required_argument("Need a url", args.first)
|
27
|
+
|
28
|
+
@output.standard @mailchimp.lists_webhook_del(:id => id, :url => url)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
data/lib/mc/commands/lists.rb
CHANGED
@@ -7,7 +7,7 @@ command :lists do |c|
|
|
7
7
|
|
8
8
|
s.action do |global,options,args|
|
9
9
|
id = required_argument(:id, options[:id], global[:list])
|
10
|
-
@output.standard @mailchimp_cached.
|
10
|
+
@output.standard @mailchimp_cached.lists_abuse_reports(:id => id)['data']
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -143,7 +143,7 @@ command :lists do |c|
|
|
143
143
|
|
144
144
|
id = required_argument(:id, options[:id], global[:list])
|
145
145
|
emails = create_email_struct(required_argument("Need to provide one or more email addresses.", args))
|
146
|
-
@output.as_hash @mailchimp.lists_subscribe(:id => id, :email => emails.first
|
146
|
+
@output.as_hash @mailchimp.lists_subscribe(:id => id, :email => emails.first)
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
data/lib/mc/commands/reports.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
desc '
|
1
|
+
desc 'View various campaign level reporting'
|
2
2
|
command :reports do |c|
|
3
3
|
# reports/abuse (string apikey, string cid, struct opts)
|
4
4
|
c.desc 'Get all email addresses that complained about a given campaign'
|
@@ -6,8 +6,12 @@ command :reports do |c|
|
|
6
6
|
s.arg_name 'campaign id'
|
7
7
|
s.flag :cid
|
8
8
|
|
9
|
+
s.desc 'Use last created campaign id'
|
10
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
11
|
+
|
9
12
|
s.action do |global,options,args|
|
10
|
-
cid = options[:cid]
|
13
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
14
|
+
|
11
15
|
member_column = lambda{|l| "#{l['member']['email']}"}
|
12
16
|
@output.standard @mailchimp_cached.reports_abuse(:cid => cid)['data'], :fields => [:member => {:display_method => member_column}]
|
13
17
|
end
|
@@ -19,8 +23,12 @@ command :reports do |c|
|
|
19
23
|
s.arg_name 'campaign id'
|
20
24
|
s.flag :cid
|
21
25
|
|
26
|
+
s.desc 'Use last created campaign id'
|
27
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
28
|
+
|
22
29
|
s.action do |global,options,args|
|
23
|
-
cid = options[:cid]
|
30
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
31
|
+
|
24
32
|
@output.as_hash @mailchimp_cached.reports_advice :cid => cid
|
25
33
|
end
|
26
34
|
end
|
@@ -31,8 +39,12 @@ command :reports do |c|
|
|
31
39
|
s.arg_name 'campaign id'
|
32
40
|
s.flag :cid
|
33
41
|
|
42
|
+
s.desc 'Use last created campaign id'
|
43
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
44
|
+
|
34
45
|
s.action do |global,options,args|
|
35
|
-
cid = options[:cid]
|
46
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
47
|
+
|
36
48
|
email = create_email_struct(required_argument("Need to provide an email address.", args))
|
37
49
|
puts @mailchimp_cached.reports_bounce_message(:cid => cid, :email => email.first)['message']
|
38
50
|
end
|
@@ -44,8 +56,11 @@ command :reports do |c|
|
|
44
56
|
s.arg_name 'campaign id'
|
45
57
|
s.flag :cid
|
46
58
|
|
59
|
+
s.desc 'Use last created campaign id'
|
60
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
61
|
+
|
47
62
|
s.action do |global,options,args|
|
48
|
-
cid = options[:cid]
|
63
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
49
64
|
|
50
65
|
results = @mailchimp_cached.reports_bounce_messages(:cid => cid)
|
51
66
|
if global[:output]
|
@@ -74,10 +89,14 @@ command :reports do |c|
|
|
74
89
|
s.flag :cid
|
75
90
|
s.flag :tid
|
76
91
|
|
92
|
+
s.desc 'Use last created campaign id'
|
93
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
94
|
+
|
77
95
|
s.action do |global,options,args|
|
78
|
-
cid = options[:cid]
|
96
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
79
97
|
tid = options[:tid]
|
80
98
|
member_column = lambda{|l| "#{l['member']['email']}"}
|
99
|
+
|
81
100
|
@output.standard @mailchimp_cached.reports_click_detail(:cid => cid, :tid => tid)['data'], :fields => [:clicks, {:member => {:display_method => member_column}}]
|
82
101
|
end
|
83
102
|
end
|
@@ -88,8 +107,12 @@ command :reports do |c|
|
|
88
107
|
s.arg_name 'campaign id'
|
89
108
|
s.flag :cid
|
90
109
|
|
110
|
+
s.desc 'Use last created campaign id'
|
111
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
112
|
+
|
91
113
|
s.action do |global,options,args|
|
92
|
-
cid = options[:cid]
|
114
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
115
|
+
|
93
116
|
@output.standard @mailchimp_cached.reports_clicks(:cid => cid)['total'], :fields => [:tid, {:url => {:width => 80}}, :clicks, :unique]
|
94
117
|
end
|
95
118
|
end
|
@@ -100,8 +123,12 @@ command :reports do |c|
|
|
100
123
|
s.arg_name 'campaign id'
|
101
124
|
s.flag :cid
|
102
125
|
|
126
|
+
s.desc 'Use last created campaign id'
|
127
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
128
|
+
|
103
129
|
s.action do |global,options,args|
|
104
|
-
cid = options[:cid]
|
130
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
131
|
+
|
105
132
|
@output.standard @mailchimp_cached.reports_domain_performance :cid => cid
|
106
133
|
end
|
107
134
|
end
|
@@ -112,8 +139,12 @@ command :reports do |c|
|
|
112
139
|
s.arg_name 'campaign id'
|
113
140
|
s.flag :cid
|
114
141
|
|
142
|
+
s.desc 'Use last created campaign id'
|
143
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
144
|
+
|
115
145
|
s.action do |global,options,args|
|
116
|
-
cid = options[:cid]
|
146
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
147
|
+
|
117
148
|
@output.standard @mailchimp_cached.reports_ecomm_orders(:cid => cid)['data']
|
118
149
|
end
|
119
150
|
end
|
@@ -124,8 +155,12 @@ command :reports do |c|
|
|
124
155
|
s.arg_name 'campaign id'
|
125
156
|
s.flag :cid
|
126
157
|
|
158
|
+
s.desc 'Use last created campaign id'
|
159
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
160
|
+
|
127
161
|
s.action do |global,options,args|
|
128
|
-
cid = options[:cid]
|
162
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
163
|
+
|
129
164
|
@output.as_hash @mailchimp_cached.reports_eepurl(:cid => cid)
|
130
165
|
end
|
131
166
|
end
|
@@ -136,8 +171,12 @@ command :reports do |c|
|
|
136
171
|
s.arg_name 'campaign id'
|
137
172
|
s.flag :cid
|
138
173
|
|
174
|
+
s.desc 'Use last created campaign id'
|
175
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
176
|
+
|
139
177
|
s.action do |global,options,args|
|
140
|
-
cid = options[:cid]
|
178
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
179
|
+
|
141
180
|
@output.standard @mailchimp_cached.reports_geo_opens(:cid => cid), :fields => [:code, :name, :opens]
|
142
181
|
end
|
143
182
|
end
|
@@ -148,8 +187,12 @@ command :reports do |c|
|
|
148
187
|
s.arg_name 'campaign id'
|
149
188
|
s.flag :cid
|
150
189
|
|
190
|
+
s.desc 'Use last created campaign id'
|
191
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
192
|
+
|
151
193
|
s.action do |global,options,args|
|
152
|
-
cid = options[:cid]
|
194
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
195
|
+
|
153
196
|
@output.standard @mailchimp_cached.reports_google_analytics :cid => cid
|
154
197
|
end
|
155
198
|
end
|
@@ -160,9 +203,13 @@ command :reports do |c|
|
|
160
203
|
s.arg_name 'campaign id'
|
161
204
|
s.flag :cid
|
162
205
|
|
206
|
+
s.desc 'Use last created campaign id'
|
207
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
208
|
+
|
163
209
|
s.action do |global,options,args|
|
164
|
-
cid = options[:cid]
|
210
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
165
211
|
email = create_email_struct(required_argument("Need to provide an email address.", args))
|
212
|
+
|
166
213
|
results = @mailchimp_cached.reports_member_activity(:cid => cid, :emails => email)['data']
|
167
214
|
|
168
215
|
results.each do |result|
|
@@ -182,9 +229,13 @@ command :reports do |c|
|
|
182
229
|
s.flag :start, :default_value => 0
|
183
230
|
s.flag :limit, :default_value => 50
|
184
231
|
|
232
|
+
s.desc 'Use last created campaign id'
|
233
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
234
|
+
|
185
235
|
s.action do |global,options,args|
|
186
|
-
cid = options[:cid]
|
236
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
187
237
|
opts = {:start => options['start'], :limit => options['limit']}
|
238
|
+
|
188
239
|
@output.standard @mailchimp_cached.reports_not_opened(:cid => cid, :opts => opts)['data'], :fields => [:email]
|
189
240
|
end
|
190
241
|
end
|
@@ -199,8 +250,11 @@ command :reports do |c|
|
|
199
250
|
s.flag 'sort-field', :default_value => "opened"
|
200
251
|
s.flag 'sort-dir', :default_value => "asc"
|
201
252
|
|
253
|
+
s.desc 'Use last created campaign id'
|
254
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
255
|
+
|
202
256
|
s.action do |global,options,args|
|
203
|
-
cid = options[:cid]
|
257
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
204
258
|
opts = {:start => options['start'], :limit => options['limit'], :sort_field => options['sort-field'], :sort_dir => options['sort-dir']}
|
205
259
|
member_column = lambda{|l| "#{l['member']['email']}"}
|
206
260
|
|
@@ -217,10 +271,14 @@ command :reports do |c|
|
|
217
271
|
s.flag :start, :default_value => 0
|
218
272
|
s.flag :limit, :default_value => 50
|
219
273
|
|
274
|
+
s.desc 'Use last created campaign id'
|
275
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
276
|
+
|
220
277
|
s.action do |global,options,args|
|
221
|
-
cid = options[:cid]
|
278
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
222
279
|
opts = {:status => options['status'], :start => options['start'], :limit => options['limit']}
|
223
280
|
member_column = lambda{|l| "#{l['member']['email']}"}
|
281
|
+
|
224
282
|
@output.standard @mailchimp_cached.reports_sent_to(:cid => cid, :opts => opts)['data'], :fields => [:member => {:display_method => member_column}]
|
225
283
|
end
|
226
284
|
end
|
@@ -231,8 +289,11 @@ command :reports do |c|
|
|
231
289
|
s.arg_name 'campaign id'
|
232
290
|
s.flag :cid
|
233
291
|
|
292
|
+
s.desc 'Use last created campaign id'
|
293
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
294
|
+
|
234
295
|
s.action do |global,options,args|
|
235
|
-
cid = options[:cid]
|
296
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
236
297
|
|
237
298
|
results = @mailchimp_cached.reports_share(:cid => cid)
|
238
299
|
if global[:output]
|
@@ -253,9 +314,12 @@ command :reports do |c|
|
|
253
314
|
s.desc 'Campaign ID'
|
254
315
|
s.flag :cid
|
255
316
|
|
317
|
+
s.desc 'Use last created campaign id'
|
318
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
319
|
+
|
256
320
|
s.action do |global,options,args|
|
257
|
-
|
258
|
-
|
321
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
322
|
+
|
259
323
|
@output.as_hash @mailchimp_cached.reports_summary(:cid => cid)
|
260
324
|
end
|
261
325
|
end
|
@@ -268,10 +332,15 @@ command :reports do |c|
|
|
268
332
|
s.flag :start, :default_value => 0
|
269
333
|
s.flag :limit, :default_value => 50
|
270
334
|
|
335
|
+
s.desc 'Use last created campaign id'
|
336
|
+
s.switch [:lcid, 'use-last-campaign-id'], :negatable => false
|
337
|
+
|
271
338
|
s.action do |global,options,args|
|
272
|
-
cid = options[:cid]
|
339
|
+
cid = required_option(:cid, options[:cid], get_last_campaign_id(options[:lcid]))
|
273
340
|
opts = {:start => options['start'], :limit => options['limit']}
|
274
|
-
|
341
|
+
|
342
|
+
member_column = lambda{|l| "#{l['member']['email']}"}
|
343
|
+
@output.standard @mailchimp_cached.reports_unsubscribes(:cid => cid, :opts => opts)['data'], :fields => [:reason, :reason_text, :member => {:display_method => member_column}]
|
275
344
|
end
|
276
345
|
end
|
277
346
|
end
|
data/lib/mc/commands/search.rb
CHANGED
@@ -12,10 +12,31 @@ command :search do |c|
|
|
12
12
|
# helper/search-members (string apikey, string query, string id, int offset)
|
13
13
|
c.desc 'Search account wide or on a specific list using the specified query terms'
|
14
14
|
c.command :members do |s|
|
15
|
+
s.desc 'list id'
|
16
|
+
s.flag :id
|
17
|
+
|
18
|
+
s.desc 'Show number of matches only'
|
19
|
+
s.switch 'count-only'
|
20
|
+
|
15
21
|
s.action do |global,options,args|
|
16
22
|
query = required_argument("You need to include a search argument: mc search members <query terms>", args.join(' '))
|
17
|
-
|
23
|
+
id = required_option(:id, options[:id], global[:list])
|
24
|
+
|
25
|
+
results = @mailchimp_cached.helper_search_members(:query => query, :id => id)
|
26
|
+
full_search_members = results['full_search']['members']
|
27
|
+
full_search_count = results['full_search']['total'].to_i
|
28
|
+
exact_search_count = results['exact_matches']['total'].to_i
|
29
|
+
|
30
|
+
if full_search_count > 100
|
31
|
+
(full_search_count / 100).times {|n| full_search_members << @mailchimp_cached.helper_search_members(:query => query, :id => id, :offset => (n+1)*100)['full_search']['members']}
|
32
|
+
end
|
33
|
+
|
34
|
+
if options['count-only']
|
35
|
+
puts "Total exact matches for '#{query}' = #{results['exact_matches']['total']}" if exact_search_count > 0
|
36
|
+
puts "Total matches for '#{query}' = #{full_search_count}" if full_search_count > 0
|
37
|
+
else
|
38
|
+
@output.member_search results['exact_matches']['members'], full_search_members.flatten, global
|
39
|
+
end
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
21
|
-
|
data/lib/mc/commands/users.rb
CHANGED
data/lib/mc/commands/vip.rb
CHANGED
data/lib/mc/helper.rb
CHANGED
@@ -19,8 +19,9 @@ module Helper
|
|
19
19
|
exit_now!(msg)
|
20
20
|
end
|
21
21
|
|
22
|
-
def get_last_campaign_id
|
23
|
-
|
22
|
+
def get_last_campaign_id(really=false)
|
23
|
+
#do we really want to use the last campaign id?
|
24
|
+
really ? @mailchimp_cached.campaigns_list(:limit => 1, :sort_field => "create_time")["data"].first["id"] : nil
|
24
25
|
end
|
25
26
|
|
26
27
|
def create_email_struct(emails)
|
data/lib/mc/version.rb
CHANGED
data/lib/mc/writer.rb
CHANGED
@@ -130,33 +130,57 @@ class ConsoleWriter
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
def member_search(
|
134
|
-
redirect_output?(
|
133
|
+
def member_search(exact, full, options=nil)
|
134
|
+
redirect_output?(full, options)
|
135
135
|
|
136
|
-
if
|
136
|
+
if exact.count == 0 and full.count == 0
|
137
137
|
exit_now!("No matches found.")
|
138
138
|
end
|
139
139
|
|
140
140
|
members = []
|
141
141
|
|
142
|
-
if
|
143
|
-
puts "#{'='*20} Exact Matches (#{
|
142
|
+
if exact.count > 0
|
143
|
+
puts "#{'='*20} Exact Matches (#{exact.count}) #{'='*20}"
|
144
144
|
|
145
|
-
|
145
|
+
exact.each do |member|
|
146
146
|
members << member
|
147
147
|
end
|
148
|
-
|
149
|
-
|
150
|
-
|
148
|
+
|
149
|
+
tp members, :email, :id, :list_name, :member_rating, :status, "VIP?" => {:display_method => :is_gmonkey}
|
150
|
+
elsif full.count > 0
|
151
|
+
max_email = 0
|
152
|
+
max_name = 0
|
153
|
+
|
154
|
+
full.each do |member|
|
151
155
|
members << member
|
156
|
+
max_email = find_max(member['email'].size, max_email)
|
157
|
+
max_name = find_max(member['list_name'].size, max_name)
|
152
158
|
end
|
153
|
-
end
|
154
159
|
|
155
|
-
|
160
|
+
#display the table header
|
161
|
+
header = "#{pad('EMAIL', max_email, 40)} | ID | #{pad('LIST NAME', max_name, 20)} | MEMBER RATING | #{pad('STATUS', 12)} | VIP?"
|
162
|
+
puts "#{'='*(header.size/2 - 7)} Matches (#{full.count}) #{'='*(header.size/2 - 7)}"
|
163
|
+
header += "\n#{'-'*header.size}"
|
164
|
+
puts header
|
165
|
+
|
166
|
+
#display member rows
|
167
|
+
members.each do |m|
|
168
|
+
puts "#{pad(m['email'], max_email, 40)} | #{m['id']} | #{pad(m['list_name'], max_name, 20)} | #{pad(m['member_rating'], 13)} | #{pad(m['status'], 12)} | #{m['is_gmonkey']}"
|
169
|
+
end
|
170
|
+
end
|
156
171
|
end
|
157
172
|
|
158
173
|
private
|
159
174
|
|
175
|
+
def pad(value, padding, max_length=25)
|
176
|
+
value = value.to_s
|
177
|
+
"#{value[0..max_length]}#{' '*(padding - value[0..max_length].size)}"
|
178
|
+
end
|
179
|
+
|
180
|
+
def find_max(a, b)
|
181
|
+
a > b ? a : b
|
182
|
+
end
|
183
|
+
|
160
184
|
def debug(results)
|
161
185
|
puts "#{'*'*50}"
|
162
186
|
puts results
|
data/test/run_all.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/user/bin/env ruby
|
2
|
+
|
3
|
+
RUN_COMMANDS = false
|
4
|
+
EXPORT_CMD = true
|
5
|
+
|
6
|
+
raise "Need to provide a list id" if ARGV.first.nil?
|
7
|
+
|
8
|
+
commands = %w(campaigns ecomm gallery helper lists reports search users vip)
|
9
|
+
|
10
|
+
def get_subcommands(help_text)
|
11
|
+
subcommands = []
|
12
|
+
commands = help_text.scan(/COMMANDS.*/m).first.split("\n")
|
13
|
+
commands.shift #get rid of 'COMMANDS' header
|
14
|
+
|
15
|
+
commands.each do |command|
|
16
|
+
begin
|
17
|
+
subcommands << command.strip.match(/^([a-z-]*) +-/)[1]
|
18
|
+
rescue
|
19
|
+
# skip multi-line command descriptions
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
return subcommands
|
24
|
+
end
|
25
|
+
|
26
|
+
def run(command, run=false)
|
27
|
+
global_options = "--list=#{ARGV.first}"
|
28
|
+
subcommands = get_subcommands `bundle exec bin/mc #{command} --help`
|
29
|
+
|
30
|
+
if command == 'lists'
|
31
|
+
%w(group grouping merge-vars webhook).each do |subcommand|
|
32
|
+
subsubcommands = []
|
33
|
+
subsubcommands = get_subcommands `bundle exec bin/mc #{command} #{subcommand} --help`
|
34
|
+
subsubcommands.each {|subsubcommand| subcommands << "#{subcommand} #{subsubcommand}"}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
puts "### #{'-'*30}"
|
39
|
+
puts "### #{command.upcase} (#{subcommands.count})"
|
40
|
+
puts "### #{'-'*30}"
|
41
|
+
|
42
|
+
subcommands.each do |subcommand|
|
43
|
+
puts "echo_and_run bundle exec bin/mc #{global_options} #{command} #{subcommand}"
|
44
|
+
if run
|
45
|
+
puts "bundle exec bin/mc #{global_options} #{command} #{subcommand}"
|
46
|
+
puts '[[['
|
47
|
+
puts "#{`bundle exec bin/mc #{global_options} #{command} #{subcommand}`}"
|
48
|
+
puts ']]]'
|
49
|
+
puts "\n---\n"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
puts "\n"
|
53
|
+
end
|
54
|
+
|
55
|
+
puts "echo_and_run() { echo \"\$ $@\" ; \"$@\" ; echo -e \"\\n\" ;}" if !RUN_COMMANDS
|
56
|
+
|
57
|
+
commands.each do |command|
|
58
|
+
run command, RUN_COMMANDS
|
59
|
+
end
|
60
|
+
|
61
|
+
run('export', RUN_COMMANDS) if EXPORT_CMD
|
data/test/run_all.sh
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
echo_and_run() { echo "$ $@" ; "$@" ; echo -e "\n" ;}
|
2
|
+
|
3
|
+
CID=cccccccccccc
|
4
|
+
LID=llllllllllll
|
5
|
+
TID=tttttttt
|
6
|
+
EMAIL="test@example.com"
|
7
|
+
REQUESTBIN="http://requestb.in/xxxxxxx" #go to requestb.in and create new page
|
8
|
+
RANDOM_NAME="Random Name"
|
9
|
+
|
10
|
+
### ------------------------------
|
11
|
+
### CAMPAIGNS (15)
|
12
|
+
### ------------------------------
|
13
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns content $CID
|
14
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns create
|
15
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns delete
|
16
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns list
|
17
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns ready
|
18
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns replicate
|
19
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns resume
|
20
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns schedule
|
21
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns schedule-batch
|
22
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns segment-test
|
23
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns send
|
24
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns send-test
|
25
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns template-content
|
26
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns unschedule
|
27
|
+
echo_and_run bundle exec bin/mc --list=$LID campaigns update
|
28
|
+
|
29
|
+
### ------------------------------
|
30
|
+
### ECOMM (3)
|
31
|
+
### ------------------------------
|
32
|
+
echo_and_run bundle exec bin/mc --list=$LID ecomm add --order_id 1000 --store_id 1000 --email $EMAIL --total 5
|
33
|
+
echo_and_run bundle exec bin/mc --list=$LID ecomm orders
|
34
|
+
echo_and_run bundle exec bin/mc --list=$LID ecomm delete --order_id 1000 --store_id 1000
|
35
|
+
|
36
|
+
### ------------------------------
|
37
|
+
### GALLERY (1)
|
38
|
+
### ------------------------------
|
39
|
+
echo_and_run bundle exec bin/mc --list=$LID gallery list
|
40
|
+
|
41
|
+
### ------------------------------
|
42
|
+
### HELPER (10)
|
43
|
+
### ------------------------------
|
44
|
+
echo_and_run bundle exec bin/mc --list=$LID helper account
|
45
|
+
echo_and_run bundle exec bin/mc --list=$LID helper apikey
|
46
|
+
echo_and_run bundle exec bin/mc --list=$LID helper campaigns-for-email $EMAIL
|
47
|
+
echo_and_run bundle exec bin/mc --list=$LID helper chatter
|
48
|
+
echo_and_run bundle exec bin/mc --list=$LID helper default-list
|
49
|
+
echo_and_run bundle exec bin/mc --list=$LID helper last-campaign
|
50
|
+
echo_and_run bundle exec bin/mc --list=$LID helper lists-for-email $EMAIL
|
51
|
+
echo_and_run bundle exec bin/mc --list=$LID helper ping
|
52
|
+
echo_and_run bundle exec bin/mc --list=$LID helper userid
|
53
|
+
echo_and_run bundle exec bin/mc --list=$LID helper verified
|
54
|
+
|
55
|
+
### ------------------------------
|
56
|
+
### LISTS (26)
|
57
|
+
### ------------------------------
|
58
|
+
echo_and_run bundle exec bin/mc --list=$LID lists abuse-reports
|
59
|
+
echo_and_run bundle exec bin/mc --list=$LID lists clients
|
60
|
+
echo_and_run bundle exec bin/mc --list=$LID lists group
|
61
|
+
echo_and_run bundle exec bin/mc --list=$LID lists grouping
|
62
|
+
echo_and_run bundle exec bin/mc --list=$LID lists growth
|
63
|
+
echo_and_run bundle exec bin/mc lists list
|
64
|
+
echo_and_run bundle exec bin/mc --list=$LID lists locations
|
65
|
+
echo_and_run bundle exec bin/mc --list=$LID lists member-activity $EMAIL
|
66
|
+
echo_and_run bundle exec bin/mc --list=$LID lists member-info $EMAIL
|
67
|
+
echo_and_run bundle exec bin/mc --list=$LID lists members
|
68
|
+
echo_and_run bundle exec bin/mc --list=$LID lists merge-vars
|
69
|
+
echo_and_run bundle exec bin/mc --list=$LID lists segments
|
70
|
+
echo_and_run bundle exec bin/mc --list=$LID lists static-segments
|
71
|
+
echo_and_run bundle exec bin/mc --list=$LID lists subscribe $EMAIL
|
72
|
+
echo_and_run bundle exec bin/mc --list=$LID lists webhook
|
73
|
+
echo_and_run bundle exec bin/mc --list=$LID lists group add $RANDOM_NAME
|
74
|
+
echo_and_run bundle exec bin/mc --list=$LID lists group delete $RANDOM_NAME
|
75
|
+
echo_and_run bundle exec bin/mc --list=$LID lists group update
|
76
|
+
echo_and_run bundle exec bin/mc --list=$LID lists grouping add --type radio --groups $RANDOM_NAME
|
77
|
+
echo_and_run bundle exec bin/mc --list=$LID lists grouping delete
|
78
|
+
echo_and_run bundle exec bin/mc --list=$LID lists grouping list
|
79
|
+
echo_and_run bundle exec bin/mc --list=$LID lists grouping update
|
80
|
+
echo_and_run bundle exec bin/mc --list=$LID lists merge-vars list
|
81
|
+
echo_and_run bundle exec bin/mc --list=$LID lists webhook add $REQUESTBIN
|
82
|
+
echo_and_run bundle exec bin/mc --list=$LID lists webhook list
|
83
|
+
echo_and_run bundle exec bin/mc --list=$LID lists webhook delete $REQUESTBIN
|
84
|
+
|
85
|
+
### ------------------------------
|
86
|
+
### REPORTS (18)
|
87
|
+
### ------------------------------
|
88
|
+
echo_and_run bundle exec bin/mc --list=$LID reports abuse --cid=$CID
|
89
|
+
echo_and_run bundle exec bin/mc --list=$LID reports advice --cid=$CID
|
90
|
+
echo_and_run bundle exec bin/mc --list=$LID reports bounce --cid=$CID $EMAIL
|
91
|
+
echo_and_run bundle exec bin/mc --list=$LID reports bounces --cid=$CID
|
92
|
+
echo_and_run bundle exec bin/mc --list=$LID reports clicked-url --cid=$CID --tid=$TID
|
93
|
+
echo_and_run bundle exec bin/mc --list=$LID reports clicks --cid=$CID
|
94
|
+
echo_and_run bundle exec bin/mc --list=$LID reports domains --cid=$CID
|
95
|
+
echo_and_run bundle exec bin/mc --list=$LID reports ecomm --cid=$CID
|
96
|
+
echo_and_run bundle exec bin/mc --list=$LID reports eepurl --cid=$CID
|
97
|
+
echo_and_run bundle exec bin/mc --list=$LID reports ga --cid=$CID
|
98
|
+
echo_and_run bundle exec bin/mc --list=$LID reports geo --cid=$CID
|
99
|
+
echo_and_run bundle exec bin/mc --list=$LID reports member-activity --cid=$CID $EMAIL
|
100
|
+
echo_and_run bundle exec bin/mc --list=$LID reports not-opened --cid=$CID
|
101
|
+
echo_and_run bundle exec bin/mc --list=$LID reports opened --cid=$CID
|
102
|
+
echo_and_run bundle exec bin/mc --list=$LID reports sent-to --cid=$CID
|
103
|
+
echo_and_run bundle exec bin/mc --list=$LID reports share --cid=$CID
|
104
|
+
echo_and_run bundle exec bin/mc --list=$LID reports summary --cid=$CID
|
105
|
+
echo_and_run bundle exec bin/mc --list=$LID reports unsubscribes --cid=$CID
|
106
|
+
|
107
|
+
### ------------------------------
|
108
|
+
### SEARCH (2)
|
109
|
+
### ------------------------------
|
110
|
+
echo_and_run bundle exec bin/mc search campaigns santa
|
111
|
+
echo_and_run bundle exec bin/mc search members kale.davis
|
112
|
+
echo_and_run bundle exec bin/mc --list=$LID search members kale.davis
|
113
|
+
|
114
|
+
### ------------------------------
|
115
|
+
### USERS (6)
|
116
|
+
### ------------------------------
|
117
|
+
echo_and_run bundle exec bin/mc --list=$LID users invite
|
118
|
+
echo_and_run bundle exec bin/mc --list=$LID users invite-revoke
|
119
|
+
echo_and_run bundle exec bin/mc --list=$LID users invites
|
120
|
+
echo_and_run bundle exec bin/mc --list=$LID users login-revoke
|
121
|
+
echo_and_run bundle exec bin/mc --list=$LID users logins
|
122
|
+
echo_and_run bundle exec bin/mc --list=$LID users profile
|
123
|
+
|
124
|
+
### ------------------------------
|
125
|
+
### VIP (4)
|
126
|
+
### ------------------------------
|
127
|
+
echo_and_run bundle exec bin/mc --list=$LID vip add $EMAIL
|
128
|
+
echo_and_run bundle exec bin/mc --list=$LID vip activity
|
129
|
+
echo_and_run bundle exec bin/mc --list=$LID vip members
|
130
|
+
echo_and_run bundle exec bin/mc --list=$LID vip remove $EMAIL
|
131
|
+
|
132
|
+
### ------------------------------
|
133
|
+
### EXPORT (3)
|
134
|
+
### ------------------------------
|
135
|
+
echo_and_run bundle exec bin/mc export activity $CID > export_activity.txt
|
136
|
+
echo_and_run bundle exec bin/mc export ecommm > export_ecomm.txt
|
137
|
+
echo_and_run bundle exec bin/mc export list $LID > export_list.txt
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kale Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -185,12 +185,13 @@ files:
|
|
185
185
|
- lib/mc/helper.rb
|
186
186
|
- lib/mc/mailchimp.rb
|
187
187
|
- lib/mc/mailchimp_cached.rb
|
188
|
-
- lib/mc/report.rb
|
189
188
|
- lib/mc/version.rb
|
190
189
|
- lib/mc/writer.rb
|
191
190
|
- license.txt
|
192
191
|
- mc.gemspec
|
193
192
|
- test/mc_test.rb
|
193
|
+
- test/run_all.rb
|
194
|
+
- test/run_all.sh
|
194
195
|
- test/test_helper.rb
|
195
196
|
homepage: http://rubygems.org/gems/mc
|
196
197
|
licenses:
|
@@ -222,4 +223,6 @@ test_files:
|
|
222
223
|
- features/step_definitions/mc_steps.rb
|
223
224
|
- features/support/env.rb
|
224
225
|
- test/mc_test.rb
|
226
|
+
- test/run_all.rb
|
227
|
+
- test/run_all.sh
|
225
228
|
- test/test_helper.rb
|
data/lib/mc/report.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
module Report
|
2
|
-
class BaseReport
|
3
|
-
def initialize(api)
|
4
|
-
@api = api
|
5
|
-
end
|
6
|
-
|
7
|
-
def run
|
8
|
-
raise NotImplementedError.new("You must implement the run method.")
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class CampaignStats < BaseReport
|
13
|
-
def initialize(api, start=0)
|
14
|
-
super(api)
|
15
|
-
@start = start
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
last_campaign_sent = @api.campaigns(:filters => {:status => "sent"}, :start => @start, :limit => 1)
|
20
|
-
campaign_data = last_campaign_sent['data'].first
|
21
|
-
campaign_id = campaign_data['id']
|
22
|
-
|
23
|
-
campaign_stats = @api.campaign_stats({:cid => campaign_id})
|
24
|
-
emails_sent = campaign_stats['emails_sent']
|
25
|
-
|
26
|
-
email_domains = @api.campaign_email_domain_performance({:cid => campaign_id})
|
27
|
-
|
28
|
-
puts "Details for #{campaign_data['title']} - #{campaign_data['archive_url']}"
|
29
|
-
puts "==="
|
30
|
-
puts "Sent at #{campaign_data['send_time']}"
|
31
|
-
puts "Last open at #{campaign_stats['last_open']}"
|
32
|
-
|
33
|
-
puts "--"
|
34
|
-
puts "Emails sent: #{emails_sent}"
|
35
|
-
puts "Opens: #{campaign_stats['unique_opens']} (%#{(campaign_stats['unique_opens'].to_f / emails_sent).round(4) * 100})"
|
36
|
-
puts "Users who clicked: #{campaign_stats['users_who_clicked']} (%#{(campaign_stats['users_who_clicked'].to_f / emails_sent).round(4) * 100})"
|
37
|
-
puts "Clicks: #{campaign_stats['unique_clicks']}"
|
38
|
-
|
39
|
-
puts "--"
|
40
|
-
puts "Unsubscribers: #{campaign_stats['unsubscribes']}"
|
41
|
-
puts "Hard/Soft Bounces: #{campaign_stats['hard_bounces']}/#{campaign_stats['soft_bounces']}"
|
42
|
-
puts "Abuse reports: #{campaign_stats['abuse_reports']}"
|
43
|
-
|
44
|
-
puts "--"
|
45
|
-
email_domains.each do |domain|
|
46
|
-
puts "#{domain['emails']} sent to #{domain['domain']} - open/click count: #{domain['opens']}/#{domain['clicks']} - open/click %: #{domain['opens_pct']}/#{domain['clicks_pct']}"
|
47
|
-
end
|
48
|
-
|
49
|
-
puts "--"
|
50
|
-
most_clicked_links(campaign_id).first(20).each do |url,clicks|
|
51
|
-
puts "#{clicks} - #{url[0..70]}"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def most_clicked_links(campaign_id)
|
56
|
-
most_clicked = {}
|
57
|
-
|
58
|
-
url_click_stats = @api.campaign_click_stats({:cid => campaign_id})
|
59
|
-
url_click_stats.each do |stat|
|
60
|
-
most_clicked[stat.first] = stat.last['unique']
|
61
|
-
end
|
62
|
-
|
63
|
-
most_clicked.sort_by {|url,clicks| -clicks}
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class TotalClicks < BaseReport
|
68
|
-
def initialize(api, list_id)
|
69
|
-
super(api)
|
70
|
-
@list_id = list_id
|
71
|
-
end
|
72
|
-
|
73
|
-
def run
|
74
|
-
@api.campaigns(:filters => {:list_id => @list_id}, :limit => 25)['data'].each do |campaign|
|
75
|
-
puts "#{campaign['subject']} - #{@api.campaignStats({:cid => campaign['id']})['clicks'].to_i}"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class ArchiveUrls < BaseReport
|
81
|
-
def initialize(api, list_id)
|
82
|
-
super(api)
|
83
|
-
@list_id = list_id
|
84
|
-
end
|
85
|
-
|
86
|
-
def run
|
87
|
-
@api.campaigns(:filters => {:list_id => @list_id}, :limit => 20)['data'].each do |campaign|
|
88
|
-
if campaign['subject'] != nil
|
89
|
-
puts "<a href=\"#{campaign['archive_url']}\" class=\"link\">#{campaign['subject'].match('\d+')}</a>,"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Zeitgest < BaseReport
|
96
|
-
def initialize(api, list_id, year)
|
97
|
-
super(api)
|
98
|
-
@list_id = list_id
|
99
|
-
@year = year
|
100
|
-
end
|
101
|
-
|
102
|
-
def run
|
103
|
-
@campaigns = load_campaigns
|
104
|
-
yearly_most_popular
|
105
|
-
end
|
106
|
-
|
107
|
-
def load_campaigns
|
108
|
-
campaigns = []
|
109
|
-
|
110
|
-
@api.campaigns_list(:filters => {:list_id => @list_id}, :limit => 100)['data'].each do |campaign|
|
111
|
-
if campaign['send_time'] != nil && campaign['send_time'].match(/#{@year.to_s}/)
|
112
|
-
campaigns << campaign
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
return campaigns
|
117
|
-
end
|
118
|
-
|
119
|
-
def yearly_most_popular
|
120
|
-
stats = {}
|
121
|
-
max_rate = 0
|
122
|
-
|
123
|
-
@campaigns.each do |campaign|
|
124
|
-
@api.campaignClickStats(:cid => campaign['id']).each do |item|
|
125
|
-
url, stat = item
|
126
|
-
click_rate = (stat["clicks"] / campaign['emails_sent'].to_f) * 100
|
127
|
-
max_rate = click_rate if click_rate > max_rate
|
128
|
-
stats[url] = [click_rate, campaign['send_time'][5..6]]
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
normalize = 100 / max_rate
|
133
|
-
|
134
|
-
stats.sort_by { |url, clicks| clicks[0] }.reverse[0..100].each_with_index do |(url, data), index|
|
135
|
-
click_rate, month = data
|
136
|
-
puts "#{index}. #{url} - #{click_rate * normalize} in #{month}"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|