Module: SendGrid4r::REST::Stats::Subuser

Includes:
Request
Included in:
API
Defined in:
lib/sendgrid4r/rest/stats/subuser.rb

Overview

SendGrid Web API v3 Stats - Subuser

Constant Summary

Constants included from Request

Request::BASE_URL

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Request

#create_args, #delete, #execute, #finish, #get, #patch, #post, #process_array_params, #process_url_params, #put

Class Method Details

.url(subuser_name = nil, aggregate = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/sendgrid4r/rest/stats/subuser.rb', line 11

def self.url(subuser_name = nil, aggregate = nil)
  url = "#{BASE_URL}/subusers"
  if subuser_name.nil?
    url = "#{url}/stats"
  else
    url = "#{url}/#{subuser_name}/stats"
  end
  url = "#{url}/#{aggregate}" unless aggregate.nil?
  url
end

Instance Method Details

#get_subuser_stats_monthly(subuser_name:, date:, sort_by_metric: nil, sort_by_direction: nil, limit: nil, offset: nil, &block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/sendgrid4r/rest/stats/subuser.rb', line 64

def get_subuser_stats_monthly(
    subuser_name:, date:, sort_by_metric: nil, sort_by_direction: nil,
    limit: nil, offset: nil, &block)
  params = {
    date: date,
    sort_by_metric: sort_by_metric,
    sort_by_direction: sort_by_direction,
    limit: limit,
    offset: offset
  }
  resp = get(@auth, Subuser.url(subuser_name, :monthly), params, &block)
  finish(resp, @raw_resp) { |r| Stats.create_top_stat(r) }
end

#get_subusers_stats(start_date:, end_date: nil, aggregated_by: nil, subusers:, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sendgrid4r/rest/stats/subuser.rb', line 22

def get_subusers_stats(
    start_date:, end_date: nil, aggregated_by: nil, subusers:, &block)
  params = {
    start_date: start_date,
    end_date: end_date,
    aggregated_by: aggregated_by,
    subusers: subusers
  }
  resp = get(@auth, Subuser.url, params, &block)
  finish(resp, @raw_resp) { |r| Stats.create_top_stats(r) }
end

#get_subusers_stats_monthly(date:, subuser: nil, sort_by_metric: nil, sort_by_direction: nil, limit: nil, offset: nil, &block) ⇒ Object



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

def get_subusers_stats_monthly(
    date:, subuser: nil, sort_by_metric: nil, sort_by_direction: nil,
    limit: nil, offset: nil, &block)
  params = {
    date: date,
    subuser: subuser,
    sort_by_metric: sort_by_metric,
    sort_by_direction: sort_by_direction,
    limit: limit,
    offset: offset
  }
  resp = get(@auth, Subuser.url(nil, :monthly), params, &block)
  finish(resp, @raw_resp) { |r| Stats.create_top_stat(r) }
end

#get_subusers_stats_sums(start_date:, end_date: nil, sort_by_metric: nil, sort_by_direction: nil, limit: nil, offset: nil, &block) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sendgrid4r/rest/stats/subuser.rb', line 34

def get_subusers_stats_sums(
    start_date:, end_date: nil, sort_by_metric: nil,
    sort_by_direction: nil, limit: nil, offset: nil, &block)
  params = {
    start_date: start_date,
    end_date: end_date,
    sort_by_metric: sort_by_metric,
    sort_by_direction: sort_by_direction,
    limit: limit,
    offset: offset
  }
  resp = get(@auth, Subuser.url(nil, :sums), params, &block)
  finish(resp, @raw_resp) { |r| Stats.create_top_stat(r) }
end