Class: MadMimi::Audience
- Inherits:
-
Object
- Object
- MadMimi::Audience
- Includes:
- Request
- Defined in:
- lib/mad_mimi/audience.rb
Overview
:nodoc
Instance Method Summary collapse
-
#add_to_list(list, options = {}) ⇒ Object
Add Audience List Membership.
-
#lists ⇒ Object
Get all Audience Lists.
-
#members(options = {}) ⇒ Object
Get Audience Members.
-
#remove_from_list(list, email) ⇒ Object
Remove Audience List Membership.
-
#search(options = {}) ⇒ Object
Search.
-
#suppress(email) ⇒ Object
Suppress an Audience Member.
Methods included from Request
Instance Method Details
#add_to_list(list, options = {}) ⇒ Object
Add Audience List Membership
This will add an existing member to a list or create a new audience member with that email address and add that member to the list. Any additional parameters passed (such as first_name and last_name) will be added
or updated
on the audience member.
53 54 55 |
# File 'lib/mad_mimi/audience.rb', line 53 def add_to_list(list, = {}) post("/audience_lists/#{list}/add", , true) end |
#lists ⇒ Object
41 42 43 44 |
# File 'lib/mad_mimi/audience.rb', line 41 def lists response = get('/audience_lists/lists.xml') response ? response["lists"]["list"] : response end |
#members(options = {}) ⇒ Object
Get Audience Members
Returns audience members paged in XML format.
Optional parameters are:
-
:page
– the current page to fetch -
:per_page
– the number of audience members returned per page. Must be between 1 and 100 -
:order
– the ordering. Must be one of email, first_name, last_name and created_at
31 32 33 34 |
# File 'lib/mad_mimi/audience.rb', line 31 def members( = {}) response = get('/audience_members') response ? response["audience"]["member"] : response end |
#remove_from_list(list, email) ⇒ Object
Remove Audience List Membership
Removes an existing email address from an audience list. The member is not deleted and will remain on any other lists. The email address is simply removed from that audience list.
64 65 66 |
# File 'lib/mad_mimi/audience.rb', line 64 def remove_from_list(list, email) post("/audience_lists/#{list}/remove", {:email => email}) end |
#search(options = {}) ⇒ Object
Search
Performs an audience search and returns the up to the first 100 results.
Optional parameters are:
-
:query
– The query parameter can be any search criteria you can use in the interface. A common use would be to use this function to get all of a member’s details by sending the email address as the query. -
:raw
– if you want to return all users, regardless of suppression status, add the raw=true parameter on the end of your query. -
:add_list
– You can add the results of the search to a new or existing list by passing an additional add_list parameter with the name of the list.
See Search
16 17 18 19 |
# File 'lib/mad_mimi/audience.rb', line 16 def search( = {}) response = get('/audience_members/search.xml', ) response ? response["audience"]["member"] : response end |
#suppress(email) ⇒ Object
Suppress an Audience Member
This adds the audience member to your suppression list, effectively preventing sending newsletters to that member (unsubscribing them). Audience members on your suppression list do not count towards your total active audience.
75 76 77 |
# File 'lib/mad_mimi/audience.rb', line 75 def suppress(email) post("/audience_members/#{email}/suppress_email") end |