Class: PewPew::Resources::Lists

Inherits:
Object
  • Object
show all
Includes:
PewPew::Resource
Defined in:
lib/pew_pew/resources/lists.rb

Instance Method Summary collapse

Instance Method Details

#allMash

Fetches all defined mailing lists.

Returns:

  • (Mash)

    the response body



11
12
13
# File 'lib/pew_pew/resources/lists.rb', line 11

def all
  get('lists')
end

#all_members(address) ⇒ Mash

Fetches all defined mailing list members.

Parameters:

  • address (String)

    the email address of the mailing list

Returns:

  • (Mash)

    the response body



66
67
68
# File 'lib/pew_pew/resources/lists.rb', line 66

def all_members(address)
  get("lists/#{address}/members")
end

#create(params) ⇒ Mash

Creates a new mailing list.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :description (String)

    optional list description

  • :name (String)

    optional mailing list name

  • :address (String)

    email address for the mailing list

Returns:

  • (Mash)

    the response body



29
30
31
# File 'lib/pew_pew/resources/lists.rb', line 29

def create(params)
  post('lists', params)
end

#create_member(address, params) ⇒ Mash

Adds a new member to a mailing list.

Parameters:

  • address (String)

    the email address of the mailing list

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :address (String)

    the email address of the member

  • :name (String)

    optional member name

  • :vars (Hash)

    optional dictionary of arbitrary member parameters (will be encoded as JSON)

  • :subscribed (Boolean)

    if false, add the member as unsubscribed

  • :upsert (Boolean)

    if true, update an existing member instead of returning an error

Returns:

  • (Mash)

    the response body



91
92
93
94
# File 'lib/pew_pew/resources/lists.rb', line 91

def create_member(address, params)
  params[:vars] = params[:vars].to_json
  post("lists/#{address}/members", params)
end

#find(address) ⇒ Mash

Fetch a mailing list by email address.

Parameters:

  • address (String)

    the email address of the mailing list to fetch

Returns:

  • (Mash)

    the response body



19
20
21
# File 'lib/pew_pew/resources/lists.rb', line 19

def find(address)
  get("lists/#{address}")
end

#find_member(address, member_address) ⇒ Mash

Fetch a mailing list member by email address.

Parameters:

  • address (String)

    the email address of the mailing list

  • member_address (String)

    the email address of the member to fetch

Returns:

  • (Mash)

    the response body



75
76
77
# File 'lib/pew_pew/resources/lists.rb', line 75

def find_member(address, member_address)
  get("lists/#{address}/members/#{member_address}")
end

#remove(address) ⇒ Mash

Removes an existing mailing list by email address.

Parameters:

  • address (String)

    the email address of the mailing list to remove

Returns:

  • (Mash)

    the response body



48
49
50
# File 'lib/pew_pew/resources/lists.rb', line 48

def remove(address)
  delete("lists/#{address}")
end

#remove_member(address, member_address) ⇒ Mash

Removes an existing mailing list member by email address.

Parameters:

  • address (String)

    the email address of the mailing list

  • member_address (String)

    the email address of the member to remove

Returns:

  • (Mash)

    the response body



116
117
118
# File 'lib/pew_pew/resources/lists.rb', line 116

def remove_member(address, member_address)
  delete("lists/#{address}/members/#{member_address}")
end

#stats(address) ⇒ Mash

Fetches a summary of the results for a given mailing list, like numbers of clicks, opens, etc. Includes unique numbers (e.g. number of unique recipients who clicked) as well.

Parameters:

  • address (String)

    the email address of the mailing list to fetch

Returns:

  • (Mash)

    the response body



58
59
60
# File 'lib/pew_pew/resources/lists.rb', line 58

def stats(address)
  get("lists/#{address}/stats")
end

#update(address, params) ⇒ Mash

Updates an existing mailing list by email address.

Parameters:

  • address (String)

    the email address of the mailing list to update

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :description (String)

    optional list description

  • :name (String)

    optional mailing list name

  • :address (String)

    email address for the mailing list

Returns:

  • (Mash)

    the response body



40
41
42
# File 'lib/pew_pew/resources/lists.rb', line 40

def update(address, params)
  put("lists/#{address}", params)
end

#update_member(address, member_address, params) ⇒ Mash

Updates an existing mailing list member by email address.

Parameters:

  • address (String)

    the email address of the mailing list

  • member_address (String)

    the email address of the member to update

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :address (String)

    the email address of the member

  • :name (String)

    optional member name

  • :vars (Hash)

    optional dictionary of arbitrary member parameters (will be encoded as JSON)

  • :subscribed (Boolean)

    if false, add the member as unsubscribed

Returns:

  • (Mash)

    the response body



107
108
109
# File 'lib/pew_pew/resources/lists.rb', line 107

def update_member(address, member_address, params)
  put("lists/#{address}/members/#{member_address}", params)
end