Class: MaropostApi::Reports

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

Overview

Contains methods that get 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"]) ⇒ Reports

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/reports.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 reports grouped by page (Integer)



18
19
20
21
22
23
# File 'lib/maropost_api/reports.rb', line 18

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_ab_reports(name:, page:, from: nil, to: nil, per: nil) ⇒ Object

gets all ab reports described by

Parameters:

  • page (Integer)

    that tells the service what page of report to retrieve

  • fields (Array)

    that contains the name of the fields of the contact to retrieve

  • from (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to (Date) (defaults to: nil)

    part of date range of from. Determines the result retrieved is in between this range of date

  • per (Integer) (defaults to: nil)

    determining how many records to get for each page



147
148
149
150
151
152
153
154
155
156
# File 'lib/maropost_api/reports.rb', line 147

def get_ab_reports(name:, page:, from: nil, to: nil, per: nil)
  full_path = full_resource_path('', "ab_reports")
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end

#get_bounces(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil, type: nil) ⇒ Object

gets all bounce reports described by

Parameters:

  • page (Integer)

    that tells the service what page of report to retrieve

  • fields (Array) (defaults to: [])

    that contains the name of the fields of the contact to retrieve

  • from (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to (Part) (defaults to: nil)

    of date range of from. Determines the result retrieved is in between this range of date

  • unique (Boolean) (defaults to: nil)

    that indicates whether to get unique reports or not

  • email (String) (defaults to: nil)

    email to be equated while querying for reports

  • uid (String) (defaults to: nil)

    carrying unique identifier for the report.

  • per (Integer) (defaults to: nil)

    determining how many records to get for each page

  • type (String) (defaults to: nil)

    Set of values determining “soft” or “hard” bounces



87
88
89
90
91
92
93
94
95
96
# File 'lib/maropost_api/reports.rb', line 87

def get_bounces(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil, type: nil)
  full_path = full_resource_path "/bounces"
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end

#get_clicks(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil) ⇒ Object

gets all click reports described by

Parameters:

  • page (Integer)

    that tells the service what page of report to retrieve

  • fields (Array) (defaults to: [])

    that contains the name of the fields of the contact to retrieve

  • from (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to (Part) (defaults to: nil)

    of date range of from. Determines the result retrieved is in between this range of date

  • unique (Boolean) (defaults to: nil)

    that indicates whether to get unique reports or not

  • email (String) (defaults to: nil)

    email to be equated while querying for reports

  • uid (String) (defaults to: nil)

    carrying unique identifier for the report.

  • per (Integer) (defaults to: nil)

    determining how many records to get for each page



65
66
67
68
69
70
71
72
73
74
# File 'lib/maropost_api/reports.rb', line 65

def get_clicks(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil)
  full_path = full_resource_path "/clicks"
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end

#get_complaints(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil) ⇒ Object

gets all complaint reports described by

Parameters:

  • page (Integer)

    that tells the service what page of report to retrieve

  • fields (Array) (defaults to: [])

    that contains the name of the fields of the contact to retrieve

  • from (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to (Date) (defaults to: nil)

    part of date range of from. Determines the result retrieved is in between this range of date

  • unique (Boolean) (defaults to: nil)

    that indicates whether to get unique reports or not

  • email (String) (defaults to: nil)

    email to be equated while querying for reports

  • uid (String) (defaults to: nil)

    carrying unique identifier for the report.

  • per (Integer) (defaults to: nil)

    determining how many records to get for each page



129
130
131
132
133
134
135
136
137
138
# File 'lib/maropost_api/reports.rb', line 129

def get_complaints(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil)
  full_path = full_resource_path "/unsubscribes"
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end

#get_journeys(page) ⇒ Object

gets all journey reports for the provided page

Parameters:

  • page (Integer)


161
162
163
164
165
166
# File 'lib/maropost_api/reports.rb', line 161

def get_journeys(page)
  full_path = full_resource_path '/journeys'
  query_params = MaropostApi.set_query_params({:page => page})
  
  MaropostApi.get_result(full_path, query_params)
end

#get_opens(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil) ⇒ Object

gets all open reports described by

Parameters:

  • page (Integer)

    Integer that tells the service what page of report to retrieve

  • fields (Array) (defaults to: [])

    that contains the name of the fields of the contact to retrieve

  • from (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to (Date) (defaults to: nil)

    Part of date range of from. Determines the result retrieved is in between this range of date

  • unique (Boolean) (defaults to: nil)

    that indicates whether to get unique reports or not

  • email (String) (defaults to: nil)

    email to be equated while querying for reports

  • uid (String) (defaults to: nil)

    carrying unique identifier for the report.

  • per (Integer) (defaults to: nil)

    determining how many records to get for each page



44
45
46
47
48
49
50
51
52
53
# File 'lib/maropost_api/reports.rb', line 44

def get_opens(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil)
  full_path = full_resource_path "/opens"
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end

#get_report(id) ⇒ Object

gets a report defined by its unique id (Integer)



27
28
29
30
31
32
# File 'lib/maropost_api/reports.rb', line 27

def get_report(id)
  full_path = full_resource_path "/#{id}"
  query_params = MaropostApi.set_query_params
  
  MaropostApi.get_result(full_path, query_params)
end

#get_unsubscribes(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil) ⇒ Object

gets all unsubscribe reports described by

Parameters:

  • page: (Integer)

    that tells the service what page of report to retrieve

  • fields: (Array) (defaults to: [])

    that contains the name of the fields of the contact to retrieve

  • from: (Date) (defaults to: nil)

    formatted string to add a constriant to our result

  • to: (Date) (defaults to: nil)

    part of date range of from. Determines the result retrieved is in between this range of date

  • unique: (Boolean) (defaults to: nil)

    that indicates whether to get unique reports or not

  • email: (String) (defaults to: nil)

    email to be equated while querying for reports

  • uid: (String) (defaults to: nil)

    carrying unique identifier for the report.

  • per: (Integer) (defaults to: nil)

    determining how many records to get for each page



108
109
110
111
112
113
114
115
116
117
# File 'lib/maropost_api/reports.rb', line 108

def get_unsubscribes(page:, fields: [], from: nil, to: nil, unique: nil, email: nil, uid: nil, per: nil)
  full_path = full_resource_path "/unsubscribes"
  params = {}
  method(__method__).parameters.each{|p| params[p[1]] = eval(p[1].to_s)}
  params.reject!{|k,v| v.nil? or (v.respond_to? :empty? and v.empty?) }

  query_params = MaropostApi.set_query_params(params)
  
  MaropostApi.get_result(full_path, query_params)
end