sendgrid4r 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +5 -0
- data/.rubocop.yml +8 -8
- data/README.md +2 -0
- data/lib/auth.rb +5 -2
- data/lib/client.rb +4 -2
- data/lib/sendgrid4r/factory/version_factory.rb +1 -1
- data/lib/sendgrid4r/rest/api.rb +4 -0
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +73 -0
- data/lib/sendgrid4r/rest/asm/asm.rb +28 -0
- data/lib/sendgrid4r/rest/asm/global_suppressions.rb +12 -8
- data/lib/sendgrid4r/rest/asm/groups.rb +29 -22
- data/lib/sendgrid4r/rest/asm/suppressions.rb +25 -15
- data/lib/sendgrid4r/rest/categories/categories.rb +19 -9
- data/lib/sendgrid4r/rest/contacts/custom_fields.rb +14 -8
- data/lib/sendgrid4r/rest/contacts/lists.rb +32 -20
- data/lib/sendgrid4r/rest/contacts/recipients.rb +42 -31
- data/lib/sendgrid4r/rest/contacts/reserved_fields.rb +6 -2
- data/lib/sendgrid4r/rest/contacts/segments.rb +22 -12
- data/lib/sendgrid4r/rest/ips/addresses.rb +36 -22
- data/lib/sendgrid4r/rest/ips/pools.rb +31 -16
- data/lib/sendgrid4r/rest/ips/warmup.rb +34 -15
- data/lib/sendgrid4r/rest/request.rb +33 -19
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +12 -5
- data/lib/sendgrid4r/rest/stats/advanced.rb +73 -25
- data/lib/sendgrid4r/rest/stats/category.rb +11 -6
- data/lib/sendgrid4r/rest/stats/global.rb +6 -4
- data/lib/sendgrid4r/rest/stats/parse.rb +10 -4
- data/lib/sendgrid4r/rest/stats/stats.rb +13 -18
- data/lib/sendgrid4r/rest/stats/subuser.rb +10 -6
- data/lib/sendgrid4r/rest/templates/templates.rb +23 -16
- data/lib/sendgrid4r/rest/templates/versions.rb +39 -36
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/api_keys/api_keys_spec.rb +152 -0
- data/spec/asm/asm_spec.rb +33 -0
- data/spec/asm/global_suppressions_spec.rb +111 -45
- data/spec/asm/groups_spec.rb +172 -48
- data/spec/asm/suppressions_spec.rb +180 -54
- data/spec/categories/categories_spec.rb +81 -25
- data/spec/client_spec.rb +11 -4
- data/spec/contacts/custom_fields_spec.rb +135 -44
- data/spec/contacts/lists_spec.rb +314 -84
- data/spec/contacts/recipients_spec.rb +337 -92
- data/spec/contacts/reserved_fields_spec.rb +80 -60
- data/spec/contacts/segments_spec.rb +219 -88
- data/spec/factory/condition_factory_spec.rb +12 -12
- data/spec/factory/segment_factory_spec.rb +19 -19
- data/spec/factory/version_factory_spec.rb +6 -6
- data/spec/ips/addresses_spec.rb +177 -84
- data/spec/ips/pools_spec.rb +190 -34
- data/spec/ips/warmup_spec.rb +106 -38
- data/spec/settings/enforced_tls_spec.rb +76 -18
- data/spec/stats/advanced_spec.rb +373 -196
- data/spec/stats/category_spec.rb +133 -71
- data/spec/stats/global_spec.rb +74 -47
- data/spec/stats/parse_spec.rb +46 -29
- data/spec/stats/stats_spec.rb +246 -0
- data/spec/stats/subuser_spec.rb +99 -54
- data/spec/templates/templates_spec.rb +219 -54
- data/spec/templates/versions_spec.rb +171 -67
- metadata +10 -2
data/spec/stats/category_spec.rb
CHANGED
@@ -1,29 +1,87 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../spec_helper'
|
3
3
|
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
describe SendGrid4r::REST::Stats::Category do
|
5
|
+
describe 'integration test' do
|
6
|
+
before do
|
7
|
+
Dotenv.load
|
8
|
+
@client = SendGrid4r::Client.new(
|
9
|
+
username: ENV['SENDGRID_USERNAME'],
|
10
|
+
password: ENV['SENDGRID_PASSWORD'])
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
context 'without block call' do
|
14
|
+
it '#get_categories_stats with mandatory params' do
|
15
|
+
begin
|
16
|
+
top_stats = @client.get_categories_stats(
|
17
|
+
start_date: '2015-01-01',
|
18
|
+
categories: 'yui'
|
19
|
+
)
|
20
|
+
expect(top_stats).to be_a(Array)
|
21
|
+
top_stats.each do |top_stat|
|
22
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
23
|
+
expect(top_stat.stats.length).to eq(1)
|
24
|
+
top_stat.stats.each do |stat|
|
25
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
26
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
27
|
+
expect(stat.metrics.blocks.nil?).to be(false)
|
28
|
+
expect(stat.metrics.bounce_drops.nil?).to be(false)
|
29
|
+
expect(stat.metrics.bounces.nil?).to be(false)
|
30
|
+
expect(stat.metrics.clicks.nil?).to be(false)
|
31
|
+
expect(stat.metrics.deferred.nil?).to be(false)
|
32
|
+
expect(stat.metrics.delivered.nil?).to be(false)
|
33
|
+
expect(stat.metrics.invalid_emails.nil?).to be(false)
|
34
|
+
expect(stat.metrics.opens.nil?).to be(false)
|
35
|
+
expect(stat.metrics.processed.nil?).to be(false)
|
36
|
+
expect(stat.metrics.requests.nil?).to be(false)
|
37
|
+
expect(stat.metrics.spam_report_drops.nil?).to be(false)
|
38
|
+
expect(stat.metrics.spam_reports.nil?).to be(false)
|
39
|
+
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
40
|
+
expect(stat.metrics.unique_opens.nil?).to be(false)
|
41
|
+
expect(stat.metrics.unsubscribe_drops.nil?).to be(false)
|
42
|
+
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
43
|
+
expect(stat.name).to be_a(String)
|
44
|
+
expect(stat.type).to eq('category')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
rescue => e
|
48
|
+
puts e.inspect
|
49
|
+
raise e
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it '#get_category_stats with all params' do
|
54
|
+
begin
|
55
|
+
top_stats = @client.get_categories_stats(
|
56
|
+
start_date: '2015-01-01',
|
57
|
+
end_date: '2015-01-02',
|
58
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
59
|
+
categories: 'yui'
|
60
|
+
)
|
61
|
+
expect(top_stats).to be_a(Array)
|
62
|
+
top_stats.each do |top_stat|
|
63
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
64
|
+
expect(top_stat.stats.length).to eq(1)
|
65
|
+
top_stat.stats.each do |stat|
|
66
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
67
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
rescue => e
|
71
|
+
puts e.inspect
|
72
|
+
raise e
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it '#get_categories_stats_sums with mandatory params' do
|
77
|
+
begin
|
78
|
+
top_stat =
|
79
|
+
@client.get_categories_stats_sums(start_date: '2015-01-01')
|
80
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
81
|
+
expect(top_stat.date).to eq('2015-01-01')
|
82
|
+
top_stat.stats.each do |stat|
|
83
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
84
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
27
85
|
expect(stat.metrics.blocks.nil?).to be(false)
|
28
86
|
expect(stat.metrics.bounce_drops.nil?).to be(false)
|
29
87
|
expect(stat.metrics.bounces.nil?).to be(false)
|
@@ -40,71 +98,75 @@ describe 'SendGrid4r::REST::Stats::Cateogry' do
|
|
40
98
|
expect(stat.metrics.unique_opens.nil?).to be(false)
|
41
99
|
expect(stat.metrics.unsubscribe_drops.nil?).to be(false)
|
42
100
|
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
101
|
+
expect(stat.name).to be_a(String)
|
102
|
+
expect(stat.type).to eq('category')
|
103
|
+
end
|
104
|
+
rescue => e
|
105
|
+
puts e.inspect
|
106
|
+
raise e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it '#get_categories_stats_sums with all params' do
|
111
|
+
begin
|
112
|
+
top_stat = @client.get_categories_stats_sums(
|
113
|
+
start_date: '2015-01-01',
|
114
|
+
end_date: '2015-01-02',
|
115
|
+
sort_by_metric: 'opens',
|
116
|
+
sort_by_direction: 'desc',
|
117
|
+
limit: 5,
|
118
|
+
offset: 0
|
119
|
+
)
|
120
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
121
|
+
expect(top_stat.stats.length).to eq(0)
|
122
|
+
top_stat.stats.each do |stat|
|
123
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
124
|
+
expect(stat.metrics_a).to be(SendGrid4r::REST::Stats::Metric)
|
43
125
|
end
|
126
|
+
rescue => e
|
127
|
+
puts e.inspect
|
128
|
+
raise e
|
44
129
|
end
|
45
130
|
end
|
46
|
-
|
47
|
-
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'with block call' do
|
134
|
+
it '#get_category_stats with all params' do
|
135
|
+
@client.get_categories_stats(
|
48
136
|
start_date: '2015-01-01',
|
49
137
|
end_date: '2015-01-02',
|
50
138
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
51
139
|
categories: 'yui'
|
52
|
-
)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
61
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
140
|
+
) do |resp, req, res|
|
141
|
+
resp =
|
142
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
143
|
+
JSON.parse(resp)
|
144
|
+
)
|
145
|
+
expect(resp).to be_a(Array)
|
146
|
+
resp.each do |stat|
|
147
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
62
148
|
end
|
149
|
+
expect(req).to be_a(RestClient::Request)
|
150
|
+
expect(res).to be_a(Net::HTTPOK)
|
63
151
|
end
|
64
152
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
actual = @client.get_categories_stats_sums(start_date: '2015-01-01')
|
69
|
-
expect(actual.class).to be(SendGrid4r::REST::Stats::TopStat)
|
70
|
-
stats = actual.stats
|
71
|
-
expect(stats.length > 0).to eq(true)
|
72
|
-
stats.each do |stat|
|
73
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
74
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
75
|
-
expect(stat.metrics.blocks.nil?).to be(false)
|
76
|
-
expect(stat.metrics.bounce_drops.nil?).to be(false)
|
77
|
-
expect(stat.metrics.bounces.nil?).to be(false)
|
78
|
-
expect(stat.metrics.clicks.nil?).to be(false)
|
79
|
-
expect(stat.metrics.deferred.nil?).to be(false)
|
80
|
-
expect(stat.metrics.delivered.nil?).to be(false)
|
81
|
-
expect(stat.metrics.invalid_emails.nil?).to be(false)
|
82
|
-
expect(stat.metrics.opens.nil?).to be(false)
|
83
|
-
expect(stat.metrics.processed.nil?).to be(false)
|
84
|
-
expect(stat.metrics.requests.nil?).to be(false)
|
85
|
-
expect(stat.metrics.spam_report_drops.nil?).to be(false)
|
86
|
-
expect(stat.metrics.spam_reports.nil?).to be(false)
|
87
|
-
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
88
|
-
expect(stat.metrics.unique_opens.nil?).to be(false)
|
89
|
-
expect(stat.metrics.unsubscribe_drops.nil?).to be(false)
|
90
|
-
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
it 'returns categories stats sums if specify all params' do
|
94
|
-
actual = @client.get_categories_stats_sums(
|
153
|
+
|
154
|
+
it '#get_categories_stats_sums with all params' do
|
155
|
+
@client.get_categories_stats_sums(
|
95
156
|
start_date: '2015-01-01',
|
96
157
|
end_date: '2015-01-02',
|
97
158
|
sort_by_metric: 'opens',
|
98
159
|
sort_by_direction: 'desc',
|
99
160
|
limit: 5,
|
100
161
|
offset: 0
|
101
|
-
)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
expect(
|
107
|
-
expect(
|
162
|
+
) do |resp, req, res|
|
163
|
+
resp =
|
164
|
+
SendGrid4r::REST::Stats.create_top_stat(
|
165
|
+
JSON.parse(resp)
|
166
|
+
)
|
167
|
+
expect(resp).to be_a(SendGrid4r::REST::Stats::TopStat)
|
168
|
+
expect(req).to be_a(RestClient::Request)
|
169
|
+
expect(res).to be_a(Net::HTTPOK)
|
108
170
|
end
|
109
171
|
end
|
110
172
|
end
|
data/spec/stats/global_spec.rb
CHANGED
@@ -1,62 +1,89 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../spec_helper'
|
3
3
|
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
describe SendGrid4r::REST::Stats::Global do
|
5
|
+
describe 'integration test' do
|
6
|
+
before do
|
7
|
+
Dotenv.load
|
8
|
+
@client = SendGrid4r::Client.new(
|
9
|
+
username: ENV['SENDGRID_USERNAME'],
|
10
|
+
password: ENV['SENDGRID_PASSWORD'])
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
expect(stat.metrics.unsubscribe_drops.nil?).to be(false)
|
39
|
-
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
13
|
+
context 'without block call' do
|
14
|
+
it '#get_global_stats with mandatory params' do
|
15
|
+
begin
|
16
|
+
top_stats = @client.get_global_stats(start_date: '2015-01-01')
|
17
|
+
expect(top_stats).to be_a(Array)
|
18
|
+
top_stats.each do |top_stat|
|
19
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
20
|
+
top_stat.stats.each do |stat|
|
21
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
22
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
23
|
+
expect(stat.metrics.blocks.nil?).to be(false)
|
24
|
+
expect(stat.metrics.bounce_drops.nil?).to be(false)
|
25
|
+
expect(stat.metrics.bounces.nil?).to be(false)
|
26
|
+
expect(stat.metrics.clicks.nil?).to be(false)
|
27
|
+
expect(stat.metrics.deferred.nil?).to be(false)
|
28
|
+
expect(stat.metrics.delivered.nil?).to be(false)
|
29
|
+
expect(stat.metrics.invalid_emails.nil?).to be(false)
|
30
|
+
expect(stat.metrics.opens.nil?).to be(false)
|
31
|
+
expect(stat.metrics.processed.nil?).to be(false)
|
32
|
+
expect(stat.metrics.requests.nil?).to be(false)
|
33
|
+
expect(stat.metrics.spam_report_drops.nil?).to be(false)
|
34
|
+
expect(stat.metrics.spam_reports.nil?).to be(false)
|
35
|
+
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
36
|
+
expect(stat.metrics.unique_opens.nil?).to be(false)
|
37
|
+
expect(stat.metrics.unsubscribe_drops.nil?).to be(false)
|
38
|
+
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
39
|
+
end
|
40
40
|
end
|
41
|
+
rescue => e
|
42
|
+
puts e.inspect
|
43
|
+
raise e
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
it '
|
45
|
-
|
47
|
+
it '#get_global_stats with all params' do
|
48
|
+
begin
|
49
|
+
top_stats = @client.get_global_stats(
|
50
|
+
start_date: '2015-01-01',
|
51
|
+
end_date: '2015-01-01',
|
52
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
53
|
+
)
|
54
|
+
expect(top_stats).to be_a(Array)
|
55
|
+
top_stats.each do |top_stat|
|
56
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
57
|
+
stats = top_stat.stats
|
58
|
+
stats.each do |stat|
|
59
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
60
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
rescue => e
|
64
|
+
puts e.inspect
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with block call' do
|
71
|
+
it '#get_global_stats with all params' do
|
72
|
+
@client.get_global_stats(
|
46
73
|
start_date: '2015-01-01',
|
47
74
|
end_date: '2015-01-01',
|
48
75
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
49
|
-
)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
58
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
76
|
+
) do |resp, req, res|
|
77
|
+
resp =
|
78
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
79
|
+
JSON.parse(resp)
|
80
|
+
)
|
81
|
+
expect(resp).to be_a(Array)
|
82
|
+
resp.each do |stat|
|
83
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
59
84
|
end
|
85
|
+
expect(req).to be_a(RestClient::Request)
|
86
|
+
expect(res).to be_a(Net::HTTPOK)
|
60
87
|
end
|
61
88
|
end
|
62
89
|
end
|
data/spec/stats/parse_spec.rb
CHANGED
@@ -1,47 +1,64 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../spec_helper'
|
3
3
|
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
describe SendGrid4r::REST::Stats::Parse do
|
5
|
+
describe 'integration test' do
|
6
|
+
before do
|
7
|
+
Dotenv.load
|
8
|
+
@client = SendGrid4r::Client.new(
|
9
|
+
username: ENV['SENDGRID_USERNAME'],
|
10
|
+
password: ENV['SENDGRID_PASSWORD'])
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
stats = global_stat.stats
|
20
|
-
expect(stats.length).to eq(1)
|
21
|
-
stats.each do |stat|
|
22
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
13
|
+
context 'without block call' do
|
14
|
+
it '#get_parse_stats with mandatory params' do
|
15
|
+
top_stats = @client.get_parse_stats(start_date: '2015-01-01')
|
16
|
+
expect(top_stats).to be_a(Array)
|
17
|
+
top_stats.each do |top_stat|
|
18
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
19
|
+
top_stat.stats.each do |stat|
|
20
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
23
21
|
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
24
22
|
expect(stat.metrics.received.nil?).to be(false)
|
25
23
|
expect(stat.metrics.blocks.nil?).to be(true)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
29
|
-
|
30
|
-
|
27
|
+
|
28
|
+
it '#get_parse_stats with all params' do
|
29
|
+
top_stats = @client.get_parse_stats(
|
31
30
|
start_date: '2015-01-01',
|
32
31
|
end_date: '2015-01-02',
|
33
32
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
34
33
|
)
|
35
|
-
expect(
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
expect(top_stats).to be_a(Array)
|
35
|
+
top_stats.each do |top_stat|
|
36
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
37
|
+
top_stat.stats.each do |stat|
|
38
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
39
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with block call' do
|
46
|
+
it '#get_parse_stats with all params' do
|
47
|
+
@client.get_parse_stats(
|
48
|
+
start_date: '2015-01-01',
|
49
|
+
end_date: '2015-01-02',
|
50
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
51
|
+
) do |resp, req, res|
|
52
|
+
resp =
|
53
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
54
|
+
JSON.parse(resp)
|
55
|
+
)
|
56
|
+
expect(resp).to be_a(Array)
|
57
|
+
resp.each do |stat|
|
58
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
44
59
|
end
|
60
|
+
expect(req).to be_a(RestClient::Request)
|
61
|
+
expect(res).to be_a(Net::HTTPOK)
|
45
62
|
end
|
46
63
|
end
|
47
64
|
end
|