Class: PewPew::Resources::Unsubscribes

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

Instance Method Summary collapse

Instance Method Details

#allMash

Fetches all unsubscribe events.

Returns:

  • (Mash)

    the response body



10
11
12
# File 'lib/pew_pew/resources/unsubscribes.rb', line 10

def all
  get("#{domain}/unsubscribes")
end

#create(params) ⇒ Mash

Creates a new unsubscribe event.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :address (String)

    the email address to unsubscribe

  • :tag (String)

    optional tag to unsubscribe from (defaults to unsubscribing the address completely from the domain)

Returns:

  • (Mash)

    the response body



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

def create(params)
  params[:tag] ||= '*'
  post("#{domain}/unsubscribes", params)
end

#find(address) ⇒ Mash

Fetch all unsubscribe events by address.

Parameters:

  • address (String)

    the address to fetch unsubscribe events for

Returns:

  • (Mash)

    the response body



18
19
20
# File 'lib/pew_pew/resources/unsubscribes.rb', line 18

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

#remove(address_or_id) ⇒ Mash

Removes existing unsubscribe events.

Parameters:

  • address_or_id (String)

    the address to remove all the unsubscribe events for, or a single unsubscribe event ID to remove

Returns:

  • (Mash)

    the response body



38
39
40
# File 'lib/pew_pew/resources/unsubscribes.rb', line 38

def remove(address_or_id)
  delete("#{domain}/unsubscribes/#{address_or_id}")
end