mailchimp-api 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,13 @@ module Mailchimp
14
14
  @host = 'https://api.mailchimp.com'
15
15
  @path = '/2.0/'
16
16
  @dc = 'us1'
17
+
18
+ unless apikey
19
+ apikey = ENV['MAILCHIMP_APIKEY'] || read_configs
20
+ end
21
+
22
+ raise Error, 'You must provide a MailChimp API key' unless apikey
23
+
17
24
  @apikey = apikey
18
25
  if @apikey.split('-').length == 2
19
26
  @host = "https://#{@apikey.split('-')[1]}.api.mailchimp.com"
@@ -21,17 +28,6 @@ module Mailchimp
21
28
 
22
29
  @session = Excon.new @host
23
30
  @debug = debug
24
-
25
- if not apikey
26
- if ENV['MAILCHIMP_APIKEY']
27
- apikey = ENV['MAILCHIMP_APIKEY']
28
- else
29
- apikey = read_configs
30
- end
31
- end
32
-
33
- raise Error, 'You must provide a MailChimp API key' if not apikey
34
- @apikey = apikey
35
31
  end
36
32
 
37
33
  def call(url, params={})
@@ -143,7 +139,13 @@ module Mailchimp
143
139
  'Invalid_PagingLimit' => InvalidPagingLimitError,
144
140
  'Invalid_PagingStart' => InvalidPagingStartError,
145
141
  'Max_Size_Reached' => MaxSizeReachedError,
146
- 'MC_SearchException' => MCSearchExceptionError
142
+ 'MC_SearchException' => MCSearchExceptionError,
143
+ 'Goal_SaveFailed' => GoalSaveFailedError,
144
+ 'Conversation_DoesNotExist' => ConversationDoesNotExistError,
145
+ 'Conversation_ReplySaveFailed' => ConversationReplySaveFailedError,
146
+ 'File_Not_Found_Exception' => FileNotFoundExceptionError,
147
+ 'Folder_Not_Found_Exception' => FolderNotFoundExceptionError,
148
+ 'Folder_Exists_Exception' => FolderExistsExceptionError
147
149
  }
148
150
 
149
151
  begin
@@ -176,6 +178,9 @@ module Mailchimp
176
178
  def mobile()
177
179
  Mobile.new self
178
180
  end
181
+ def conversations()
182
+ Conversations.new self
183
+ end
179
184
  def ecomm()
180
185
  Ecomm.new self
181
186
  end
@@ -197,6 +202,9 @@ module Mailchimp
197
202
  def gallery()
198
203
  Gallery.new self
199
204
  end
205
+ def goal()
206
+ Goal.new self
207
+ end
200
208
  end
201
209
  end
202
210
 
@@ -97,12 +97,13 @@ module Mailchimp
97
97
  # @param [Hash] types optional the types of templates to return
98
98
  # - [Boolean] user Custom templates for this user account. Defaults to true.
99
99
  # - [Boolean] gallery Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false.
100
- # - [Boolean] base Our "start from scratch" extremely basic templates. Defaults to false.
100
+ # - [Boolean] base Our "start from scratch" extremely basic templates. Defaults to false. As of the 9.0 update, "base" templates are no longer available via the API because they are now all saved Drag & Drop templates.
101
101
  # @param [Hash] filters optional options to control how inactive templates are returned, if at all
102
102
  # - [String] category optional for Gallery templates only, limit to a specific template category
103
103
  # - [String] folder_id user templates, limit to this folder_id
104
104
  # - [Boolean] include_inactive user templates are not deleted, only set inactive. defaults to false.
105
105
  # - [Boolean] inactive_only only include inactive user templates. defaults to false.
106
+ # - [Boolean] include_drag_and_drop Include templates created and saved using the new Drag & Drop editor. <strong>Note:</strong> You will not be able to edit or create new drag & drop templates via this API. This is useful only for creating a new campaign based on a drag & drop template.
106
107
  # @return [Hash] for each type
107
108
  # - [Array] user matching user templates, if requested.
108
109
  # - [Int] id Id of the template
@@ -123,15 +124,7 @@ module Mailchimp
123
124
  # - [String] date_created The date/time the template was created
124
125
  # - [Boolean] active whether or not the template is active and available for use.
125
126
  # - [Boolean] edit_source Whether or not you are able to edit the source of a template.
126
- # - [Array] base matching base templates, if requested.
127
- # - [Int] id Id of the template
128
- # - [String] name Name of the template
129
- # - [String] layout General description of the layout of the template
130
- # - [String] category The category for the template, if there is one.
131
- # - [String] preview_image If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
132
- # - [Boolean] active whether or not the template is active and available for use.
133
- # - [String] date_created The date/time the template was created
134
- # - [Boolean] edit_source Whether or not you are able to edit the source of a template.
127
+ # - [Array] base matching base templates, if requested. (Will always be empty as of 9.0)
135
128
  def list(types=[], filters=[])
136
129
  _params = {:types => types, :filters => filters}
137
130
  return @master.call 'templates/list', _params
@@ -225,6 +218,8 @@ module Mailchimp
225
218
  # - [String] email the email tied to the account used for passwords resets and the ilk
226
219
  # - [String] role the role assigned to the account
227
220
  # - [String] avatar if available, the url for the login's avatar
221
+ # - [Int] global_user_id the globally unique user id for the user account connected to
222
+ # - [String] dc_unique_id the datacenter unique id for the user account connected to, like helper/account-details
228
223
  def logins()
229
224
  _params = {}
230
225
  return @master.call 'users/logins', _params
@@ -238,6 +233,9 @@ module Mailchimp
238
233
  # - [String] email the email tied to the account used for passwords resets and the ilk
239
234
  # - [String] role the role assigned to the account
240
235
  # - [String] avatar if available, the url for the login's avatar
236
+ # - [Int] global_user_id the globally unique user id for the user account connected to
237
+ # - [String] dc_unique_id the datacenter unique id for the user account connected to, like helper/account-details
238
+ # - [String] account_name The name of the account to which the API key belongs
241
239
  def profile()
242
240
  _params = {}
243
241
  return @master.call 'users/profile', _params
@@ -254,7 +252,7 @@ module Mailchimp
254
252
  # Retrieve lots of account information including payments made, plan info, some account stats, installed modules, contact info, and more. No private information like Credit Card numbers is available.
255
253
  # @param [Array] exclude defaults to nothing for backwards compatibility. Allows controlling which extra arrays are returned since they can slow down calls. Valid keys are "modules", "orders", "rewards-credits", "rewards-inspections", "rewards-referrals", "rewards-applied", "integrations". Hint: "rewards-referrals" is typically the culprit. To avoid confusion, if data is excluded, the corresponding key <strong>will not be returned at all</strong>.
256
254
  # @return [Hash] containing the details for the account tied to this API Key
257
- # - [String] username The Account username
255
+ # - [String] username The company name associated with the account
258
256
  # - [String] user_id The Account user unique id (for building some links)
259
257
  # - [Bool] is_trial Whether the Account is in Trial mode (can only send campaigns to less than 100 emails)
260
258
  # - [Bool] is_approved Whether the Account has been approved for purchases
@@ -398,8 +396,8 @@ module Mailchimp
398
396
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
399
397
  # @return [Array] An array of structs with info on the list_id the member is subscribed to.
400
398
  # - [String] id the list unique id
401
- # - [Web_id] the id referenced in web interface urls
402
- # - [Name] the list name
399
+ # - [Int] web_id the id referenced in web interface urls
400
+ # - [String] name the list name
403
401
  def lists_for_email(email)
404
402
  _params = {:email => email}
405
403
  return @master.call 'helper/lists-for-email', _params
@@ -423,7 +421,6 @@ module Mailchimp
423
421
  # - [Array] results matching campaigns and snippets
424
422
  # - [String] snippet the matching snippet for the campaign
425
423
  # - [Hash] campaign the matching campaign's details - will return same data as single campaign from campaigns/list()
426
- # - [Hash] summary if available, the matching campaign's report/summary data, other wise empty
427
424
  def search_campaigns(query, offset=0, snip_start=nil, snip_end=nil)
428
425
  _params = {:query => query, :offset => offset, :snip_start => snip_start, :snip_end => snip_end}
429
426
  return @master.call 'helper/search-campaigns', _params
@@ -434,12 +431,12 @@ module Mailchimp
434
431
  # @param [String] id optional the list id to limit the search to. Get by calling lists/list()
435
432
  # @param [Int] offset optional the paging offset to use if more than 100 records match
436
433
  # @return [Hash] An array of both exact matches and partial matches over a full search
437
- # - [Hash] exact_matches containing the total matches and current results
438
- # - [Int] total total members matching
439
- # - [Array] members each entry will be struct matching the data format for a single member as returned by lists/member-info()
434
+ # - [Hash] exact_matches containing the exact email address matches and current results
435
+ # - [Int] total total members matching
436
+ # - [Array] members each entry will be struct matching the data format for a single member as returned by lists/member-info()
440
437
  # - [Hash] full_search containing the total matches and current results
441
- # - [Int] total total members matching
442
- # - [Array] members each entry will be struct matching the data format for a single member as returned by lists/member-info()
438
+ # - [Int] total total members matching
439
+ # - [Array] members each entry will be struct matching the data format for a single member as returned by lists/member-info()
443
440
  def search_members(query, id=nil, offset=0)
444
441
  _params = {:query => query, :id => id, :offset => offset}
445
442
  return @master.call 'helper/search-members', _params
@@ -463,6 +460,78 @@ module Mailchimp
463
460
  @master = master
464
461
  end
465
462
 
463
+ end
464
+ class Conversations
465
+ attr_accessor :master
466
+
467
+ def initialize(master)
468
+ @master = master
469
+ end
470
+
471
+ # Retrieve conversation metadata, includes message data for the most recent message in the conversation
472
+ # @param [String] list_id optional the list id to connect to. Get by calling lists/list()
473
+ # @param [String] leid optional The member's 'leid', as found by calling lists/member-info()
474
+ # @param [String] campaign_id the campaign id to get content for (can be gathered using campaigns/list())
475
+ # @param [Int] start optional - control paging, start results at this offset, defaults to 0 (1st page of data)
476
+ # @param [Int] limit optional - control paging, number of results to return with each call, defaults to 25 (max=100)
477
+ # @return [Hash] Conversation data and metadata
478
+ # - [Int] count Total number of conversations, irrespective of pagination.
479
+ # - [Array] data An array of structs representing individual conversations
480
+ # - [String] unique_id A string identifying this particular conversation
481
+ # - [Int] message_count The total number of messages in this conversation
482
+ # - [String] campaign_id The unique identifier of the campaign this conversation is associated with
483
+ # - [String] list_id The unique identifier of the list this conversation is associated with
484
+ # - [Int] unread_messages The number of messages in this conversation which have not yet been read.
485
+ # - [String] from_label A label representing the sender of this message.
486
+ # - [String] from_email The email address of the sender of this message.
487
+ # - [String] subject The subject of the message.
488
+ # - [String] timestamp Date the message was either sent or received.
489
+ # - [Hash] last_message The most recent message in the conversation
490
+ # - [String] from_label A label representing the sender of this message.
491
+ # - [String] from_email The email address of the sender of this message.
492
+ # - [String] subject The subject of the message.
493
+ # - [String] message The plain-text content of the message.
494
+ # - [Boolean] read Whether or not this message has been marked as read.
495
+ # - [String] timestamp Date the message was either sent or received.
496
+ def list(list_id=nil, leid=nil, campaign_id=nil, start=0, limit=25)
497
+ _params = {:list_id => list_id, :leid => leid, :campaign_id => campaign_id, :start => start, :limit => limit}
498
+ return @master.call 'conversations/list', _params
499
+ end
500
+
501
+ # Retrieve conversation messages
502
+ # @param [String] conversation_id the unique_id of the conversation to retrieve the messages for, can be obtained by calling converstaions/list().
503
+ # @param [Boolean] mark_as_read optional Whether or not the conversation ought to be marked as read (defaults to false).
504
+ # @param [Int] start optional - control paging, start results at this offset, defaults to 1st page of data (offset 0)
505
+ # @param [Int] limit optional - control paging, number of results to return with each call, defaults to 25 (max=100)
506
+ # @return [Hash] Message data and metadata
507
+ # - [Int] count The number of messages in this conversation, irrespective of paging.
508
+ # - [Array] data An array of structs representing each message in a conversation
509
+ # - [String] from_label A label representing the sender of this message.
510
+ # - [String] from_email The email address of the sender of this message.
511
+ # - [String] subject The subject of the message.
512
+ # - [String] message The plain-text content of the message.
513
+ # - [Boolean] read Whether or not this message has been marked as read.
514
+ # - [String] timestamp Date the message was either sent or received.
515
+ def messages(conversation_id, mark_as_read=false, start=0, limit=25)
516
+ _params = {:conversation_id => conversation_id, :mark_as_read => mark_as_read, :start => start, :limit => limit}
517
+ return @master.call 'conversations/messages', _params
518
+ end
519
+
520
+ # Retrieve conversation messages
521
+ # @param [String] conversation_id the unique_id of the conversation to retrieve the messages for, can be obtained by calling converstaions/list().
522
+ # @param [String] message the text of the message you want to send.
523
+ # @return [Hash] Message data from the created message
524
+ # - [String] from_label A label representing the sender of this message.
525
+ # - [String] from_email The email address of the sender of this message.
526
+ # - [String] subject The subject of the message.
527
+ # - [String] message The plain-text content of the message.
528
+ # - [Boolean] read Whether or not this message has been marked as read.
529
+ # - [String] timestamp Date the message was either sent or received.
530
+ def reply(conversation_id, message)
531
+ _params = {:conversation_id => conversation_id, :message => message}
532
+ return @master.call 'conversations/reply', _params
533
+ end
534
+
466
535
  end
467
536
  class Ecomm
468
537
  attr_accessor :master
@@ -488,8 +557,8 @@ module Mailchimp
488
557
  # - [Int] product_id the store's internal Id for the product. Lines that do no contain this will be skipped
489
558
  # - [String] sku optional the store's internal SKU for the product. (max 30 bytes)
490
559
  # - [String] product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
491
- # - [Int] category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
492
- # - [String] category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
560
+ # - [Int] category_id (required) the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
561
+ # - [String] category_name (required) the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
493
562
  # - [Double] qty optional the quantity of the item ordered - defaults to 1
494
563
  # - [Double] cost optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
495
564
  # @return [Hash] with a single entry:
@@ -629,7 +698,6 @@ module Mailchimp
629
698
  # @return [Array] Array of structs containing results and any errors that occurred
630
699
  # - [Int] success_count Number of email addresses that were successfully removed
631
700
  # - [Int] error_count Number of email addresses that failed during addition/updating
632
- # - [Array] of structs contain error details including:
633
701
  # - [Array] errors array of error structs including:
634
702
  # - [String] email whatever was passed in the batch record's email parameter
635
703
  # - [String] email the email address added
@@ -1012,7 +1080,17 @@ module Mailchimp
1012
1080
  # @param [String] id the list id to connect to. Get by calling lists/list()
1013
1081
  # @param [String] type optional, if specified should be "static" or "saved" and will limit the returned entries to that type
1014
1082
  # @return [Hash] with 2 keys:
1015
- # - [Int] static.id the id of the segment
1083
+ # - [Array] static of structs with data for each segment
1084
+ # - [Int] id the id of the segment
1085
+ # - [String] name the name for the segment
1086
+ # - [String] created_date the date+time the segment was created
1087
+ # - [String] last_update the date+time the segment was last updated (add or del)
1088
+ # - [String] last_reset the date+time the segment was last reset (ie had all members cleared from it)
1089
+ # - [Array] saved of structs with data for each segment
1090
+ # - [Int] id the id of the segment
1091
+ # - [String] name the name for the segment
1092
+ # - [String] segment_opts same match+conditions struct typically used
1093
+ # - [String] segment_text a textual description of the segment match/conditions
1016
1094
  # - [String] created_date the date+time the segment was created
1017
1095
  # - [String] last_update the date+time the segment was last updated (add or del)
1018
1096
  def segments(id, type=nil)
@@ -1047,10 +1125,7 @@ module Mailchimp
1047
1125
 
1048
1126
  # Allows one to test their segmentation rules before creating a campaign using them - this is no different from campaigns/segment-test() and will eventually replace it. For the time being, the crazy segmenting condition documentation will continue to live over there.
1049
1127
  # @param [String] list_id the list to test segmentation on - get lists using lists/list()
1050
- # @param [Hash] options with 1 or 2 keys:
1051
- # - [String] saved_segment_id a saved segment id from lists/segments() - this will take precendence, otherwise the match+conditions are required.
1052
- # - [String] match controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
1053
- # - [Array] conditions of up to 5 structs for different criteria to apply while segmenting. Each criteria row must contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", and "<strong>value</strong>" - and possibly a fourth, "<strong>extra</strong>", based on these definitions:
1128
+ # @param [Hash] options See the campaigns/segment-test() call for details.
1054
1129
  # @return [Hash] with a single entry:
1055
1130
  # - [Int] total The total number of subscribers matching your segmentation options
1056
1131
  def segment_test(list_id, options)
@@ -1064,7 +1139,7 @@ module Mailchimp
1064
1139
  # @param [Hash] opts various options to update
1065
1140
  # - [String] name a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
1066
1141
  # - [Hash] segment_opts for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
1067
- # - [Hash] match "any" or "all"
1142
+ # - [String] match "any" or "all"
1068
1143
  # - [Array] conditions structs for each condition, just like campaigns/segment-test
1069
1144
  # @return [Hash] with a single entry:
1070
1145
  # - [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
@@ -1148,6 +1223,9 @@ module Mailchimp
1148
1223
 
1149
1224
  # Retrieve all of the Static Segments for a list.
1150
1225
  # @param [String] id the list id to connect to. Get by calling lists/list()
1226
+ # @param [Boolean] get_counts optional Retreiving counts for static segments can be slow, leaving them out can speed up this call. Defaults to 'true'.
1227
+ # @param [Int] start optional - control paging, start results at this offset, defaults to 1st page of data (offset 0)
1228
+ # @param [Int] limit optional - control paging, number of results to return with each call, returns all by default
1151
1229
  # @return [Array] an of structs with data for each static segment
1152
1230
  # - [Int] id the id of the segment
1153
1231
  # - [String] name the name for the segment
@@ -1155,19 +1233,19 @@ module Mailchimp
1155
1233
  # - [String] created_date the date+time the segment was created
1156
1234
  # - [String] last_update the date+time the segment was last updated (add or del)
1157
1235
  # - [String] last_reset the date+time the segment was last reset (ie had all members cleared from it)
1158
- def static_segments(id)
1159
- _params = {:id => id}
1236
+ def static_segments(id, get_counts=true, start=0, limit=nil)
1237
+ _params = {:id => id, :get_counts => get_counts, :start => start, :limit => limit}
1160
1238
  return @master.call 'lists/static-segments', _params
1161
1239
  end
1162
1240
 
1163
1241
  # Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
1164
1242
  # @param [String] id the list id to connect to. Get by calling lists/list()
1165
- # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Providing multiples and will use the first we see in this same order.
1243
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
1166
1244
  # - [String] email an email address - for new subscribers obviously this should be used
1167
1245
  # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
1168
1246
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
1169
- # @param [Hash] merge_vars optional merges for the email (FNAME, LNAME, <a href="http://kb.mailchimp.com/article/where-can-i-find-my-lists-merge-tags target="_blank">etc.</a>) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 bytes. Also, there are a few "special" keys:
1170
- # - [String] new-email set this to change the email address. This is only respected on calls using update_existing or when passed to listUpdateMember().
1247
+ # @param [Hash] merge_vars optional merges for the email (FNAME, LNAME, <a href="http://kb.mailchimp.com/article/where-can-i-find-my-lists-merge-tags" target="_blank">etc.</a>) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 bytes. Also, there are a few "special" keys:
1248
+ # - [String] new-email set this to change the email address. This is only respected on calls using update_existing or when passed to lists/update.
1171
1249
  # - [Array] groupings of Interest Grouping structs. Each should contain:
1172
1250
  # - [Int] id Grouping "id" from lists/interest-groupings (either this or name must be present) - this id takes precedence and can't change (unlike the name)
1173
1251
  # - [String] name Grouping "name" from lists/interest-groupings (either this or id must be present)
@@ -1199,7 +1277,7 @@ module Mailchimp
1199
1277
 
1200
1278
  # Unsubscribe the given email address from the list
1201
1279
  # @param [String] id the list id to connect to. Get by calling lists/list()
1202
- # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Providing multiples and will use the first we see in this same order.
1280
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
1203
1281
  # - [String] email an email address
1204
1282
  # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
1205
1283
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
@@ -1215,7 +1293,7 @@ module Mailchimp
1215
1293
 
1216
1294
  # Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users, consider using lists/batch-subscribe() with the update_existing and possible replace_interests parameter.
1217
1295
  # @param [String] id the list id to connect to. Get by calling lists/list()
1218
- # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Providing multiples and will use the first we see in this same order.
1296
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
1219
1297
  # - [String] email an email address
1220
1298
  # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
1221
1299
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
@@ -1334,7 +1412,7 @@ module Mailchimp
1334
1412
  # - [Array] errors structs of any errors found while loading lists - usually just from providing invalid list ids
1335
1413
  # - [String] param the data that caused the failure
1336
1414
  # - [Int] code the error code
1337
- # - [Int] error the error message
1415
+ # - [String] error the error message
1338
1416
  def list(filters=[], start=0, limit=25, sort_field='created', sort_dir='DESC')
1339
1417
  _params = {:filters => filters, :start => start, :limit => limit, :sort_field => sort_field, :sort_dir => sort_dir}
1340
1418
  return @master.call 'lists/list', _params
@@ -1352,7 +1430,7 @@ module Mailchimp
1352
1430
  # @param [String] cid the campaign id to get content for (can be gathered using campaigns/list())
1353
1431
  # @param [Hash] options various options to control this call
1354
1432
  # - [String] view optional one of "archive" (default), "preview" (like our popup-preview) or "raw"
1355
- # - [Hash] email optional if provided, view is "archive" or "preview", the campaign's list still exists, and the requested record is subscribed to the list. the returned content will be populated with member data populated. a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Providing multiples and will use the first we see in this same order.
1433
+ # - [Hash] email optional if provided, view is "archive" or "preview", the campaign's list still exists, and the requested record is subscribed to the list. the returned content will be populated with member data populated. a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
1356
1434
  # - [String] email an email address
1357
1435
  # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
1358
1436
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
@@ -1385,7 +1463,7 @@ module Mailchimp
1385
1463
  # - [Hash] analytics optional - one or more of these keys set to the tag to use - that can be any custom text (up to 50 bytes)
1386
1464
  # - [String] google for Google Analytics tracking
1387
1465
  # - [String] clicktale for ClickTale tracking
1388
- # - [String] gooal for Goo.al tracking
1466
+ # - [String] gooal for Goal tracking (the extra 'o' in the param name is not a typo)
1389
1467
  # - [Boolean] auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
1390
1468
  # - [Boolean] inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
1391
1469
  # - [Boolean] generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
@@ -1522,9 +1600,10 @@ module Mailchimp
1522
1600
  # - [Boolean] auto_footer Whether or not the auto_footer was manually turned on
1523
1601
  # - [Boolean] timewarp Whether or not the campaign used Timewarp
1524
1602
  # - [String] timewarp_schedule The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
1525
- # - [String] parent_id the unique id of the parent campaign (currently only valid for rss children)
1603
+ # - [String] parent_id the unique id of the parent campaign (currently only valid for rss children). Will be blank for non-rss child campaigns or parent campaign has been deleted.
1604
+ # - [Boolean] is_child true if this is an RSS child campaign. Will return true even if the parent campaign has been deleted.
1526
1605
  # - [String] tests_sent tests sent
1527
- # - [String] tests_remain test sends remaining
1606
+ # - [Int] tests_remain test sends remaining
1528
1607
  # - [Hash] tracking the various tracking options used
1529
1608
  # - [Boolean] html_clicks whether or not tracking for html clicks was enabled.
1530
1609
  # - [Boolean] text_clicks whether or not tracking for text clicks was enabled.
@@ -1532,9 +1611,9 @@ module Mailchimp
1532
1611
  # - [String] segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
1533
1612
  # - [Array] segment_opts the segment used for the campaign - can be passed to campaigns/segment-test or campaigns/create()
1534
1613
  # - [Hash] saved_segment if a saved segment was used (match+conditions returned above):
1535
- # - [Hash] id the saved segment id
1536
- # - [Hash] type the saved segment type
1537
- # - [Hash] name the saved segment name
1614
+ # - [Int] id the saved segment id
1615
+ # - [String] type the saved segment type
1616
+ # - [String] name the saved segment name
1538
1617
  # - [Hash] type_opts the type-specific options for the campaign - can be passed to campaigns/create()
1539
1618
  # - [Int] comments_total total number of comments left on this campaign
1540
1619
  # - [Int] comments_unread total number of unread comments for this campaign based on the login the apikey belongs to
@@ -1543,7 +1622,7 @@ module Mailchimp
1543
1622
  # - [String] filter the filter that caused the failure
1544
1623
  # - [String] value the filter value that caused the failure
1545
1624
  # - [Int] code the error code
1546
- # - [Int] error the error message
1625
+ # - [String] error the error message
1547
1626
  def list(filters=[], start=0, limit=25, sort_field='create_time', sort_dir='DESC')
1548
1627
  _params = {:filters => filters, :start => start, :limit => limit, :sort_field => sort_field, :sort_dir => sort_dir}
1549
1628
  return @master.call 'campaigns/list', _params
@@ -1580,7 +1659,7 @@ module Mailchimp
1580
1659
  end
1581
1660
 
1582
1661
  # Resume sending an AutoResponder or RSS campaign
1583
- # @param [String] cid the id of the campaign to pause
1662
+ # @param [String] cid the id of the campaign to resume
1584
1663
  # @return [Hash] with a single entry:
1585
1664
  # - [Bool] complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
1586
1665
  def resume(cid)
@@ -1611,7 +1690,7 @@ module Mailchimp
1611
1690
  return @master.call 'campaigns/schedule-batch', _params
1612
1691
  end
1613
1692
 
1614
- # Allows one to test their segmentation rules before creating a campaign using them
1693
+ # Allows one to test their segmentation rules before creating a campaign using them.
1615
1694
  # @param [String] list_id the list to test segmentation on - get lists using lists/list()
1616
1695
  # @param [Hash] options with 1 or 2 keys:
1617
1696
  # - [String] saved_segment_id a saved segment id from lists/segments() - this will take precendence, otherwise the match+conditions are required.
@@ -1814,7 +1893,7 @@ module Mailchimp
1814
1893
 
1815
1894
  # Retrieve the most recent full bounce message for a specific email address on the given campaign. Messages over 30 days old are subject to being removed
1816
1895
  # @param [String] cid the campaign id to pull bounces for (can be gathered using campaigns/list())
1817
- # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Providing multiples and will use the first we see in this same order.
1896
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
1818
1897
  # - [String] email an email address - this is recommended for this method
1819
1898
  # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
1820
1899
  # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
@@ -1900,23 +1979,23 @@ module Mailchimp
1900
1979
  # @return [Hash] the total matching orders and the specific orders for the requested page
1901
1980
  # - [Int] total the total matching orders
1902
1981
  # - [Array] data structs for the actual data for each order being returned
1903
- # - [String] store_id the store id generated by the plugin used to uniquely identify a store
1904
- # - [String] store_name the store name collected by the plugin - often the domain name
1905
- # - [String] order_id the internal order id the store tracked this order by
1906
- # - [Hash] member the member record as returned by lists/member-info() that received this campaign and is associated with this order
1907
- # - [Double] order_total the order total
1908
- # - [Double] tax_total the total tax for the order (if collected)
1909
- # - [Double] ship_total the shipping total for the order (if collected)
1910
- # - [String] order_date the date the order was tracked - from the store if possible, otherwise the GMT time we received it
1911
- # - [Array] lines structs containing details of the order:
1912
- # - [Int] line_num the line number assigned to this line
1913
- # - [Int] product_id the product id assigned to this item
1914
- # - [String] product_name the product name
1915
- # - [String] product_sku the sku for the product
1916
- # - [Int] product_category_id the id for the product category
1917
- # - [String] product_category_name the product category name
1918
- # - [Double] qty optional the quantity of the item ordered - defaults to 1
1919
- # - [Double] cost optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
1982
+ # - [String] store_id the store id generated by the plugin used to uniquely identify a store
1983
+ # - [String] store_name the store name collected by the plugin - often the domain name
1984
+ # - [String] order_id the internal order id the store tracked this order by
1985
+ # - [Hash] member the member record as returned by lists/member-info() that received this campaign and is associated with this order
1986
+ # - [Double] order_total the order total
1987
+ # - [Double] tax_total the total tax for the order (if collected)
1988
+ # - [Double] ship_total the shipping total for the order (if collected)
1989
+ # - [String] order_date the date the order was tracked - from the store if possible, otherwise the GMT time we received it
1990
+ # - [Array] lines structs containing details of the order:
1991
+ # - [Int] line_num the line number assigned to this line
1992
+ # - [Int] product_id the product id assigned to this item
1993
+ # - [String] product_name the product name
1994
+ # - [String] product_sku the sku for the product
1995
+ # - [Int] product_category_id the id for the product category
1996
+ # - [String] product_category_name the product category name
1997
+ # - [Double] qty optional the quantity of the item ordered - defaults to 1
1998
+ # - [Double] cost optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
1920
1999
  def ecomm_orders(cid, opts=[])
1921
2000
  _params = {:cid => cid, :opts => opts}
1922
2001
  return @master.call 'reports/ecomm-orders', _params
@@ -2207,9 +2286,11 @@ module Mailchimp
2207
2286
  # - [String] sort_by optional field to sort by - one of size, time, name - defaults to time
2208
2287
  # - [String] sort_dir optional field to sort by - one of asc, desc - defaults to desc
2209
2288
  # - [String] search_term optional a term to search for in names
2289
+ # - [Int] folder_id optional to return files that are in a specific folder. id returned by the list-folders call
2210
2290
  # @return [Hash] the matching gallery items
2211
2291
  # - [Int] total the total matching items
2212
2292
  # - [Array] data structs for each item included in the set, including:
2293
+ # - [Int] id the id of the file
2213
2294
  # - [String] name the file name
2214
2295
  # - [String] time the creation date for the item
2215
2296
  # - [Int] size the file size in bytes
@@ -2220,6 +2301,107 @@ module Mailchimp
2220
2301
  return @master.call 'gallery/list', _params
2221
2302
  end
2222
2303
 
2304
+ # Return a list of the folders available to the file gallery
2305
+ # @param [Hash] opts various options for controlling returned data
2306
+ # - [Int] start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
2307
+ # - [Int] limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
2308
+ # - [String] search_term optional a term to search for in names
2309
+ # @return [Hash] the matching gallery folders
2310
+ # - [Int] total the total matching folders
2311
+ # - [Array] data structs for each folder included in the set, including:
2312
+ # - [Int] id the id of the folder
2313
+ # - [String] name the file name
2314
+ # - [Int] file_count the number of files in the folder
2315
+ def list_folders(opts=[])
2316
+ _params = {:opts => opts}
2317
+ return @master.call 'gallery/list-folders', _params
2318
+ end
2319
+
2320
+ # Adds a folder to the file gallery
2321
+ # @param [String] name the name of the folder to add (255 character max)
2322
+ # @return [Hash] the new data for the created folder
2323
+ # - [Int] data.id the id of the new folder
2324
+ def add_folder(name)
2325
+ _params = {:name => name}
2326
+ return @master.call 'gallery/add-folder', _params
2327
+ end
2328
+
2329
+ # Remove a folder
2330
+ # @param [Int] folder_id the id of the folder to remove, as returned by the listFolders call
2331
+ # @return [Boolean] true/false for success/failure
2332
+ def remove_folder(folder_id)
2333
+ _params = {:folder_id => folder_id}
2334
+ return @master.call 'gallery/remove-folder', _params
2335
+ end
2336
+
2337
+ # Add a file to a folder
2338
+ # @param [Int] file_id the id of the file you want to add to a folder, as returned by the list call
2339
+ # @param [Int] folder_id the id of the folder to add the file to, as returned by the listFolders call
2340
+ # @return [Boolean] true/false for success/failure
2341
+ def add_file_to_folder(file_id, folder_id)
2342
+ _params = {:file_id => file_id, :folder_id => folder_id}
2343
+ return @master.call 'gallery/add-file-to-folder', _params
2344
+ end
2345
+
2346
+ # Remove a file from a folder
2347
+ # @param [Int] file_id the id of the file you want to remove from the folder, as returned by the list call
2348
+ # @param [Int] folder_id the id of the folder to remove the file from, as returned by the listFolders call
2349
+ # @return [Boolean] true/false for success/failure
2350
+ def remove_file_from_folder(file_id, folder_id)
2351
+ _params = {:file_id => file_id, :folder_id => folder_id}
2352
+ return @master.call 'gallery/remove-file-from-folder', _params
2353
+ end
2354
+
2355
+ # Remove all files from a folder (Note that the files are not deleted, they are only removed from the folder)
2356
+ # @param [Int] folder_id the id of the folder to remove the file from, as returned by the listFolders call
2357
+ # @return [Boolean] true/false for success/failure
2358
+ def remove_all_files_from_folder(folder_id)
2359
+ _params = {:folder_id => folder_id}
2360
+ return @master.call 'gallery/remove-all-files-from-folder', _params
2361
+ end
2362
+
2363
+ end
2364
+ class Goal
2365
+ attr_accessor :master
2366
+
2367
+ def initialize(master)
2368
+ @master = master
2369
+ end
2370
+
2371
+ # Retrieve goal event data for a particular list member. Note: only unique events are returned. If a user triggers a particular event multiple times, you will still only receive one entry for that event.
2372
+ # @param [String] list_id the list id to connect to. Get by calling lists/list()
2373
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
2374
+ # - [String] email an email address
2375
+ # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
2376
+ # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
2377
+ # @param [Int] start optional - control paging of lists, start results at this list #, defaults to 1st page of data (page 0)
2378
+ # @param [Int] limit optional - control paging of lists, number of lists to return with each call, defaults to 25 (max=100)
2379
+ # @return [Hash] Event data and metadata
2380
+ # - [Array] data An array of goal data structs for the specified list member in the following format
2381
+ # - [String] event The URL or name of the event that was triggered
2382
+ # - [String] last_visited_at A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
2383
+ # - [Int] total The total number of events that match your criteria.
2384
+ def events(list_id, email, start=0, limit=25)
2385
+ _params = {:list_id => list_id, :email => email, :start => start, :limit => limit}
2386
+ return @master.call 'goal/events', _params
2387
+ end
2388
+
2389
+ # This allows programmatically trigger goal event collection without the use of front-end code.
2390
+ # @param [String] list_id the list id to connect to. Get by calling lists/list()
2391
+ # @param [Hash] email a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
2392
+ # - [String] email an email address
2393
+ # - [String] euid the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
2394
+ # - [String] leid the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
2395
+ # @param [String] campaign_id the campaign id to get content for (can be gathered using campaigns/list())
2396
+ # @param [String] event The name of the event or the URL visited
2397
+ # @return [Hash] Event data for the submitted event
2398
+ # - [String] event The URL or name of the event that was triggered
2399
+ # - [String] last_visited_at A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
2400
+ def record_event(list_id, email, campaign_id, event)
2401
+ _params = {:list_id => list_id, :email => email, :campaign_id => campaign_id, :event => event}
2402
+ return @master.call 'goal/record-event', _params
2403
+ end
2404
+
2223
2405
  end
2224
2406
  end
2225
2407
 
@@ -175,5 +175,17 @@ module Mailchimp
175
175
  end
176
176
  class MCSearchExceptionError < Error
177
177
  end
178
+ class GoalSaveFailedError < Error
179
+ end
180
+ class ConversationDoesNotExistError < Error
181
+ end
182
+ class ConversationReplySaveFailedError < Error
183
+ end
184
+ class FileNotFoundExceptionError < Error
185
+ end
186
+ class FolderNotFoundExceptionError < Error
187
+ end
188
+ class FolderExistsExceptionError < Error
189
+ end
178
190
  end
179
191
 
metadata CHANGED
@@ -1,98 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mailchimp-api
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.5
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 0
9
- - 4
10
- version: 2.0.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - MailChimp Devs
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-10-17 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2014-06-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 5
29
- segments:
30
- - 1
31
- - 7
32
- - 7
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.7.7
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: excon
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.7
30
+ - !ruby/object:Gem::Dependency
31
+ name: excon
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 95
45
- segments:
46
- - 0
47
- - 16
48
- - 0
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
49
37
  version: 0.16.0
50
38
  type: :runtime
51
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.16.0
52
46
  description: A Ruby API library for the MailChimp email platform
53
47
  email: api@mailchimp.com
54
48
  executables: []
55
-
56
49
  extensions: []
57
-
58
50
  extra_rdoc_files: []
59
-
60
- files:
51
+ files:
61
52
  - lib/mailchimp.rb
62
53
  - lib/mailchimp/api.rb
63
54
  - lib/mailchimp/errors.rb
64
55
  homepage: https://bitbucket.org/mailchimp/mailchimp-api-ruby/
65
56
  licenses: []
66
-
67
57
  post_install_message:
68
58
  rdoc_options: []
69
-
70
- require_paths:
59
+ require_paths:
71
60
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
61
+ required_ruby_version: !ruby/object:Gem::Requirement
73
62
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
68
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
90
73
  requirements: []
91
-
92
74
  rubyforge_project:
93
- rubygems_version: 1.8.15
75
+ rubygems_version: 1.8.25
94
76
  signing_key:
95
77
  specification_version: 3
96
78
  summary: A Ruby API library for the MailChimp email platform.
97
79
  test_files: []
98
-