Class: Mailchimp::Lists
- Inherits:
-
Object
- Object
- Mailchimp::Lists
- Defined in:
- lib/mailchimp/api.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
Returns the value of attribute master.
Instance Method Summary collapse
-
#abuse_reports(id, start = 0, limit = 500, since = nil) ⇒ Hash
Get all email addresses that complained about a campaign sent to a list.
-
#activity(id) ⇒ Array
Access up to the previous 180 days of daily detailed aggregated activity stats for a given list.
-
#batch_subscribe(id, batch, double_optin = true, update_existing = false, replace_interests = true) ⇒ Hash
Subscribe a batch of email addresses to a list at once.
-
#batch_unsubscribe(id, batch, delete_member = false, send_goodbye = true, send_notify = false) ⇒ Array
Unsubscribe a batch of email addresses from a list.
-
#clients(id) ⇒ Hash
Retrieve the clients that the list’s subscribers have been tagged as being used based on user agents seen.
-
#growth_history(id = nil) ⇒ Array
Access the Growth History by Month in aggregate or for a given list.
-
#initialize(master) ⇒ Lists
constructor
A new instance of Lists.
-
#interest_group_add(id, group_name, grouping_id = nil) ⇒ Hash
Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first group will automatically turn them on.
-
#interest_group_del(id, group_name, grouping_id = nil) ⇒ Hash
Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
-
#interest_group_update(id, old_name, new_name, grouping_id = nil) ⇒ Hash
Change the name of an Interest Group.
-
#interest_grouping_add(id, name, type, groups) ⇒ Hash
Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first grouping will automatically turn them on.
-
#interest_grouping_del(grouping_id) ⇒ Hash
Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members.
-
#interest_grouping_update(grouping_id, name, value) ⇒ Hash
Update an existing Interest Grouping.
-
#interest_groupings(id, counts = false) ⇒ Array
Get the list of interest groupings for a given list, including the label, form information, and included groups for each.
-
#list(filters = [], start = 0, limit = 25, sort_field = 'created', sort_dir = 'DESC') ⇒ Hash
Retrieve all of the lists defined for your user account.
-
#locations(id) ⇒ Array
Retrieve the locations (countries) that the list’s subscribers have been tagged to based on geocoding their IP address.
-
#member_activity(id, emails) ⇒ Hash
Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to, etc.).
-
#member_info(id, emails) ⇒ Hash
Get all the information for particular members of a list.
-
#members(id, status = 'subscribed', opts = []) ⇒ Hash
Get all of the list members for a list that are of a particular status and potentially matching a segment.
-
#merge_var_add(id, tag, name, options = []) ⇒ Hash
Add a new merge tag to a given list.
-
#merge_var_del(id, tag) ⇒ Hash
Delete a merge tag from a given list and all its members.
-
#merge_var_reset(id, tag) ⇒ Hash
Completely resets all data stored in a merge var on a list.
-
#merge_var_set(id, tag, value) ⇒ Hash
Sets a particular merge var to the specified value for every list member.
-
#merge_var_update(id, tag, options) ⇒ Hash
Update most parameters for a merge tag on a given list.
-
#merge_vars(id) ⇒ Hash
Get the list of merge tags for a given list, including their name, tag, and required setting.
-
#static_segment_add(id, name) ⇒ Hash
Save a segment against a list for later use.
-
#static_segment_del(id, seg_id) ⇒ Hash
Delete a static segment.
-
#static_segment_members_add(id, seg_id, batch) ⇒ Hash
Add list members to a static segment.
-
#static_segment_members_del(id, seg_id, batch) ⇒ Hash
Remove list members from a static segment.
-
#static_segment_reset(id, seg_id) ⇒ Hash
Resets a static segment - removes <strong>all</strong> members from the static segment.
-
#static_segments(id) ⇒ Array
Retrieve all of the Static Segments for a list.
-
#subscribe(id, email, merge_vars = nil, email_type = 'html', double_optin = true, update_existing = false, replace_interests = true, send_welcome = false) ⇒ Hash
Subscribe the provided email to a list.
-
#unsubscribe(id, email, delete_member = false, send_goodbye = true, send_notify = true) ⇒ Hash
Unsubscribe the given email address from the list.
-
#update_member(id, email, merge_vars, email_type = '', replace_interests = true) ⇒ Hash
Edit the email address, merge fields, and interest groups for a list member.
-
#webhook_add(id, url, actions = [], sources = []) ⇒ Hash
Add a new Webhook URL for the given list.
-
#webhook_del(id, url) ⇒ Hash
Delete an existing Webhook URL from a given list.
-
#webhooks(id) ⇒ Array
Return the Webhooks configured for the given list.
Constructor Details
#initialize(master) ⇒ Lists
Returns a new instance of Lists.
541 542 543 |
# File 'lib/mailchimp/api.rb', line 541 def initialize(master) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
539 540 541 |
# File 'lib/mailchimp/api.rb', line 539 def master @master end |
Instance Method Details
#abuse_reports(id, start = 0, limit = 500, since = nil) ⇒ Hash
Get all email addresses that complained about a campaign sent to a list
557 558 559 560 |
# File 'lib/mailchimp/api.rb', line 557 def abuse_reports(id, start=0, limit=500, since=nil) _params = {:id => id, :start => start, :limit => limit, :since => since} return @master.call 'lists/abuse-reports', _params end |
#activity(id) ⇒ Array
Access up to the previous 180 days of daily detailed aggregated activity stats for a given list. Does not include AutoResponder activity.
565 566 567 568 |
# File 'lib/mailchimp/api.rb', line 565 def activity(id) _params = {:id => id} return @master.call 'lists/activity', _params end |
#batch_subscribe(id, batch, double_optin = true, update_existing = false, replace_interests = true) ⇒ Hash
Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you only run this method as a POST request, and not a GET request. Maximum batch sizes vary based on the amount of data in each record, though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
602 603 604 605 |
# File 'lib/mailchimp/api.rb', line 602 def batch_subscribe(id, batch, double_optin=true, update_existing=false, replace_interests=true) _params = {:id => id, :batch => batch, :double_optin => double_optin, :update_existing => update_existing, :replace_interests => replace_interests} return @master.call 'lists/batch-subscribe', _params end |
#batch_unsubscribe(id, batch, delete_member = false, send_goodbye = true, send_notify = false) ⇒ Array
Unsubscribe a batch of email addresses from a list
627 628 629 630 |
# File 'lib/mailchimp/api.rb', line 627 def batch_unsubscribe(id, batch, delete_member=false, send_goodbye=true, send_notify=false) _params = {:id => id, :batch => batch, :delete_member => delete_member, :send_goodbye => send_goodbye, :send_notify => send_notify} return @master.call 'lists/batch-unsubscribe', _params end |
#clients(id) ⇒ Hash
Retrieve the clients that the list’s subscribers have been tagged as being used based on user agents seen. Made possible by <a href=“user-agent-string.info” target=“_blank”>user-agent-string.info</a>
649 650 651 652 |
# File 'lib/mailchimp/api.rb', line 649 def clients(id) _params = {:id => id} return @master.call 'lists/clients', _params end |
#growth_history(id = nil) ⇒ Array
Access the Growth History by Month in aggregate or for a given list.
661 662 663 664 |
# File 'lib/mailchimp/api.rb', line 661 def growth_history(id=nil) _params = {:id => id} return @master.call 'lists/growth-history', _params end |
#interest_group_add(id, group_name, grouping_id = nil) ⇒ Hash
Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first group will automatically turn them on.
689 690 691 692 |
# File 'lib/mailchimp/api.rb', line 689 def interest_group_add(id, group_name, grouping_id=nil) _params = {:id => id, :group_name => group_name, :grouping_id => grouping_id} return @master.call 'lists/interest-group-add', _params end |
#interest_group_del(id, group_name, grouping_id = nil) ⇒ Hash
Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
700 701 702 703 |
# File 'lib/mailchimp/api.rb', line 700 def interest_group_del(id, group_name, grouping_id=nil) _params = {:id => id, :group_name => group_name, :grouping_id => grouping_id} return @master.call 'lists/interest-group-del', _params end |
#interest_group_update(id, old_name, new_name, grouping_id = nil) ⇒ Hash
Change the name of an Interest Group
712 713 714 715 |
# File 'lib/mailchimp/api.rb', line 712 def interest_group_update(id, old_name, new_name, grouping_id=nil) _params = {:id => id, :old_name => old_name, :new_name => new_name, :grouping_id => grouping_id} return @master.call 'lists/interest-group-update', _params end |
#interest_grouping_add(id, name, type, groups) ⇒ Hash
Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first grouping will automatically turn them on.
724 725 726 727 |
# File 'lib/mailchimp/api.rb', line 724 def interest_grouping_add(id, name, type, groups) _params = {:id => id, :name => name, :type => type, :groups => groups} return @master.call 'lists/interest-grouping-add', _params end |
#interest_grouping_del(grouping_id) ⇒ Hash
Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
733 734 735 736 |
# File 'lib/mailchimp/api.rb', line 733 def interest_grouping_del(grouping_id) _params = {:grouping_id => grouping_id} return @master.call 'lists/interest-grouping-del', _params end |
#interest_grouping_update(grouping_id, name, value) ⇒ Hash
Update an existing Interest Grouping
744 745 746 747 |
# File 'lib/mailchimp/api.rb', line 744 def interest_grouping_update(grouping_id, name, value) _params = {:grouping_id => grouping_id, :name => name, :value => value} return @master.call 'lists/interest-grouping-update', _params end |
#interest_groupings(id, counts = false) ⇒ Array
Get the list of interest groupings for a given list, including the label, form information, and included groups for each
678 679 680 681 |
# File 'lib/mailchimp/api.rb', line 678 def interest_groupings(id, counts=false) _params = {:id => id, :counts => counts} return @master.call 'lists/interest-groupings', _params end |
#list(filters = [], start = 0, limit = 25, sort_field = 'created', sort_dir = 'DESC') ⇒ Hash
Retrieve all of the lists defined for your user account
1262 1263 1264 1265 |
# File 'lib/mailchimp/api.rb', line 1262 def list(filters=[], start=0, limit=25, sort_field='created', sort_dir='DESC') _params = {:filters => filters, :start => start, :limit => limit, :sort_field => sort_field, :sort_dir => sort_dir} return @master.call 'lists/list', _params end |
#locations(id) ⇒ Array
Retrieve the locations (countries) that the list’s subscribers have been tagged to based on geocoding their IP address
756 757 758 759 |
# File 'lib/mailchimp/api.rb', line 756 def locations(id) _params = {:id => id} return @master.call 'lists/locations', _params end |
#member_activity(id, emails) ⇒ Hash
Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to, etc.)
789 790 791 792 |
# File 'lib/mailchimp/api.rb', line 789 def member_activity(id, emails) _params = {:id => id, :emails => emails} return @master.call 'lists/member-activity', _params end |
#member_info(id, emails) ⇒ Hash
Get all the information for particular members of a list
859 860 861 862 |
# File 'lib/mailchimp/api.rb', line 859 def member_info(id, emails) _params = {:id => id, :emails => emails} return @master.call 'lists/member-info', _params end |
#members(id, status = 'subscribed', opts = []) ⇒ Hash
Get all of the list members for a list that are of a particular status and potentially matching a segment. This will cause locking, so don’t run multiples at once. Are you trying to get a dump including lots of merge data or specific members of a list? If so, checkout the <a href=“export/1.0/list.func.php”>List Export API</a>
876 877 878 879 |
# File 'lib/mailchimp/api.rb', line 876 def members(id, status='subscribed', opts=[]) _params = {:id => id, :status => status, :opts => opts} return @master.call 'lists/members', _params end |
#merge_var_add(id, tag, name, options = []) ⇒ Hash
Add a new merge tag to a given list
910 911 912 913 |
# File 'lib/mailchimp/api.rb', line 910 def merge_var_add(id, tag, name, =[]) _params = {:id => id, :tag => tag, :name => name, :options => } return @master.call 'lists/merge-var-add', _params end |
#merge_var_del(id, tag) ⇒ Hash
Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well! Note that on large lists this method may seem a bit slower than calls you typically make.
920 921 922 923 |
# File 'lib/mailchimp/api.rb', line 920 def merge_var_del(id, tag) _params = {:id => id, :tag => tag} return @master.call 'lists/merge-var-del', _params end |
#merge_var_reset(id, tag) ⇒ Hash
Completely resets all data stored in a merge var on a list. All data is removed and this action can not be undone.
930 931 932 933 |
# File 'lib/mailchimp/api.rb', line 930 def merge_var_reset(id, tag) _params = {:id => id, :tag => tag} return @master.call 'lists/merge-var-reset', _params end |
#merge_var_set(id, tag, value) ⇒ Hash
Sets a particular merge var to the specified value for every list member. Only merge var ids 1 - 30 may be modified this way. This is generally a dirty method unless you’re fixing data since you should probably be using default_values and/or conditional content. as with lists/merge-var-reset(), this can not be undone.
941 942 943 944 |
# File 'lib/mailchimp/api.rb', line 941 def merge_var_set(id, tag, value) _params = {:id => id, :tag => tag, :value => value} return @master.call 'lists/merge-var-set', _params end |
#merge_var_update(id, tag, options) ⇒ Hash
Update most parameters for a merge tag on a given list. You cannot currently change the merge type
963 964 965 966 |
# File 'lib/mailchimp/api.rb', line 963 def merge_var_update(id, tag, ) _params = {:id => id, :tag => tag, :options => } return @master.call 'lists/merge-var-update', _params end |
#merge_vars(id) ⇒ Hash
Get the list of merge tags for a given list, including their name, tag, and required setting
993 994 995 996 |
# File 'lib/mailchimp/api.rb', line 993 def merge_vars(id) _params = {:id => id} return @master.call 'lists/merge-vars', _params end |
#static_segment_add(id, name) ⇒ Hash
Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance. When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation options), though performance may degrade at that point.
1003 1004 1005 1006 |
# File 'lib/mailchimp/api.rb', line 1003 def static_segment_add(id, name) _params = {:id => id, :name => name} return @master.call 'lists/static-segment-add', _params end |
#static_segment_del(id, seg_id) ⇒ Hash
Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
1013 1014 1015 1016 |
# File 'lib/mailchimp/api.rb', line 1013 def static_segment_del(id, seg_id) _params = {:id => id, :seg_id => seg_id} return @master.call 'lists/static-segment-del', _params end |
#static_segment_members_add(id, seg_id, batch) ⇒ Hash
Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list in order to be included - this <strong>will not</strong> subscribe them to the list!
1035 1036 1037 1038 |
# File 'lib/mailchimp/api.rb', line 1035 def static_segment_members_add(id, seg_id, batch) _params = {:id => id, :seg_id => seg_id, :batch => batch} return @master.call 'lists/static-segment-members-add', _params end |
#static_segment_members_del(id, seg_id, batch) ⇒ Hash
Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list in order to be removed - this <strong>will not</strong> unsubscribe them from the list!
1058 1059 1060 1061 |
# File 'lib/mailchimp/api.rb', line 1058 def static_segment_members_del(id, seg_id, batch) _params = {:id => id, :seg_id => seg_id, :batch => batch} return @master.call 'lists/static-segment-members-del', _params end |
#static_segment_reset(id, seg_id) ⇒ Hash
Resets a static segment - removes <strong>all</strong> members from the static segment. Note: does not actually affect list member data
1068 1069 1070 1071 |
# File 'lib/mailchimp/api.rb', line 1068 def static_segment_reset(id, seg_id) _params = {:id => id, :seg_id => seg_id} return @master.call 'lists/static-segment-reset', _params end |
#static_segments(id) ⇒ Array
Retrieve all of the Static Segments for a list.
1082 1083 1084 1085 |
# File 'lib/mailchimp/api.rb', line 1082 def static_segments(id) _params = {:id => id} return @master.call 'lists/static-segments', _params end |
#subscribe(id, email, merge_vars = nil, email_type = 'html', double_optin = true, update_existing = false, replace_interests = true, send_welcome = false) ⇒ Hash
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!
1119 1120 1121 1122 |
# File 'lib/mailchimp/api.rb', line 1119 def subscribe(id, email, merge_vars=nil, email_type='html', double_optin=true, update_existing=false, replace_interests=true, send_welcome=false) _params = {:id => id, :email => email, :merge_vars => merge_vars, :email_type => email_type, :double_optin => double_optin, :update_existing => update_existing, :replace_interests => replace_interests, :send_welcome => send_welcome} return @master.call 'lists/subscribe', _params end |
#unsubscribe(id, email, delete_member = false, send_goodbye = true, send_notify = true) ⇒ Hash
Unsubscribe the given email address from the list
1135 1136 1137 1138 |
# File 'lib/mailchimp/api.rb', line 1135 def unsubscribe(id, email, delete_member=false, send_goodbye=true, send_notify=true) _params = {:id => id, :email => email, :delete_member => delete_member, :send_goodbye => send_goodbye, :send_notify => send_notify} return @master.call 'lists/unsubscribe', _params end |
#update_member(id, email, merge_vars, email_type = '', replace_interests = true) ⇒ Hash
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 listBatchSubscribe() with the update_existing and possible replace_interests parameter.
1153 1154 1155 1156 |
# File 'lib/mailchimp/api.rb', line 1153 def update_member(id, email, merge_vars, email_type='', replace_interests=true) _params = {:id => id, :email => email, :merge_vars => merge_vars, :email_type => email_type, :replace_interests => replace_interests} return @master.call 'lists/update-member', _params end |
#webhook_add(id, url, actions = [], sources = []) ⇒ Hash
Add a new Webhook URL for the given list
1174 1175 1176 1177 |
# File 'lib/mailchimp/api.rb', line 1174 def webhook_add(id, url, actions=[], sources=[]) _params = {:id => id, :url => url, :actions => actions, :sources => sources} return @master.call 'lists/webhook-add', _params end |
#webhook_del(id, url) ⇒ Hash
Delete an existing Webhook URL from a given list
1184 1185 1186 1187 |
# File 'lib/mailchimp/api.rb', line 1184 def webhook_del(id, url) _params = {:id => id, :url => url} return @master.call 'lists/webhook-del', _params end |
#webhooks(id) ⇒ Array
Return the Webhooks configured for the given list
1204 1205 1206 1207 |
# File 'lib/mailchimp/api.rb', line 1204 def webhooks(id) _params = {:id => id} return @master.call 'lists/webhooks', _params end |