Class: MadMimi::Audience

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/mad_mimi/audience.rb

Overview

:nodoc

Instance Method Summary collapse

Methods included from Request

#get, #post

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.

See Add Audience List Membership



53
54
55
# File 'lib/mad_mimi/audience.rb', line 53

def add_to_list(list, options = {})
  post("/audience_lists/#{list}/add", options, true)
end

#listsObject

Get all Audience Lists

Returns all audience lists

See Get all Audience Lists



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

See Get Audience Members



31
32
33
34
# File 'lib/mad_mimi/audience.rb', line 31

def members(options = {})
  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.

See Remove Audience List Membership



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(options = {})
  response = get('/audience_members/search.xml', options)
  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.

See Suppress an Audience Member



75
76
77
# File 'lib/mad_mimi/audience.rb', line 75

def suppress(email)
  post("/audience_members/#{email}/suppress_email")
end