Class: MaropostApi::Campaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/maropost_api/campaigns.rb

Overview

Contains methods that get various Campaign Reports based on provided parameters. The method names themselves reveal the type of reports they are getting.

Instance Method Summary collapse

Constructor Details

#initialize(account = ENV["ACCOUNT"], api_key = ENV["API_KEY"]) ⇒ Campaigns

Creates a new instance of Reports class.

Parameters:

  • account (Integer) (defaults to: ENV["ACCOUNT"])

    is authentic user account id (Integer) provided by maropost.com

  • api_key (String) (defaults to: ENV["API_KEY"])

    is the auth token (String) that is validated on the server to authenticate the user



11
12
13
14
# File 'lib/maropost_api/campaigns.rb', line 11

def initialize( = ENV["ACCOUNT"], api_key = ENV["API_KEY"])
  MaropostApi.instance_variable_set(:@api_key, api_key)
  MaropostApi.instance_variable_set(:@account, )
end

Instance Method Details

#get(page) ⇒ Object

gets all the campaigns grouped by

Parameters:

  • page (Integer)

    number that determines which page of the result to retrieve



19
20
21
22
23
24
# File 'lib/maropost_api/campaigns.rb', line 19

def get(page)
  full_path = full_resource_path('')
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_bounce_reports(campaign_id, page) ⇒ Object

gets bounce reports for the provided

Parameters:

  • campaign_id (Integer)

    Unique id of campaign

  • page (Integer)

    number that decides which page of result to get



40
41
42
43
44
45
# File 'lib/maropost_api/campaigns.rb', line 40

def get_bounce_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/bounce_report")
  query_params = MaropostApi.set_query_params({page:page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_campaign(campaign_id) ⇒ Object

gets a campaign determined by the provided

Parameters:

  • campaign_id (Integer)

    Unique identifier of campaigns



29
30
31
32
33
34
# File 'lib/maropost_api/campaigns.rb', line 29

def get_campaign(campaign_id)
  full_path = full_resource_path("/#{campaign_id}")
  query_params = MaropostApi.set_query_params()

  MaropostApi.get_result(full_path, query_params)
end

#get_click_reports(campaign_id, page, unique = nil) ⇒ Object

gets click reports for the provided

Parameters:

  • campaign_id (Integer)

    Unique id of campaign

  • page (Integer)

    number that decides which page of result to get

  • unique (Boolean) (defaults to: nil)

    decides whether to retrive unique reports or not



52
53
54
55
56
57
58
# File 'lib/maropost_api/campaigns.rb', line 52

def get_click_reports(campaign_id, page, unique = nil)
  full_path = full_resource_path("/#{campaign_id}/click_report")
  query_params = MaropostApi.set_query_params({page: page})
  query_params[:query][:unique] = unique unless unique.nil?
  
  MaropostApi.get_result(full_path, query_params)
end

#get_complaint_reports(campaign_id, page) ⇒ Object

gets complaint reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



64
65
66
67
68
69
# File 'lib/maropost_api/campaigns.rb', line 64

def get_complaint_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/complaint_report")
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_delivered_reports(campaign_id, page) ⇒ Object

gets delivered reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



75
76
77
78
79
80
# File 'lib/maropost_api/campaigns.rb', line 75

def get_delivered_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/delivered_report")
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_hard_bounce_reports(campaign_id, page) ⇒ Object

gets hard bounce reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



86
87
88
89
90
91
# File 'lib/maropost_api/campaigns.rb', line 86

def get_hard_bounce_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/hard_bounce_report")
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end

gets link reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



132
133
134
135
136
137
138
# File 'lib/maropost_api/campaigns.rb', line 132

def get_link_reports(campaign_id, page, unique = nil)
  full_path = full_resource_path("/#{campaign_id}/link_report")
  query_params = MaropostApi.set_query_params({page: page})
  query_params[:query][:unique] = unique unless unique.nil?
  
  MaropostApi.get_result(full_path, query_params)
end

#get_open_reports(campaign_id, page, unique = nil) ⇒ Object

gets open reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign

  • unique (Boolean) (defaults to: nil)

    decides whether to retrive unique reports or not



109
110
111
112
113
114
115
# File 'lib/maropost_api/campaigns.rb', line 109

def get_open_reports(campaign_id, page, unique = nil)
  full_path = full_resource_path("/#{campaign_id}/open_report")
  query_params = MaropostApi.set_query_params({page: page})
  query_params[:query][:unique] = unique unless unique.nil?
  
  MaropostApi.get_result(full_path, query_params)
end

#get_soft_bounce_reports(campaign_id, page) ⇒ Object

gets soft bounce reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



97
98
99
100
101
102
# File 'lib/maropost_api/campaigns.rb', line 97

def get_soft_bounce_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/soft_bounce_report")
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_unsubscribe_reports(campaign_id, page) ⇒ Object

gets unsubscribe reports for the provided param page [Integer] number that decides which page of result to get

Parameters:

  • campaign_id (Integer)

    Unique id of campaign



121
122
123
124
125
126
# File 'lib/maropost_api/campaigns.rb', line 121

def get_unsubscribe_reports(campaign_id, page)
  full_path = full_resource_path("/#{campaign_id}/unsubscribe_report")
  query_params = MaropostApi.set_query_params({page: page})
  
  MaropostApi.get_result(full_path, query_params)
end