sendgrid4r 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +21 -0
  3. data/.travis.yml +2 -3
  4. data/README.md +3 -373
  5. data/Rakefile +1 -1
  6. data/lib/auth.rb +7 -9
  7. data/lib/client.rb +8 -9
  8. data/lib/sendgrid4r/factory/version_factory.rb +20 -10
  9. data/lib/sendgrid4r/rest/api.rb +28 -9
  10. data/lib/sendgrid4r/rest/asm/global_suppressions.rb +46 -0
  11. data/lib/sendgrid4r/rest/asm/groups.rb +69 -0
  12. data/lib/sendgrid4r/rest/asm/suppressions.rb +68 -0
  13. data/lib/sendgrid4r/rest/categories/categories.rb +38 -0
  14. data/lib/sendgrid4r/rest/ips/addresses.rb +74 -0
  15. data/lib/sendgrid4r/rest/ips/pools.rb +63 -0
  16. data/lib/sendgrid4r/rest/ips/warmup.rb +55 -0
  17. data/lib/sendgrid4r/rest/request.rb +34 -19
  18. data/lib/sendgrid4r/rest/settings/enforced_tls.rb +39 -0
  19. data/lib/sendgrid4r/rest/stats/advanced.rb +91 -0
  20. data/lib/sendgrid4r/rest/stats/category.rb +47 -0
  21. data/lib/sendgrid4r/rest/stats/global.rb +26 -0
  22. data/lib/sendgrid4r/rest/stats/parse.rb +26 -0
  23. data/lib/sendgrid4r/rest/stats/stats.rb +89 -0
  24. data/lib/sendgrid4r/rest/stats/subuser.rb +47 -0
  25. data/lib/sendgrid4r/rest/templates/templates.rb +61 -0
  26. data/lib/sendgrid4r/rest/templates/versions.rb +92 -0
  27. data/lib/sendgrid4r/version.rb +4 -1
  28. data/lib/sendgrid4r.rb +5 -2
  29. data/sendgrid4r.gemspec +13 -12
  30. data/spec/{global_suppressions_spec.rb → asm/global_suppressions_spec.rb} +25 -17
  31. data/spec/asm/groups_spec.rb +58 -0
  32. data/spec/{suppressions_spec.rb → asm/suppressions_spec.rb} +24 -22
  33. data/spec/categories/categories_spec.rb +39 -0
  34. data/spec/client_spec.rb +65 -50
  35. data/spec/ips/addresses_spec.rb +116 -0
  36. data/spec/ips/pools_spec.rb +43 -0
  37. data/spec/ips/warmup_spec.rb +52 -0
  38. data/spec/{enforced_tls_spec.rb → settings/enforced_tls_spec.rb} +12 -11
  39. data/spec/stats/advanced_spec.rb +243 -0
  40. data/spec/stats/category_spec.rb +112 -0
  41. data/spec/stats/global_spec.rb +64 -0
  42. data/spec/stats/parse_spec.rb +49 -0
  43. data/spec/stats/subuser_spec.rb +105 -0
  44. data/spec/templates/templates_spec.rb +66 -0
  45. data/spec/templates/versions_spec.rb +89 -0
  46. data/spec/version_factory_spec.rb +20 -15
  47. metadata +94 -42
  48. data/lib/sendgrid4r/rest/addresses.rb +0 -62
  49. data/lib/sendgrid4r/rest/enforced_tls.rb +0 -46
  50. data/lib/sendgrid4r/rest/global_suppressions.rb +0 -35
  51. data/lib/sendgrid4r/rest/groups.rb +0 -68
  52. data/lib/sendgrid4r/rest/pools.rb +0 -53
  53. data/lib/sendgrid4r/rest/suppressions.rb +0 -57
  54. data/lib/sendgrid4r/rest/templates.rb +0 -64
  55. data/lib/sendgrid4r/rest/versions.rb +0 -65
  56. data/lib/sendgrid4r/rest/warmup.rb +0 -53
  57. data/spec/addresses_spec.rb +0 -80
  58. data/spec/groups_spec.rb +0 -54
  59. data/spec/pools_spec.rb +0 -62
  60. data/spec/templates_spec.rb +0 -38
  61. data/spec/versions_spec.rb +0 -75
  62. data/spec/warmup_spec.rb +0 -52
@@ -0,0 +1,68 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Asm
9
+ #
10
+ # SendGrid Web API v3 Advanced Suppression Manager - Suppressions
11
+ #
12
+ module Suppressions
13
+ include SendGrid4r::REST::Request
14
+
15
+ Suppression = Struct.new(:id, :name, :description, :suppressed)
16
+
17
+ def self.url(group_id, email_address = nil)
18
+ url =
19
+ "#{SendGrid4r::Client::BASE_URL}"\
20
+ "/asm/groups/#{group_id}/suppressions"
21
+ url = "#{url}/#{email_address}" unless email_address.nil?
22
+ url
23
+ end
24
+
25
+ def self.create_suppression(resp)
26
+ Suppression.new(
27
+ resp['id'], resp['name'], resp['description'], resp['suppressed'])
28
+ end
29
+
30
+ def post_suppressed_emails(group_id, recipient_emails)
31
+ resp = post(
32
+ @auth,
33
+ SendGrid4r::REST::Asm::Suppressions.url(group_id),
34
+ recipient_emails: recipient_emails
35
+ )
36
+ resp['recipient_emails']
37
+ end
38
+
39
+ def get_suppressions(email_address)
40
+ resp_a = get(
41
+ @auth,
42
+ "#{SendGrid4r::Client::BASE_URL}/asm/suppressions/#{email_address}")
43
+ suppressions = []
44
+ resp_a['suppressions'].each do |resp|
45
+ suppressions.push(
46
+ SendGrid4r::REST::Asm::Suppressions.create_suppression(resp)
47
+ )
48
+ end
49
+ suppressions
50
+ end
51
+
52
+ def get_suppressed_emails(group_id)
53
+ get(
54
+ @auth,
55
+ SendGrid4r::REST::Asm::Suppressions.url(group_id)
56
+ )
57
+ end
58
+
59
+ def delete_suppressed_email(group_id, email_address)
60
+ delete(
61
+ @auth,
62
+ SendGrid4r::REST::Asm::Suppressions.url(group_id, email_address)
63
+ )
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Categories
9
+ #
10
+ # SendGrid Web API v3 Categories - Categories
11
+ #
12
+ module Categories
13
+ include SendGrid4r::REST::Request
14
+
15
+ Category = Struct.new(:category)
16
+
17
+ def self.create_category(resp)
18
+ Category.new(resp['category'])
19
+ end
20
+
21
+ def get_categories(category = nil, limit = nil, offset = nil)
22
+ params = {}
23
+ params['category'] = category unless category.nil?
24
+ params['limit'] = limit unless limit.nil?
25
+ params['offset'] = offset unless limit.nil?
26
+ resp_a = get(
27
+ @auth, "#{SendGrid4r::Client::BASE_URL}/categories", params)
28
+ categories = []
29
+ resp_a.each do |resp|
30
+ categories.push(
31
+ SendGrid4r::REST::Categories::Categories.create_category(resp))
32
+ end
33
+ categories
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,74 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ #
9
+ # SendGrid Web API v3 Ip Management
10
+ #
11
+ module Ips
12
+ #
13
+ # SendGrid Web API v3 Ip Management - Pools
14
+ #
15
+ module Addresses
16
+ include SendGrid4r::REST::Request
17
+
18
+ Address = Struct.new(
19
+ :ip, :pools, :warmup, :start_date, :subusers, :rdns, :pool_name)
20
+
21
+ def self.create_address(resp)
22
+ Address.new(
23
+ resp['ip'],
24
+ resp['pools'],
25
+ resp['warmup'],
26
+ resp['start_date'],
27
+ resp['subusers'],
28
+ resp['rdns'],
29
+ resp['pool_name']
30
+ )
31
+ end
32
+
33
+ def post_ip_to_pool(pool_name, ip)
34
+ resp = post(
35
+ @auth,
36
+ "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{pool_name}/ips",
37
+ ip: ip
38
+ )
39
+ SendGrid4r::REST::Ips::Addresses.create_address(resp)
40
+ end
41
+
42
+ def get_ips
43
+ resp_a = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips")
44
+ ips = []
45
+ resp_a.each do |resp|
46
+ ips.push(SendGrid4r::REST::Ips::Addresses.create_address(resp))
47
+ end
48
+ ips
49
+ end
50
+
51
+ def get_ips_assigned
52
+ resp_a = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/assigned")
53
+ ips = []
54
+ resp_a.each do |resp|
55
+ ips.push(SendGrid4r::REST::Ips::Addresses.create_address(resp))
56
+ end
57
+ ips
58
+ end
59
+
60
+ def get_ip(ip)
61
+ resp = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/#{ip}")
62
+ SendGrid4r::REST::Ips::Addresses.create_address(resp)
63
+ end
64
+
65
+ def delete_ip_from_pool(pool_name, ip)
66
+ delete(
67
+ @auth,
68
+ "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{pool_name}/ips/#{ip}"
69
+ )
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,63 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ #
9
+ # SendGrid Web API v3 Ip Management
10
+ #
11
+ module Ips
12
+ #
13
+ # SendGrid Web API v3 Ip Management - Pools
14
+ #
15
+ module Pools
16
+ include SendGrid4r::REST::Request
17
+
18
+ Pool = Struct.new(:pool_name, :name, :ips)
19
+
20
+ def self.create_pool(resp)
21
+ ips = []
22
+ Array(resp['ips']).each { |ip| ips.push(ip) }
23
+ Pool.new(resp['pool_name'], resp['name'], ips)
24
+ end
25
+
26
+ def post_pool(name)
27
+ resp = post(
28
+ @auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools", name: name
29
+ )
30
+ SendGrid4r::REST::Ips::Pools.create_pool(resp)
31
+ end
32
+
33
+ def get_pools
34
+ resp_a = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools")
35
+ pools = []
36
+ resp_a.each do |resp|
37
+ pools.push(SendGrid4r::REST::Ips::Pools.create_pool(resp))
38
+ end
39
+ pools
40
+ end
41
+
42
+ def get_pool(name)
43
+ resp = get(
44
+ @auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}"
45
+ )
46
+ SendGrid4r::REST::Ips::Pools.create_pool(resp)
47
+ end
48
+
49
+ def put_pool(name, new_name)
50
+ resp = put(
51
+ @auth,
52
+ "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}",
53
+ name: new_name)
54
+ SendGrid4r::REST::Ips::Pools.create_pool(resp)
55
+ end
56
+
57
+ def delete_pool(name)
58
+ delete(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}")
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,55 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Ips
9
+ #
10
+ # SendGrid Web API v3 Ip Management - Warmup
11
+ #
12
+ module Warmup
13
+ include SendGrid4r::REST::Request
14
+ WarmupIp = Struct.new(:ip, :start_date)
15
+
16
+ def self.create_warmup_ip(resp)
17
+ WarmupIp.new(resp['ip'], resp['start_date'])
18
+ end
19
+
20
+ def get_warmup_ips
21
+ ips = []
22
+ resp_a = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/warmup")
23
+ resp_a.each do |resp|
24
+ ips.push(SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp))
25
+ end
26
+ ips
27
+ end
28
+
29
+ def get_warmup_ip(ip_address)
30
+ resp = get(
31
+ @auth,
32
+ "#{SendGrid4r::Client::BASE_URL}/ips/warmup/#{ip_address}"
33
+ )
34
+ SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
35
+ end
36
+
37
+ def post_warmup_ip(ip_address)
38
+ resp = post(
39
+ @auth,
40
+ "#{SendGrid4r::Client::BASE_URL}/ips/warmup",
41
+ ip: ip_address
42
+ )
43
+ SendGrid4r::REST::Ips::Warmup.create_warmup_ip(resp)
44
+ end
45
+
46
+ def delete_warmup_ip(ip_address)
47
+ delete(
48
+ @auth,
49
+ "#{SendGrid4r::Client::BASE_URL}/ips/warmup/#{ip_address}"
50
+ )
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,48 +1,63 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.unshift File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
3
 
4
- require "rest-client"
5
- require "uri"
6
- require "json"
4
+ require 'rest-client'
5
+ require 'uri'
6
+ require 'json'
7
7
 
8
8
  module SendGrid4r
9
9
  module REST
10
+ #
11
+ # SendGrid Web API v3 Request
12
+ #
10
13
  module Request
11
-
12
- def get(auth, endpoint)
13
- resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
14
- body = resource.get.body
14
+ def get(auth, endpoint, params = nil)
15
+ resource = RestClient::Resource.new(
16
+ endpoint, auth.username, auth.password)
17
+ p = { params: params } unless params.nil?
18
+ if p.nil?
19
+ body = resource.get
20
+ else
21
+ body = resource.get(p)
22
+ # TODO: handle ratelimit headers
23
+ # do |response, request, result, &block|
24
+ # # puts response.headers
25
+ # break response.body
26
+ # end
27
+ end
15
28
  JSON.parse(body)
16
29
  end
17
30
 
18
31
  def post(auth, endpoint, params = nil)
19
- resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
20
- if params == nil
21
- body = resource.post(:content_type => :json).body
32
+ resource = RestClient::Resource.new(
33
+ endpoint, auth.username, auth.password)
34
+ if params.nil?
35
+ body = resource.post(content_type: :json).body
22
36
  else
23
- body = resource.post(params.to_json, :content_type => :json).body
37
+ body = resource.post(params.to_json, content_type: :json).body
24
38
  end
25
39
  JSON.parse(body)
26
40
  end
27
41
 
28
42
  def patch(auth, endpoint, params)
29
- resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
30
- body = resource.patch(params.to_json, :content_type => :json).body
43
+ resource = RestClient::Resource.new(
44
+ endpoint, auth.username, auth.password)
45
+ body = resource.patch(params.to_json, content_type: :json).body
31
46
  JSON.parse(body)
32
47
  end
33
48
 
34
49
  def put(auth, endpoint, params)
35
- resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
36
- body = resource.put(params.to_json, :content_type => :json).body
50
+ resource = RestClient::Resource.new(
51
+ endpoint, auth.username, auth.password)
52
+ body = resource.put(params.to_json, content_type: :json).body
37
53
  JSON.parse(body)
38
54
  end
39
55
 
40
56
  def delete(auth, endpoint)
41
- resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
57
+ resource = RestClient::Resource.new(
58
+ endpoint, auth.username, auth.password)
42
59
  resource.delete
43
60
  end
44
-
45
61
  end
46
-
47
62
  end
48
63
  end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Settings
9
+ #
10
+ # SendGrid Web API v3 Settings - EnforcedTls
11
+ #
12
+ module EnforcedTls
13
+ include SendGrid4r::REST::Request
14
+ EnforcedTls = Struct.new(:require_tls, :require_valid_cert)
15
+
16
+ def self.create_enforced_tls(resp)
17
+ EnforcedTls.new(resp['require_tls'], resp['require_valid_cert'])
18
+ end
19
+
20
+ def get_enforced_tls
21
+ resp = get(
22
+ @auth,
23
+ "#{SendGrid4r::Client::BASE_URL}/user/settings/enforced_tls"
24
+ )
25
+ SendGrid4r::REST::Settings::EnforcedTls.create_enforced_tls(resp)
26
+ end
27
+
28
+ def patch_enforced_tls(params)
29
+ resp = patch(
30
+ @auth,
31
+ "#{SendGrid4r::Client::BASE_URL}/user/settings/enforced_tls",
32
+ params.to_h
33
+ )
34
+ SendGrid4r::REST::Settings::EnforcedTls.create_enforced_tls(resp)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,91 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Stats
9
+ #
10
+ # SendGrid Web API v3 Stats - Advanced
11
+ #
12
+ module Advanced
13
+ def get_geo_stats(
14
+ start_date:, end_date: nil, aggregated_by: nil, country: nil)
15
+ params = {
16
+ start_date: start_date,
17
+ end_date: end_date,
18
+ aggregated_by: aggregated_by,
19
+ country: country
20
+ }
21
+ resp_a = get(
22
+ @auth, "#{SendGrid4r::Client::BASE_URL}/geo/stats", params)
23
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
24
+ end
25
+
26
+ def get_devices_stats(start_date:, end_date: nil, aggregated_by: nil)
27
+ params = {
28
+ start_date: start_date,
29
+ end_date: end_date,
30
+ aggregated_by: aggregated_by
31
+ }
32
+ resp_a = get(
33
+ @auth, "#{SendGrid4r::Client::BASE_URL}/devices/stats", params)
34
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
35
+ end
36
+
37
+ def get_clients_stats(start_date:, end_date: nil, aggregated_by: nil)
38
+ params = {
39
+ start_date: start_date,
40
+ end_date: end_date,
41
+ aggregated_by: aggregated_by
42
+ }
43
+ resp_a = get(
44
+ @auth, "#{SendGrid4r::Client::BASE_URL}/clients/stats", params)
45
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
46
+ end
47
+
48
+ def get_clients_type_stats(
49
+ start_date:, end_date: nil, aggregated_by: nil, client_type:)
50
+ params = {
51
+ start_date: start_date,
52
+ end_date: end_date,
53
+ aggregated_by: aggregated_by,
54
+ client_type: client_type
55
+ }
56
+ resp_a = get(
57
+ @auth,
58
+ "#{SendGrid4r::Client::BASE_URL}/clients/#{client_type}/stats",
59
+ params)
60
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
61
+ end
62
+
63
+ def get_esp_stats(
64
+ start_date:, end_date: nil, aggregated_by: nil, esps: nil)
65
+ params = {
66
+ start_date: start_date,
67
+ end_date: end_date,
68
+ aggregated_by: aggregated_by,
69
+ esps: esps
70
+ }
71
+ resp_a = get(
72
+ @auth, "#{SendGrid4r::Client::BASE_URL}/esp/stats", params)
73
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
74
+ end
75
+
76
+ def get_browsers_stats(
77
+ start_date:, end_date: nil, aggregated_by: nil, browsers: nil)
78
+ params = {
79
+ start_date: start_date,
80
+ end_date: end_date,
81
+ aggregated_by: aggregated_by,
82
+ browsers: browsers
83
+ }
84
+ resp_a = get(
85
+ @auth, "#{SendGrid4r::Client::BASE_URL}/browsers/stats", params)
86
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Stats
9
+ #
10
+ # SendGrid Web API v3 Stats - Category
11
+ #
12
+ module Category
13
+ def get_categories_stats(
14
+ start_date:, end_date: nil, aggregated_by: nil, categories:)
15
+ params = {
16
+ start_date: start_date,
17
+ end_date: end_date,
18
+ aggregated_by: aggregated_by,
19
+ categories: categories
20
+ }
21
+ # TODO: categories does not support array yet
22
+ resp_a = get(
23
+ @auth, "#{SendGrid4r::Client::BASE_URL}/categories/stats", params)
24
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
25
+ end
26
+
27
+ def get_categories_stats_sums(
28
+ start_date:, end_date: nil, sort_by_metric: nil,
29
+ sort_by_direction: nil, limit: nil, offset: nil)
30
+ params = {
31
+ start_date: start_date,
32
+ end_date: end_date,
33
+ sort_by_metric: sort_by_metric,
34
+ sort_by_direction: sort_by_direction,
35
+ limit: limit,
36
+ offset: offset
37
+ }
38
+ resp = get(
39
+ @auth,
40
+ "#{SendGrid4r::Client::BASE_URL}/categories/stats/sums",
41
+ params)
42
+ SendGrid4r::REST::Stats.create_top_stat(resp)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Stats
9
+ #
10
+ # SendGrid Web API v3 Stats - Global
11
+ #
12
+ module Global
13
+ def get_global_stats(start_date:, end_date: nil, aggregated_by: nil)
14
+ params = {
15
+ start_date: start_date,
16
+ end_date: end_date,
17
+ aggregated_by: aggregated_by
18
+ }
19
+ resp_a = get(
20
+ @auth, "#{SendGrid4r::Client::BASE_URL}/stats", params)
21
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'sendgrid4r/rest/request'
5
+
6
+ module SendGrid4r
7
+ module REST
8
+ module Stats
9
+ #
10
+ # SendGrid Web API v3 Stats - Parse
11
+ #
12
+ module Parse
13
+ def get_parse_stats(start_date:, end_date: nil, aggregated_by: nil)
14
+ params = {
15
+ start_date: start_date,
16
+ end_date: end_date,
17
+ aggregated_by: aggregated_by
18
+ }
19
+ resp_a = get(
20
+ @auth, "#{SendGrid4r::Client::BASE_URL}/parse/stats", params)
21
+ SendGrid4r::REST::Stats.create_top_stats(resp_a)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end