Class: PewPew::Resources::Campaigns

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

Instance Method Summary collapse

Instance Method Details

#allMash

Fetches all campaigns for the domain.

Returns:

  • (Mash)

    the response body



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

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

#clicks(id, params = {}) ⇒ Mash

Fetches clicks aggregated by one or more parameters.

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :group_by (String)

    optional grouping (link, recipient, domain, country, region, city, month, day, hour, minute, daily_hour)

  • :country (String)

    optional two-letter country code

  • :region (String)

    optional region name or code

  • :city (String)

    optional city name

  • :limit (Fixnum)

    number of records to return (maximum 100)

  • :page (Fixnum)

    results page number

  • :count (Boolean)

    if true, return counts instead of records

Returns:

  • (Mash)

    the response body



84
85
86
87
# File 'lib/pew_pew/resources/campaigns.rb', line 84

def clicks(id, params={})
  params[:groupby] = params.delete(:group_by) if params[:group_by]
  get("#{domain}/campaigns/#{id}/clicks", params)
end

#complaints(id, params = {}) ⇒ Mash

Fetches complaints aggregated by one or more parameters.

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :group_by (String)

    optional grouping (recipient, domain, month, day, hour, minute, daily_hour)

  • :limit (Fixnum)

    number of records to return (maximum 100)

  • :page (Fixnum)

    results page number

  • :count (Boolean)

    if true, return counts instead of records

Returns:

  • (Mash)

    the response body



135
136
137
138
# File 'lib/pew_pew/resources/campaigns.rb', line 135

def complaints(id, params={})
  params[:groupby] = params.delete(:group_by) if params[:group_by]
  get("#{domain}/campaigns/#{id}/complaints", params)
end

#create(params) ⇒ Mash

Creates a new campaign.

Parameters:

  • params (Hash)

    a customizable set of options

Options Hash (params):

  • :name (String)

    the name of the campaign

  • :id (String)

    optional campaign identifier (defaults to an generated ID)

Returns:

  • (Mash)

    the response body



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

def create(params)
  post("#{domain}/campaigns", params)
end

#events(id, params = {}) ⇒ Mash

Fetch the events for a campaign, including clicks, opens, unsubscribes, bounces and complaints.

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :event (String, Array<String>)

    optional event filter (clicked, opened, unsubscribed, bounced, or complained)

  • :address (String)

    optional recipient email address

  • :country (String)

    optional two-letter country code

  • :region (String)

    optional region name or code

  • :limit (Fixnum)

    number of records to return (maximum 100)

  • :page (Fixnum)

    results page number

  • :count (Boolean)

    if true, return counts instead of records

Returns:

  • (Mash)

    the response body



54
55
56
# File 'lib/pew_pew/resources/campaigns.rb', line 54

def events(id, params={})
  get("#{domain}/campaigns/#{id}/events", params)
end

#find(id) ⇒ Mash

Fetch a campaign by ID.

Parameters:

  • id (String)

    the ID of the campaign to be fetched

Returns:

  • (Mash)

    the response body



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

def find(id)
  get("#{domain}/campaigns/#{id}")
end

#opens(id, params = {}) ⇒ Mash

Fetches opens aggregated by one or more parameters.

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :group_by (String)

    optional grouping (recipient, domain, country, region, city, month, day, hour, minute, daily_hour)

  • :country (String)

    optional two-letter country code

  • :region (String)

    optional region name or code

  • :city (String)

    optional city name

  • :limit (Fixnum)

    number of records to return (maximum 100)

  • :page (Fixnum)

    results page number

  • :count (Boolean)

    if true, return counts instead of records

Returns:

  • (Mash)

    the response body



102
103
104
105
# File 'lib/pew_pew/resources/campaigns.rb', line 102

def opens(id, params={})
  params[:groupby] = params.delete(:group_by) if params[:group_by]
  get("#{domain}/campaigns/#{id}/opens", params)
end

#remove(id) ⇒ Mash

Removes an existing campaign and all associated data.

Parameters:

  • id (String)

    the ID of the campaign to be deleted

Returns:

  • (Mash)

    the response body



36
37
38
# File 'lib/pew_pew/resources/campaigns.rb', line 36

def remove(id)
  delete("#{domain}/campaigns/#{id}")
end

#stats(id, params = {}) ⇒ Mash

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

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :group_by (String)

    optional grouping (domain or daily_hour)

Returns:

  • (Mash)

    the response body



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

def stats(id, params={})
  params[:groupby] = params.delete(:group_by) if params[:group_by]
  get("#{domain}/campaigns/#{id}/stats", params)
end

#unsubscribes(id, params = {}) ⇒ Mash

Fetches unsubscribes aggregated by one or more parameters.

Parameters:

  • id (String)

    a campaign ID

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :group_by (String)

    optional grouping (domain, country, region, city, month, day, hour, minute, daily_hour)

  • :country (String)

    optional two-letter country code

  • :region (String)

    optional region name or code

  • :city (String)

    optional city name

  • :limit (Fixnum)

    number of records to return (maximum 100)

  • :page (Fixnum)

    results page number

  • :count (Boolean)

    if true, return counts instead of records

Returns:

  • (Mash)

    the response body



120
121
122
123
# File 'lib/pew_pew/resources/campaigns.rb', line 120

def unsubscribes(id, params={})
  params[:groupby] = params.delete(:group_by) if params[:group_by]
  get("#{domain}/campaigns/#{id}/unsubscribes", params)
end