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 all 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.
540 541 542 |
# File 'lib/mailchimp/api.rb', line 540 def initialize(master) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
538 539 540 |
# File 'lib/mailchimp/api.rb', line 538 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
556 557 558 559 |
# File 'lib/mailchimp/api.rb', line 556 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.
564 565 566 567 |
# File 'lib/mailchimp/api.rb', line 564 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.
601 602 603 604 |
# File 'lib/mailchimp/api.rb', line 601 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
626 627 628 629 |
# File 'lib/mailchimp/api.rb', line 626 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 user-agent-string.info
648 649 650 651 |
# File 'lib/mailchimp/api.rb', line 648 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.
660 661 662 663 |
# File 'lib/mailchimp/api.rb', line 660 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.
688 689 690 691 |
# File 'lib/mailchimp/api.rb', line 688 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.
699 700 701 702 |
# File 'lib/mailchimp/api.rb', line 699 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
711 712 713 714 |
# File 'lib/mailchimp/api.rb', line 711 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.
723 724 725 726 |
# File 'lib/mailchimp/api.rb', line 723 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
732 733 734 735 |
# File 'lib/mailchimp/api.rb', line 732 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
743 744 745 746 |
# File 'lib/mailchimp/api.rb', line 743 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
677 678 679 680 |
# File 'lib/mailchimp/api.rb', line 677 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
1261 1262 1263 1264 |
# File 'lib/mailchimp/api.rb', line 1261 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
755 756 757 758 |
# File 'lib/mailchimp/api.rb', line 755 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.)
788 789 790 791 |
# File 'lib/mailchimp/api.rb', line 788 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
858 859 860 861 |
# File 'lib/mailchimp/api.rb', line 858 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 List Export API
875 876 877 878 |
# File 'lib/mailchimp/api.rb', line 875 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
909 910 911 912 |
# File 'lib/mailchimp/api.rb', line 909 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.
919 920 921 922 |
# File 'lib/mailchimp/api.rb', line 919 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.
929 930 931 932 |
# File 'lib/mailchimp/api.rb', line 929 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.
940 941 942 943 |
# File 'lib/mailchimp/api.rb', line 940 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
962 963 964 965 |
# File 'lib/mailchimp/api.rb', line 962 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
992 993 994 995 |
# File 'lib/mailchimp/api.rb', line 992 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 are not 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.
1002 1003 1004 1005 |
# File 'lib/mailchimp/api.rb', line 1002 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
1012 1013 1014 1015 |
# File 'lib/mailchimp/api.rb', line 1012 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 will not subscribe them to the list!
1034 1035 1036 1037 |
# File 'lib/mailchimp/api.rb', line 1034 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 will not unsubscribe them from the list!
1057 1058 1059 1060 |
# File 'lib/mailchimp/api.rb', line 1057 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 all members from the static segment. Note: does not actually affect list member data
1067 1068 1069 1070 |
# File 'lib/mailchimp/api.rb', line 1067 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.
1081 1082 1083 1084 |
# File 'lib/mailchimp/api.rb', line 1081 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!
1118 1119 1120 1121 |
# File 'lib/mailchimp/api.rb', line 1118 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
1134 1135 1136 1137 |
# File 'lib/mailchimp/api.rb', line 1134 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.
1152 1153 1154 1155 |
# File 'lib/mailchimp/api.rb', line 1152 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
1173 1174 1175 1176 |
# File 'lib/mailchimp/api.rb', line 1173 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
1183 1184 1185 1186 |
# File 'lib/mailchimp/api.rb', line 1183 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
1203 1204 1205 1206 |
# File 'lib/mailchimp/api.rb', line 1203 def webhooks(id) _params = {:id => id} return @master.call 'lists/webhooks', _params end |