Module: SendGrid4r::REST::Stats

Defined in:
lib/sendgrid4r/rest/stats/stats.rb,
lib/sendgrid4r/rest/stats/parse.rb,
lib/sendgrid4r/rest/stats/global.rb,
lib/sendgrid4r/rest/stats/subuser.rb,
lib/sendgrid4r/rest/stats/advanced.rb,
lib/sendgrid4r/rest/stats/category.rb

Overview

SendGrid Web API v3 Stats

Defined Under Namespace

Modules: Advanced, AggregatedBy, Category, Global, Parse, Subuser Classes: Metric, Stat, TopStat

Class Method Summary collapse

Class Method Details

.create_metric(resp) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/sendgrid4r/rest/stats/stats.rb', line 51

def self.create_metric(resp)
  return resp if resp.nil?
  Metric.new(
    resp['blocks'],       resp['bounce_drops'],
    resp['bounces'],      resp['clicks'],
    resp['deferred'],     resp['delivered'],
    resp['drops'],        resp['invalid_emails'],
    resp['opens'],        resp['processed'],
    resp['requests'],     resp['spam_report_drops'],
    resp['spam_reports'], resp['unique_clicks'],
    resp['unique_opens'], resp['unsubscribe_drops'],
    resp['unsubscribes'], resp['received']
  )
end

.create_stat(resp) ⇒ Object



46
47
48
49
# File 'lib/sendgrid4r/rest/stats/stats.rb', line 46

def self.create_stat(resp)
  return resp if resp.nil?
  Stat.new(Stats.create_metric(resp['metrics']), resp['name'], resp['type'])
end

.create_top_stat(resp) ⇒ Object



40
41
42
43
44
# File 'lib/sendgrid4r/rest/stats/stats.rb', line 40

def self.create_top_stat(resp)
  return resp if resp.nil?
  stats = resp['stats'].map { |stat| Stats.create_stat(stat) }
  TopStat.new(resp['date'], stats)
end

.create_top_stats(resp_a) ⇒ Object



66
67
68
69
# File 'lib/sendgrid4r/rest/stats/stats.rb', line 66

def self.create_top_stats(resp_a)
  return resp_a if resp_a.nil?
  resp_a.map { |resp| Stats.create_top_stat(resp) }
end