ruby-mailchimp 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mail_chimp.rb +252 -25
- metadata +4 -3
data/lib/mail_chimp.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'net/imap'
|
3
3
|
require 'rubygems'
|
4
|
-
require 'xmlrpc
|
4
|
+
require 'xmlrpc/@client'
|
5
5
|
gem 'actionmailer'
|
6
6
|
require 'action_mailer'
|
7
7
|
|
@@ -41,20 +41,31 @@ require 'action_mailer'
|
|
41
41
|
# bonobo.listUnsubscribe(uid, list_id, "testuser@nowhere.com")
|
42
42
|
#
|
43
43
|
class MailChimp
|
44
|
-
API_URL = "http://api.mailchimp.com/1.
|
45
|
-
attr_accessor :email_server, :email_user, :email_password,
|
44
|
+
API_URL = "http://api.mailchimp.com/1.1/"
|
45
|
+
attr_accessor :email_server, :email_user, :email_password, :@client
|
46
|
+
@client = nil
|
46
47
|
|
47
48
|
def login(username, password)
|
48
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
49
|
-
client.call("login", username, password)
|
49
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
50
|
+
@client.call("login", username, password)
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
-
|
54
|
-
client
|
55
|
-
|
53
|
+
def apikeyAdd(username, password, new_key)
|
54
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
55
|
+
@client.call("apikeyAdd", username, password, new_key)
|
56
|
+
end
|
57
|
+
|
58
|
+
def apikeyExpire(username, password, new_key)
|
59
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
60
|
+
@client.call("apikeyExpire", username, password, new_key)
|
56
61
|
end
|
57
62
|
|
63
|
+
def apikeys(username, password, uid, include_expired=false)
|
64
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
65
|
+
@client.call("apikeys", username, password, uid, include_expired)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
58
69
|
def getListByName(uid, listname)
|
59
70
|
listinfo = lists(uid)
|
60
71
|
listhash = {}
|
@@ -70,48 +81,264 @@ class MailChimp
|
|
70
81
|
return list["id"]
|
71
82
|
end
|
72
83
|
|
84
|
+
def listBatchSubscribe(uid, list_id, email_array, double_optin=true, update_existing=true, replace_interests=true)
|
85
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
86
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
87
|
+
@client.call("listBatchSubscribe", uid, list_id, email_array, double_optin, update_existing, replace_interests)
|
88
|
+
end
|
89
|
+
|
90
|
+
def listBatchUnsubscribe(uid, list_id, email_array, delete_member=false, send_goodbye=true, send_notify=true)
|
91
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
92
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
93
|
+
@client.call("listBatchSubscribe", uid, list_id, email_array, delete_member, send_goodbye, send_notify)
|
94
|
+
end
|
95
|
+
|
96
|
+
def listInterestGroupAdd(uid, list_id, group_name)
|
97
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
98
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
99
|
+
@client.call("listInterestGroupAdd", uid, list_id, group_name)
|
100
|
+
end
|
101
|
+
|
102
|
+
def listInterestGroupDel(uid, list_id, group_name)
|
103
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
104
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
105
|
+
@client.call("listInterestGroupDel", uid, list_id, group_name)
|
106
|
+
end
|
107
|
+
|
108
|
+
def listInterestGroups(uid, list_id)
|
109
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
110
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
111
|
+
@client.call("listInterests", uid, list_id)
|
112
|
+
end
|
113
|
+
|
114
|
+
def listMemberInfo(uid, list_id, email)
|
115
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
116
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
117
|
+
@client.call("listMemberInfo", uid, list_id, email)
|
118
|
+
end
|
119
|
+
|
120
|
+
def listMembers(uid, list_id, status, start=0, limit=100)
|
121
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
122
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
123
|
+
@client.call("listMembers", uid, list_id, status, start, limit)
|
124
|
+
end
|
125
|
+
|
126
|
+
def listMergeVarAdd(uid, list_id, merge_tag, description, required=false)
|
127
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
128
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
129
|
+
@client.call("listMergeVarAdd", uid, list_id, merge_tag, description, required)
|
130
|
+
end
|
131
|
+
|
132
|
+
def listMergeVarDel(uid, list_id, merge_tag)
|
133
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
134
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
135
|
+
@client.call("listMergeVarDel", uid, list_id, merge_tag)
|
136
|
+
end
|
137
|
+
|
73
138
|
def listMergeVars(uid, list_id)
|
74
139
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
75
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
76
|
-
client.call("listMergeVars", uid, list_id)
|
140
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
141
|
+
@client.call("listMergeVars", uid, list_id)
|
77
142
|
end
|
78
143
|
|
79
144
|
def listInterestGroups(uid, list_id)
|
80
145
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
81
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
82
|
-
client.call("listInterestGroups", uid, list_id)
|
146
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
147
|
+
@client.call("listInterestGroups", uid, list_id)
|
83
148
|
end
|
84
149
|
|
85
150
|
def listSubscribe(uid, list_id, email, merge_vars, email_type="html", double_optin=true)
|
86
151
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
87
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
88
|
-
client.call("listSubscribe", uid, list_id, email, merge_vars, email_type, double_optin)
|
152
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
153
|
+
@client.call("listSubscribe", uid, list_id, email, merge_vars, email_type, double_optin)
|
89
154
|
end
|
90
155
|
|
91
156
|
def listUnsubscribe(uid, list_id, email, delete_member=false, send_goodbye=true, send_notify=true)
|
92
157
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
93
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
94
|
-
client.call("listUnsubscribe", uid, list_id, email, delete_member, send_goodbye, send_notify)
|
158
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
159
|
+
@client.call("listUnsubscribe", uid, list_id, email, delete_member, send_goodbye, send_notify)
|
95
160
|
end
|
96
161
|
|
97
162
|
def listUpdateMember(uid, list_id, email, merge_vars, email_type, replace_interests=true)
|
98
163
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
99
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
100
|
-
client.call("listUpdateMember", uid, list_id, email, merge_vars, email_type, replace_interests)
|
164
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
165
|
+
@client.call("listUpdateMember", uid, list_id, email, merge_vars, email_type, replace_interests)
|
101
166
|
end
|
102
167
|
|
103
|
-
def
|
168
|
+
def lists(uid)
|
104
169
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
105
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
106
|
-
client.call("
|
170
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
171
|
+
@client.call("lists", uid)
|
107
172
|
end
|
108
173
|
|
109
|
-
|
174
|
+
#######################
|
175
|
+
# HELPER METHODS
|
176
|
+
#######################
|
177
|
+
def generateText(uid, mime_type, content)
|
178
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
179
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
180
|
+
@client.call("generateText", uid, mime_type, content)
|
181
|
+
end
|
182
|
+
|
183
|
+
def getAffiliateInfo(uid)
|
184
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
185
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
186
|
+
@client.call("generateText", uid, mime_type, content)
|
187
|
+
end
|
188
|
+
|
189
|
+
def inlineCss(uid, html, strip_css=false)
|
190
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
191
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
192
|
+
@client.call("inlineCss", uid, html, strip_css)
|
193
|
+
end
|
194
|
+
|
195
|
+
def ping(uid)
|
196
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
197
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
198
|
+
@client.call("ping", uid)
|
199
|
+
end
|
200
|
+
|
201
|
+
#######################
|
202
|
+
# CAMPAIGN AIM METHODS
|
203
|
+
#######################
|
204
|
+
def campaignClickDetailAIM(uid, campaign_id, url, start, limit)
|
205
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
206
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
207
|
+
@client.call("campaignClickDetailAIM", uid, campaign_id, url, start, limit)
|
208
|
+
end
|
209
|
+
|
210
|
+
def campaignEmailStatsAIM(uid, campaign_id, email_address)
|
211
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
212
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
213
|
+
@client.call("campaignEmailStatsAIM", uid, campaign_id, email_address)
|
214
|
+
end
|
215
|
+
|
216
|
+
def campaignEmailStatsAIMAll(uid, campaign_id, start, limit)
|
110
217
|
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
111
|
-
client = XMLRPC::Client.new2(API_URL) if client.nil?
|
112
|
-
client.call("
|
218
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
219
|
+
@client.call("campaignEmailStatsAIMAll", uid, campaign_id, start, limit)
|
113
220
|
end
|
114
221
|
|
222
|
+
def campaignNotOpenedAIM(uid, campaign_id, start, limit)
|
223
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
224
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
225
|
+
@client.call("campaignNotOpenedAIM", uid, campaign_id, start, limit)
|
226
|
+
end
|
227
|
+
|
228
|
+
def campaignOpenedAIM(uid, campaign_id, start, limit)
|
229
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
230
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
231
|
+
@client.call("campaignOpenedAIM", uid, campaign_id, start, limit)
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
#######################
|
236
|
+
# CAMPAIGN STATS METHODS
|
237
|
+
#######################
|
238
|
+
def campaignAbuseReports(uid, campaign_id, start, limit)
|
239
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
240
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
241
|
+
@client.call("campaignAbuseReports", uid, campaign_id, start, limit)
|
242
|
+
end
|
243
|
+
|
244
|
+
def campaignClickStats(uid, campaign_id)
|
245
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
246
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
247
|
+
@client.call("campaignClickStats", uid, campaign_id)
|
248
|
+
end
|
249
|
+
|
250
|
+
def campaignHardBounces(uid, campaign_id, start, limit)
|
251
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
252
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
253
|
+
@client.call("campaignHardBounces", uid, campaign_id, start, limit)
|
254
|
+
end
|
255
|
+
|
256
|
+
def campaignSoftBounces(uid, campaign_id, start, limit)
|
257
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
258
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
259
|
+
@client.call("campaignSoftBounces", uid, campaign_id, start, limit)
|
260
|
+
end
|
261
|
+
|
262
|
+
def campaignStats(uid, campaign_id)
|
263
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
264
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
265
|
+
@client.call("campaignStats", uid, campaign_id)
|
266
|
+
end
|
267
|
+
|
268
|
+
def campaignUnsubscribes(uid, campaign_id, start, limit)
|
269
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
270
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
271
|
+
@client.call("campaignUnsubscribes", uid, campaign_id, start, limit)
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
#######################
|
276
|
+
# CAMPAIGN METHODS
|
277
|
+
#######################
|
278
|
+
def campaignContent(uid, campaign_id)
|
279
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
280
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
281
|
+
@client.call("campaignContent", uid, campaign_id)
|
282
|
+
end
|
283
|
+
|
284
|
+
def campaignCreate(uid, campaign_type, options, content, segment_options, type_options)
|
285
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
286
|
+
raise StandardError("Unknown campaign type #{campaign_type}") unless %w(regular plaintext absplit rss trans).include?(campaign_type)
|
287
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
288
|
+
@client.call("campaignCreate", uid, campaign_type, options, content, segment_options, type_options)
|
289
|
+
end
|
290
|
+
|
291
|
+
def campaignEcommAddOrder(uid, order_info, campaign_id, plugin_info)
|
292
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
293
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
294
|
+
@client.call("campaignEcommAddOrder", uid, order_info, campaign_id, plugin_info)
|
295
|
+
end
|
296
|
+
|
297
|
+
def campaignFolders(uid)
|
298
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
299
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
300
|
+
@client.call("campaignFolders", uid)
|
301
|
+
end
|
302
|
+
|
303
|
+
def campaignPause(uid, campaign_id)
|
304
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
305
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
306
|
+
@client.call("campaignPause", uid, campaign_id)
|
307
|
+
end
|
308
|
+
|
309
|
+
def campaignResume(uid, campaign_id)
|
310
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
311
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
312
|
+
@client.call("campaignResume", uid, campaign_id)
|
313
|
+
end
|
314
|
+
|
315
|
+
def campaignSchedule(uid, campaign_id, schedule_time, schedule_time_b)
|
316
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
317
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
318
|
+
@client.call("campaignSchedule", uid, campaign_id, schedule_time, schedule_time_b)
|
319
|
+
end
|
320
|
+
|
321
|
+
def campaignSegmentTest(uid, list_id, options)
|
322
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
323
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
324
|
+
@client.call("campaignSegmentTest", uid, campaign_id, options)
|
325
|
+
end
|
326
|
+
|
327
|
+
def campaignSendNow(uid, campaign_id)
|
328
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
329
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
330
|
+
@client.call("campaignSendNow", uid, campaign_id)
|
331
|
+
end
|
332
|
+
|
333
|
+
def campaignUnschedule(uid, campaign_id)
|
334
|
+
raise StandardError("Not Loggged in or invalid UID.") if (uid.nil?)
|
335
|
+
@client = XMLRPC::Client.new2(API_URL) if @client.nil?
|
336
|
+
@client.call("campaignUnschedule", uid, campaign_id)
|
337
|
+
end
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
115
342
|
#
|
116
343
|
# Stores the inbox attributes to allow connection by check_inbox
|
117
344
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- C. G. Brown
|
@@ -9,11 +9,12 @@ autorequire: mail_chimp
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-06 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionmailer
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
54
|
requirements: []
|
54
55
|
|
55
56
|
rubyforge_project:
|
56
|
-
rubygems_version:
|
57
|
+
rubygems_version: 1.2.0
|
57
58
|
signing_key:
|
58
59
|
specification_version: 2
|
59
60
|
summary: Allows programmatic subscription and unsubscription to MailChimp. Requires MailChimp account.
|