hominid 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +48 -91
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/hominid.gemspec +3 -8
- data/lib/hominid.rb +13 -28
- data/lib/hominid/base.rb +59 -53
- data/lib/hominid/campaign.rb +637 -147
- data/lib/hominid/helper.rb +80 -30
- data/lib/hominid/list.rb +357 -103
- data/lib/hominid/security.rb +46 -0
- metadata +5 -16
- data/hominid.yml.tpl +0 -25
- data/lib/hominid/webhook.rb +0 -131
- data/tasks/rails/hominid.rake +0 -22
data/lib/hominid/helper.rb
CHANGED
@@ -1,44 +1,94 @@
|
|
1
1
|
module Hominid
|
2
|
-
|
3
|
-
class Helper < Base
|
2
|
+
module Helper
|
4
3
|
|
5
|
-
#
|
6
|
-
# --------------------------------
|
4
|
+
# HELPER METHODS
|
7
5
|
|
8
|
-
def
|
9
|
-
#
|
10
|
-
|
6
|
+
def account_details
|
7
|
+
# Retrieve lots of account information including payments made, plan info,
|
8
|
+
# some account stats, installed modules, contact info, and more. No private
|
9
|
+
# information like Credit Card numbers is available.
|
10
|
+
#
|
11
|
+
# Parameters:
|
12
|
+
# options (Hash) =
|
13
|
+
#
|
14
|
+
# Returns:
|
15
|
+
# An array of account details for this API key including:
|
16
|
+
# username (String) = The Account username.
|
17
|
+
# user_id (String) = The Account user unique id (for building some links).
|
18
|
+
# is_trial (Boolean) = Whether the Account is in Trial mode.
|
19
|
+
# timezone (String) = The timezone for the Account.
|
20
|
+
# plan_type (String) = Plan Type - "monthly", "payasyougo", or "free".
|
21
|
+
# plan_low (Integer) = Only for Monthly plans - the lower tier for list size.
|
22
|
+
# plan_high (Integer) = Only for Monthly plans - the upper tier for list size.
|
23
|
+
# plan_start_date (DateTime) = Only for Monthly plans - the start date for a monthly plan.
|
24
|
+
# emails_left (Integer) = Only for Free and Pay-as-you-go plans emails credits left for the account.
|
25
|
+
# pending_monthly (Boolean) = Whether the account is finishing Pay As You Go credits before switching to
|
26
|
+
# a Monthly plan.
|
27
|
+
# first_payment (DateTime) = Date of first payment.
|
28
|
+
# last_payment (DateTime) = Date of most recent payment.
|
29
|
+
# times_logged_in (Integer) = Total number of times the account has been logged into via the web.
|
30
|
+
# last_login (DateTime) = Date/time of last login via the web.
|
31
|
+
# affiliate_link (String) = Monkey Rewards link for our Affiliate program.
|
32
|
+
# contact (Array) = Contact details for the account, including: First & Last name, email, company
|
33
|
+
# name, address, phone, and url.
|
34
|
+
# addons (Array) = Addons installed in the account and the date they were installed.
|
35
|
+
# orders (Array) = Order details for the account, include order_id, type, cost, date/time, and any
|
36
|
+
# credits applied to the order.
|
37
|
+
#
|
38
|
+
hash_to_object(call("getAccountDetails"))
|
11
39
|
end
|
12
40
|
|
13
|
-
|
14
|
-
|
15
|
-
|
41
|
+
def inline_css(html, strip_css = false)
|
42
|
+
# Send your HTML content to have the CSS inlined and optionally remove the original styles.
|
43
|
+
#
|
44
|
+
# Paramters:
|
45
|
+
# html (String) = Your HTML content.
|
46
|
+
# strip_css (Boolean) = Whether you want the CSS <style> tags stripped from the returned document. Defaults to false.
|
47
|
+
#
|
48
|
+
# Returns:
|
49
|
+
# Your HTML content with all CSS inlined, just like if we sent it. (String)
|
50
|
+
#
|
51
|
+
call("inlineCss", html, strip_css)
|
16
52
|
end
|
53
|
+
alias :convert_css_to_inline :inline_css
|
17
54
|
|
18
|
-
def
|
19
|
-
# Create a new folder to file campaigns in
|
20
|
-
|
55
|
+
def create_folder(name)
|
56
|
+
# Create a new folder to file campaigns in.
|
57
|
+
#
|
58
|
+
# Parameters:
|
59
|
+
# name (String) = A unique name for a folder.
|
60
|
+
#
|
61
|
+
# Returns:
|
62
|
+
# The folder_id of the newly created folder. (Integer)
|
63
|
+
call("createFolder", name)
|
21
64
|
end
|
22
65
|
|
23
|
-
def
|
24
|
-
# Have HTML content auto-converted to a text-only format.
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
66
|
+
def generate_text(type, content)
|
67
|
+
# Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content,
|
68
|
+
# an existing Campaign Id, or an existing Template Id. Note that this will not save anything to or update any of
|
69
|
+
# your lists, campaigns, or templates.
|
70
|
+
#
|
71
|
+
# Parameters:
|
72
|
+
# type (String) = Must be one of: "html", "template", "url", "cid", or "tid".
|
73
|
+
# content (String) = The content to use. For "html" expects a single string value, "template" expects an array
|
74
|
+
# like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid"
|
75
|
+
# expects a valid Campaign Id, and "tid" expects a valid Template Id on your account.
|
76
|
+
#
|
77
|
+
# Returns:
|
78
|
+
# The content passed in converted to text. (String)
|
79
|
+
#
|
80
|
+
call("generateText", type, content)
|
32
81
|
end
|
33
82
|
|
34
|
-
def
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
|
83
|
+
def ping(options = {})
|
84
|
+
# "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything
|
85
|
+
# is good. Note than unlike most all of our methods, we don't throw an Exception if we are having issues. You will
|
86
|
+
# simply receive a different string back that will explain our view on what is going on.
|
87
|
+
#
|
88
|
+
# Returns:
|
89
|
+
# "Everything's Chimpy!"
|
90
|
+
#
|
91
|
+
call("ping")
|
42
92
|
end
|
43
93
|
|
44
94
|
end
|
data/lib/hominid/list.rb
CHANGED
@@ -1,110 +1,290 @@
|
|
1
1
|
module Hominid
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
attr_reader :attributes
|
10
|
-
|
11
|
-
def initialize(*args)
|
12
|
-
options = args.last.is_a?(Hash) ? args.last : {}
|
13
|
-
raise StandardError.new('Please provide a List ID.') unless options[:id]
|
14
|
-
@list_id = options.delete(:id)
|
15
|
-
@attributes = options.delete(:attributes)
|
16
|
-
super(options)
|
2
|
+
module List
|
3
|
+
|
4
|
+
# LIST RELATED METHODS
|
5
|
+
|
6
|
+
def lists
|
7
|
+
# Get all the lists for this account.
|
8
|
+
call("lists")
|
17
9
|
end
|
18
|
-
|
19
|
-
def
|
20
|
-
#
|
21
|
-
|
10
|
+
|
11
|
+
def find_list_by_name(list_name)
|
12
|
+
# Find a mailing list by name
|
13
|
+
call("lists").find {|list| list["name"] == list_name}
|
22
14
|
end
|
23
|
-
|
24
|
-
def
|
25
|
-
# Find list by name
|
26
|
-
|
15
|
+
|
16
|
+
def find_list_id_by_name(list_name)
|
17
|
+
# Find a mailing list ID by name
|
18
|
+
call("lists").find {|list| list["name"] == list_name}["id"]
|
27
19
|
end
|
28
|
-
|
29
|
-
def
|
30
|
-
# Find list by
|
31
|
-
|
20
|
+
|
21
|
+
def find_list_by_id(list_id)
|
22
|
+
# Find a mailing list by ID
|
23
|
+
call("lists").find {|list| list["id"] == list_id}
|
32
24
|
end
|
33
|
-
|
34
|
-
def
|
35
|
-
# Find list by
|
36
|
-
|
25
|
+
|
26
|
+
def find_list_by_web_id(list_web_id)
|
27
|
+
# Find a mailing list by web_id
|
28
|
+
call("lists").find {|list| list["web_id"] == list_web_id}
|
37
29
|
end
|
38
|
-
|
39
|
-
def
|
40
|
-
#
|
41
|
-
|
42
|
-
list = self.find_by_id(id_or_web_id.to_s).to_a + self.find_by_web_id(id_or_web_id.to_i).to_a
|
43
|
-
return list.blank? ? nil : list.first
|
30
|
+
|
31
|
+
def find_list_id_by_web_id(list_web_id)
|
32
|
+
# Find a mailing list ID by web_id
|
33
|
+
call("lists").find {|list| list["web_id"] == list_web_id}["id"]
|
44
34
|
end
|
45
|
-
|
46
|
-
def
|
47
|
-
#
|
48
|
-
|
35
|
+
|
36
|
+
def list_abuse_reports(list_id, start = 0, limit = 500, since = "2000-01-01 00:00:00")
|
37
|
+
# Get all email addresses that complained about a given list.
|
38
|
+
#
|
39
|
+
# Parameters:
|
40
|
+
# list_id (String) = The mailing list ID value.
|
41
|
+
# list_id (String) = The mailing list ID value.
|
42
|
+
# start (Integer) = Page number to start at. Defaults to 0.
|
43
|
+
# limit (Integer) = Number of results to return. Defaults to 500. Upper limit is 1000.
|
44
|
+
# since (DateTime) = Only return email reports since this date. Must be in YYYY-MM-DD HH:II:SS format (GMT).
|
45
|
+
#
|
46
|
+
# Returns:
|
47
|
+
# An array of abuse reports for this list including:
|
48
|
+
# date (String) = Date/time the abuse report was received and processed.
|
49
|
+
# email (String) = The email address that reported abuse.
|
50
|
+
# campaign_id (String) = The unique id for the campaign that report was made against.
|
51
|
+
# type (String) = An internal type generally specifying the orginating mail provider - may not be
|
52
|
+
# useful outside of filling report views.
|
53
|
+
#
|
54
|
+
call("listAbuseReports", list_id, start, limit, since)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_group(list_id, group)
|
58
|
+
# Add a single Interest Group - if interest groups for the List are not yet
|
59
|
+
# enabled, adding the first group will automatically turn them on.
|
60
|
+
#
|
61
|
+
# Parameters:
|
62
|
+
# list_id (String) = The mailing list ID value.
|
63
|
+
# group (String) = The interest group to add.
|
64
|
+
#
|
65
|
+
# Returns:
|
66
|
+
# True if successful, error code if not.
|
67
|
+
#
|
68
|
+
call("listInterestGroupAdd", list_id, group)
|
49
69
|
end
|
50
70
|
alias :interest_group_add :create_group
|
51
|
-
|
52
|
-
def create_tag(tag, name, required = false)
|
53
|
-
# Add a merge tag to a list
|
54
|
-
|
71
|
+
|
72
|
+
def create_tag(list_id, tag, name, required = false)
|
73
|
+
# Add a new merge tag to a given list
|
74
|
+
#
|
75
|
+
# Parameters:
|
76
|
+
# list_id (String) = The mailing list ID value.
|
77
|
+
# tag (String) = The merge tag to add. Ex: FNAME
|
78
|
+
# name (String) = The long description of the tag being added, used for user displays.
|
79
|
+
# required (Boolean) = TODO: set this up to accept the options available.
|
80
|
+
#
|
81
|
+
# Returns:
|
82
|
+
# True if successful, error code if not.
|
83
|
+
#
|
84
|
+
call("listMergeVarAdd", list_id, tag, name, required)
|
55
85
|
end
|
56
86
|
alias :merge_var_add :create_tag
|
57
|
-
|
58
|
-
def
|
59
|
-
#
|
60
|
-
|
87
|
+
|
88
|
+
def create_webhook(list_id, url, actions = {}, sources = {})
|
89
|
+
# Add a new Webhook URL for the given list
|
90
|
+
#
|
91
|
+
# Parameters:
|
92
|
+
# list_id (String) = The mailing list ID value.
|
93
|
+
# url (String) = A valid URL for the Webhook - it will be validated.
|
94
|
+
# actions (Hash) = A hash of actions to fire this Webhook for including:
|
95
|
+
# :subscribe (Boolean) - defaults to true.
|
96
|
+
# :unsubscribe (Boolean) - defaults to true.
|
97
|
+
# :profile (Boolean) - defaults to true.
|
98
|
+
# :cleaned (Boolean) - defaults to true.
|
99
|
+
# :upemail (Boolean) - defaults to true.
|
100
|
+
# sources (Hash) = A hash of sources to fire this Webhook for including:
|
101
|
+
# :user (Boolean) - defaults to true.
|
102
|
+
# :admin (Boolean) - defaults to true.
|
103
|
+
# :api (Boolean) - defaults to false.
|
104
|
+
#
|
105
|
+
# See the Mailchimp API documentation for more information.
|
106
|
+
#
|
107
|
+
# Returns:
|
108
|
+
# True if successful, error code if not.
|
109
|
+
#
|
110
|
+
call("listWebhookAdd", list_id, url, actions, sources)
|
111
|
+
end
|
112
|
+
alias :webhook_add :create_webhook
|
113
|
+
|
114
|
+
def delete_group(list_id, group)
|
115
|
+
# Delete a single Interest Group - if the last group for a list
|
116
|
+
#is deleted, this will also turn groups for the list off.
|
117
|
+
#
|
118
|
+
# Parameters:
|
119
|
+
# list_id (String) = The mailing list ID value.
|
120
|
+
# group (String) = The interest group to delete.
|
121
|
+
#
|
122
|
+
# Returns:
|
123
|
+
# True if successful, error code if not.
|
124
|
+
#
|
125
|
+
call("listInterestGroupDel", list_id, group)
|
61
126
|
end
|
62
127
|
alias :interest_group_del :delete_group
|
63
128
|
|
64
|
-
def delete_tag(tag)
|
65
|
-
# Delete a merge tag and all its members
|
66
|
-
|
129
|
+
def delete_tag(list_id, tag)
|
130
|
+
# Delete a merge tag from a given list and all its members.
|
131
|
+
# Seriously - the data is removed from all members as well!
|
132
|
+
# Note that on large lists this method may seem a bit slower
|
133
|
+
# than calls you typically make.
|
134
|
+
#
|
135
|
+
# Parameters:
|
136
|
+
# list_id (String) = The mailing list ID value.
|
137
|
+
# tag (String) = The merge tag to delete.
|
138
|
+
#
|
139
|
+
# Returns:
|
140
|
+
# True if successful, error code if not.
|
141
|
+
#
|
142
|
+
call("listMergeVarDel", list_id, tag)
|
67
143
|
end
|
68
144
|
alias :merge_var_del :delete_tag
|
69
|
-
|
70
|
-
def
|
71
|
-
#
|
72
|
-
|
145
|
+
|
146
|
+
def delete_webhook(list_id, url)
|
147
|
+
# Delete an existing Webhook URL from a given list.
|
148
|
+
#
|
149
|
+
# Parameters:
|
150
|
+
# list_id (String) = The mailing list ID value.
|
151
|
+
# url (String) = The URL of a Webhook on this list.
|
152
|
+
#
|
153
|
+
# Returns:
|
154
|
+
# True if successful, error code if not.
|
155
|
+
#
|
156
|
+
call("listWebhookDel", list_id, url)
|
157
|
+
end
|
158
|
+
alias :webhook_del :delete_webhook
|
159
|
+
|
160
|
+
def groups(list_id)
|
161
|
+
# Get the list of interest groups for a given list, including
|
162
|
+
# the label and form information.
|
163
|
+
#
|
164
|
+
# Parameters:
|
165
|
+
# list_id (String) = The mailing list ID value.
|
166
|
+
#
|
167
|
+
# Returns:
|
168
|
+
# A struct of interest groups for this list:
|
169
|
+
# name (String) = Name for the Interest group.
|
170
|
+
# form_field (String) = Gives the type of interest group: checkbox, radio, select, etc.
|
171
|
+
# groups (Array) = Array of the group names
|
172
|
+
#
|
173
|
+
call("listInterestGroups", list_id)
|
73
174
|
end
|
74
175
|
alias :interest_groups :groups
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
#
|
79
|
-
|
176
|
+
|
177
|
+
def growth_history(list_id)
|
178
|
+
# Access the Growth History by Month for a given list.
|
179
|
+
#
|
180
|
+
# Parameters:
|
181
|
+
# list_id (String) = The mailing list ID value.
|
182
|
+
# group (String) = The interest group to delete.
|
183
|
+
#
|
184
|
+
# Returns:
|
185
|
+
# An array of months and growth with the following fields:
|
186
|
+
# month (String) = The Year and Month in question using YYYY-MM format.
|
187
|
+
# existing (Integer) = Number of existing subscribers to start the month.
|
188
|
+
# imports (Integer) = Number of subscribers imported during the month.
|
189
|
+
# optins (Integer) = Number of subscribers who opted-in during the month.
|
190
|
+
#
|
191
|
+
call("listGrowthHistory", list_id)
|
80
192
|
end
|
81
|
-
|
82
|
-
def
|
83
|
-
# Get
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
|
193
|
+
|
194
|
+
def member_info(list_id, email)
|
195
|
+
# Get all the information for a particular member of a list.
|
196
|
+
#
|
197
|
+
# Parameters:
|
198
|
+
# list_id (String) = The mailing list ID value.
|
199
|
+
# email (String) = the member email address to get information for
|
200
|
+
# OR the "id" for the member returned from listMemberInfo,
|
201
|
+
# Webhooks, and Campaigns
|
202
|
+
#
|
203
|
+
# Returns:
|
204
|
+
# An array of list member info with the following fields:
|
205
|
+
# id (String) = The unique id for this email address on an account.
|
206
|
+
# email (String) = The email address associated with this record.
|
207
|
+
# email_type (String) = The type of emails this customer asked to get: html, text, or mobile.
|
208
|
+
# merges (Array) = An associative array of all the merge tags and the data for those tags
|
209
|
+
# for this email address. Note: Interest Groups are returned as comma
|
210
|
+
# delimited strings - if a group name contains a comma, it will be escaped
|
211
|
+
# with a backslash. ie, "," => "\,"
|
212
|
+
# status (String) = The subscription status for this email address, either subscribed,
|
213
|
+
# unsubscribed or cleaned.
|
214
|
+
# ip_opt (String) = IP Address this address opted in from.
|
215
|
+
# ip_signup (String) = IP Address this address signed up from.
|
216
|
+
# campaign_id (String) = If the user is unsubscribed and they unsubscribed from a specific campaign,
|
217
|
+
# that campaign_id will be listed, otherwise this is not returned.
|
218
|
+
# list (Array) = An associative array of the other lists this member belongs to - the key is
|
219
|
+
# the list id and the value is their status in that list.
|
220
|
+
# timestamp (Date) = The time this email address was added to the list
|
221
|
+
#
|
222
|
+
call("listMemberInfo", list_id, email)
|
93
223
|
end
|
94
|
-
|
95
|
-
def
|
96
|
-
# Get the
|
97
|
-
|
224
|
+
|
225
|
+
def members(list_id, status = "subscribed", since = "2000-01-01 00:00:00", start = 0, limit = 100)
|
226
|
+
# Get all of the list members for a list that are of a particular status.
|
227
|
+
#
|
228
|
+
# Parameters:
|
229
|
+
# list_id (String) = The mailing list ID value.
|
230
|
+
# status (String) = One of subscribed, unsubscribed, cleaned, updated.
|
231
|
+
# since (Datetime) = Pull all members whose status (subscribed/unsubscribed/cleaned) has changed or whose
|
232
|
+
# profile (updated) has changed since this date/time (in GMT).
|
233
|
+
# start (Integer) = The page number to start at - defaults to 0.
|
234
|
+
# limit (integer) = The number of results to return - defaults to 100, upper limit set at 15000.
|
235
|
+
#
|
236
|
+
# Returns:
|
237
|
+
# An array of list member structs:
|
238
|
+
# email (String) = Member email address.
|
239
|
+
# timestamp (DateTime) = timestamp of their associated status date in GMT.
|
240
|
+
#
|
241
|
+
call("listMembers", list_id, status, since, start, limit)
|
242
|
+
end
|
243
|
+
|
244
|
+
def merge_tags(list_id)
|
245
|
+
# Get the list of merge tags for a given list, including their name, tag, and required setting.
|
246
|
+
#
|
247
|
+
# Parameters:
|
248
|
+
# list_id (String) = The mailing list ID value.
|
249
|
+
#
|
250
|
+
# Returns:
|
251
|
+
# An array of merge tags for this list:
|
252
|
+
# name (String) = Name of the merge field.
|
253
|
+
# req (Char) = Denotes whether the field is required (Y) or not (N).
|
254
|
+
# tag (String) = The merge tag.
|
255
|
+
call("listMergeVars", list_id)
|
98
256
|
end
|
99
257
|
alias :merge_vars :merge_tags
|
100
|
-
|
101
|
-
def
|
102
|
-
#
|
103
|
-
|
258
|
+
|
259
|
+
def segment_test(list_id, options = {})
|
260
|
+
# Allows one to test their segmentation rules before creating a campaign using them.
|
261
|
+
#
|
262
|
+
# Parameters:
|
263
|
+
# list_id (String) = The mailing list ID value.
|
264
|
+
# options (Hash) = Please refer to the Mailchimp API documentation for more information.
|
265
|
+
#
|
266
|
+
# Returns:
|
267
|
+
#
|
268
|
+
#
|
269
|
+
call("campaignSegmentTest", list_id, options)
|
270
|
+
end
|
271
|
+
|
272
|
+
def subscribe(list_id, email, merge_vars = {}, options = {})
|
273
|
+
# Subscribe the provided email to a list.
|
274
|
+
#
|
275
|
+
# Parameters:
|
276
|
+
# list_id (String) = The mailing list ID value.
|
277
|
+
# email (String) = The email address to subscribe.
|
278
|
+
# merge_vars (Hash) = A hash of the merge tags that you want to include.
|
279
|
+
#
|
280
|
+
# Returns:
|
281
|
+
# True on success, false on failure.
|
282
|
+
#
|
283
|
+
merge_tags = clean_merge_tags merge_vars
|
104
284
|
options = apply_defaults_to({:email_type => "html"}.merge(options))
|
105
285
|
call(
|
106
286
|
"listSubscribe",
|
107
|
-
|
287
|
+
list_id,
|
108
288
|
email,
|
109
289
|
merge_tags,
|
110
290
|
*options.values_at(
|
@@ -116,35 +296,109 @@ module Hominid
|
|
116
296
|
)
|
117
297
|
)
|
118
298
|
end
|
119
|
-
|
120
|
-
def subscribe_many(subscribers, options = {})
|
121
|
-
# Subscribe
|
122
|
-
#
|
299
|
+
|
300
|
+
def subscribe_many(list_id, subscribers, options = {})
|
301
|
+
# Subscribe a batch of email addresses to a list at once.
|
302
|
+
#
|
303
|
+
# Parameters:
|
304
|
+
# list_id (String) = The mailing list ID value.
|
305
|
+
# subscribers (Array) = An array of email addresses to subscribe.
|
306
|
+
# merge_vars (Hash) = A hash of subscription options. See the Mailchimp API documentation.
|
307
|
+
#
|
308
|
+
# Returns:
|
309
|
+
# An array of result counts and errors:
|
310
|
+
# success_count (Integer) = Number of email addresses that were succesfully added/updated.
|
311
|
+
# error_count (Integer) = Number of email addresses that failed during addition/updating.
|
312
|
+
# errors (Array) = Array of error structs. Each error struct will contain "code",
|
313
|
+
# "message", and the full struct that failed.
|
314
|
+
#
|
123
315
|
subscribers = subscribers.collect { |subscriber| clean_merge_tags(subscriber) }
|
124
316
|
options = apply_defaults_to({:update_existing => true}.merge(options))
|
125
|
-
call("listBatchSubscribe",
|
317
|
+
call("listBatchSubscribe", list_id, subscribers, *options.values_at(:double_opt_in, :update_existing, :replace_interests))
|
126
318
|
end
|
127
319
|
alias :batch_subscribe :subscribe_many
|
128
|
-
|
129
|
-
def unsubscribe(current_email, options = {})
|
130
|
-
# Unsubscribe
|
320
|
+
|
321
|
+
def unsubscribe(list_id, current_email, options = {})
|
322
|
+
# Unsubscribe the given email address from the list.
|
323
|
+
#
|
324
|
+
# Parameters:
|
325
|
+
# list_id (String) = The mailing list ID value.
|
326
|
+
# current_email (String) = The email address to unsubscribe OR the email "id".
|
327
|
+
# options (Hash) = A hash of unsubscribe options including:
|
328
|
+
# :delete_member (defaults to false)
|
329
|
+
# :send_goodbye (defaults to false)
|
330
|
+
# :send_notify (defaults to false).
|
331
|
+
#
|
332
|
+
# Returns:
|
333
|
+
# True on success, false on failure
|
334
|
+
#
|
131
335
|
options = apply_defaults_to({:delete_member => true}.merge(options))
|
132
|
-
call("listUnsubscribe",
|
336
|
+
call("listUnsubscribe", list_id, current_email, *options.values_at(:delete_member, :send_goodbye, :send_notify))
|
133
337
|
end
|
134
|
-
|
135
|
-
def unsubscribe_many(emails, options = {})
|
136
|
-
# Unsubscribe
|
137
|
-
#
|
338
|
+
|
339
|
+
def unsubscribe_many(list_id, emails, options = {})
|
340
|
+
# Unsubscribe a batch of email addresses to a list.
|
341
|
+
#
|
342
|
+
# Parameters:
|
343
|
+
# list_id (String) = The mailing list ID value.
|
344
|
+
# emails (Array) = An array of email addresses to unsubscribe.
|
345
|
+
# options (Hash) = A hash of unsubscribe options including:
|
346
|
+
# :delete_member (defaults to false)
|
347
|
+
# :send_goodbye (defaults to false)
|
348
|
+
# :send_notify (defaults to false)
|
349
|
+
#
|
350
|
+
# Returns:
|
351
|
+
#
|
138
352
|
options = apply_defaults_to({:delete_member => true}.merge(options))
|
139
|
-
call("listBatchUnsubscribe",
|
353
|
+
call("listBatchUnsubscribe", list_id, emails, *options.values_at(:delete_member, :send_goodbye, :send_notify))
|
140
354
|
end
|
141
355
|
alias :batch_unsubscribe :unsubscribe_many
|
142
|
-
|
143
|
-
def
|
144
|
-
#
|
145
|
-
|
356
|
+
|
357
|
+
def update_group(list_id, old_name, new_name)
|
358
|
+
# Change the name of an Interest Group.
|
359
|
+
#
|
360
|
+
# Parameters:
|
361
|
+
# list_id (String) = The mailing list ID value.
|
362
|
+
# old_name (String) = The interest group name to be changed.
|
363
|
+
# new_name (String) = The new interest group name to be set.
|
364
|
+
#
|
365
|
+
# Returns:
|
366
|
+
# True if successful, error code if not.
|
367
|
+
#
|
368
|
+
call("listInterestGroupUpdate", list_id, old_name, new_name)
|
146
369
|
end
|
147
|
-
|
370
|
+
|
371
|
+
def update_member(list_id, email, merge_tags = {}, email_type = "html", replace_interests = true)
|
372
|
+
# Edit the email address, merge fields, and interest groups for a list member.
|
373
|
+
#
|
374
|
+
# Parameters:
|
375
|
+
# list_id (String) = The mailing list ID value.
|
376
|
+
# email (String) = The current email address of the member to update OR the "id" for the member.
|
377
|
+
# merge_tags (Hash) = Hash of new field values to update the member with.
|
378
|
+
# Ex: {FNAME => 'Bob', :LNAME => 'Smith'}
|
379
|
+
# email_type (String) = One of 'html', 'text', or 'mobile'.
|
380
|
+
# replace_interests (Boolean) = Whether or not to replace the interest groups with the updated groups provided.
|
381
|
+
#
|
382
|
+
# Returns:
|
383
|
+
# True on success, false on failure
|
384
|
+
#
|
385
|
+
call("listUpdateMember", list_id, email, merge_tags, email_type, replace_interests)
|
386
|
+
end
|
387
|
+
|
388
|
+
def webhooks(list_id)
|
389
|
+
# Return the Webhooks configured for the given list.
|
390
|
+
#
|
391
|
+
# Parameters:
|
392
|
+
# list_id (String) = The mailing list ID value.
|
393
|
+
#
|
394
|
+
# Returns:
|
395
|
+
# An array of webhooks for this list including:
|
396
|
+
# url (String) = The URL for this Webhook.
|
397
|
+
# action (Array) = The possible actions and whether they are enabled.
|
398
|
+
# sources (Array) = The possible sources and whether they are enabled.
|
399
|
+
#
|
400
|
+
call("listWebhooks", list_id)
|
401
|
+
end
|
402
|
+
|
148
403
|
end
|
149
|
-
end
|
150
|
-
|
404
|
+
end
|