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/advanced_spec.rb
CHANGED
@@ -1,241 +1,418 @@
|
|
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::Advanced 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
|
12
|
+
|
13
|
+
context 'without block call' do
|
14
|
+
it '#get_geo_stats with mandatory params' do
|
15
|
+
begin
|
16
|
+
top_stats = @client.get_geo_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
|
+
expect(top_stat.date).to be_a(String)
|
21
|
+
expect(top_stat.stats).to be_a(Array)
|
22
|
+
top_stat.stats.each do |stat|
|
23
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
24
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
25
|
+
expect(stat.metrics.clicks.nil?).to be(false)
|
26
|
+
expect(stat.metrics.opens.nil?).to be(false)
|
27
|
+
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
28
|
+
expect(stat.metrics.unique_opens.nil?).to be(false)
|
29
|
+
expect(stat.name).to be_a(String)
|
30
|
+
expect(stat.type).to eq('country')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
rescue => e
|
34
|
+
puts e.inspect
|
35
|
+
raise e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it '#get_geo_stats with all params' do
|
40
|
+
begin
|
41
|
+
top_stats = @client.get_geo_stats(
|
42
|
+
start_date: '2015-01-01',
|
43
|
+
end_date: '2015-01-02',
|
44
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
45
|
+
country: 'US'
|
46
|
+
)
|
47
|
+
expect(top_stats).to be_a(Array)
|
48
|
+
top_stats.each do |top_stat|
|
49
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
50
|
+
expect(top_stat.date).to be_a(String)
|
51
|
+
expect(top_stat.stats).to be_a(Array)
|
52
|
+
top_stat.stats.each do |stat|
|
53
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
54
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
rescue => e
|
58
|
+
puts e.inspect
|
59
|
+
raise e
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it '#get_devices_stats with mandatory params' do
|
64
|
+
begin
|
65
|
+
top_stats = @client.get_devices_stats(start_date: '2015-01-01')
|
66
|
+
expect(top_stats).to be_a(Array)
|
67
|
+
top_stats.each do |top_stat|
|
68
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
69
|
+
expect(top_stat.date).to be_a(String)
|
70
|
+
expect(top_stat.stats).to be_a(Array)
|
71
|
+
top_stat.stats.each do |stat|
|
72
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
73
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
74
|
+
expect(stat.name).to be_a(String)
|
75
|
+
expect(stat.type).to eq('device')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
rescue => e
|
79
|
+
puts e.inspect
|
80
|
+
raise e
|
81
|
+
end
|
82
|
+
end
|
10
83
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
expect(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
expect(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
84
|
+
it '#get_devices_stats with all params' do
|
85
|
+
begin
|
86
|
+
top_stats = @client.get_devices_stats(
|
87
|
+
start_date: '2015-01-01',
|
88
|
+
end_date: '2015-01-02',
|
89
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
90
|
+
)
|
91
|
+
expect(top_stats).to be_a(Array)
|
92
|
+
top_stats.each do |top_stat|
|
93
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
94
|
+
expect(top_stat.date).to be_a(String)
|
95
|
+
expect(top_stat.stats).to be_a(Array)
|
96
|
+
top_stat.stats.each do |stat|
|
97
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
98
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
rescue => e
|
102
|
+
puts e.inspect
|
103
|
+
raise e
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it '#get_clients_stats with mandatory params' do
|
108
|
+
begin
|
109
|
+
top_stats = @client.get_clients_stats(start_date: '2015-01-01')
|
110
|
+
expect(top_stats).to be_a(Array)
|
111
|
+
top_stats.each do |top_stat|
|
112
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
113
|
+
expect(top_stat.date).to be_a(String)
|
114
|
+
expect(top_stat.stats).to be_a(Array)
|
115
|
+
top_stat.stats.each do |stat|
|
116
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
117
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
118
|
+
expect(stat.name).to be_a(String)
|
119
|
+
expect(stat.type).to eq('client')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
rescue => e
|
123
|
+
puts e.inspect
|
124
|
+
raise e
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
it '#get_clients_stats with all params' do
|
129
|
+
begin
|
130
|
+
top_stats = @client.get_clients_stats(
|
131
|
+
start_date: '2015-01-01',
|
132
|
+
end_date: '2015-01-02',
|
133
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
134
|
+
)
|
135
|
+
expect(top_stats).to be_a(Array)
|
136
|
+
top_stats.each do |top_stat|
|
137
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
138
|
+
expect(top_stat.date).to be_a(String)
|
139
|
+
expect(top_stat.stats).to be_a(Array)
|
140
|
+
top_stat.stats.each do |stat|
|
141
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
142
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
rescue => e
|
146
|
+
puts e.inspect
|
147
|
+
raise e
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
it '#get_clients_type_stats with mandatory params' do
|
152
|
+
begin
|
153
|
+
top_stats = @client.get_clients_type_stats(
|
154
|
+
start_date: '2015-01-01', client_type: 'webmail'
|
155
|
+
)
|
156
|
+
expect(top_stats).to be_a(Array)
|
157
|
+
top_stats.each do |top_stat|
|
158
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
159
|
+
expect(top_stat.date).to be_a(String)
|
160
|
+
expect(top_stat.stats).to be_a(Array)
|
161
|
+
top_stat.stats.each do |stat|
|
162
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
163
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
164
|
+
expect(stat.name).to be_a(String)
|
165
|
+
expect(stat.type).to eq('client')
|
166
|
+
end
|
167
|
+
end
|
168
|
+
rescue => e
|
169
|
+
puts e.inspect
|
170
|
+
raise e
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it '#get_clients_stats with all params' do
|
175
|
+
begin
|
176
|
+
top_stats = @client.get_clients_type_stats(
|
177
|
+
start_date: '2015-01-01',
|
178
|
+
end_date: '2015-01-02',
|
179
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
180
|
+
client_type: 'webmail'
|
181
|
+
)
|
182
|
+
expect(top_stats).to be_a(Array)
|
183
|
+
top_stats.each do |top_stat|
|
184
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
185
|
+
expect(top_stat.date).to be_a(String)
|
186
|
+
expect(top_stat.stats).to be_a(Array)
|
187
|
+
top_stat.stats.each do |stat|
|
188
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
189
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
rescue => e
|
193
|
+
puts e.inspect
|
194
|
+
raise e
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
it '#get_mailbox_providers_stats with mandatory params' do
|
199
|
+
begin
|
200
|
+
top_stats =
|
201
|
+
@client.get_mailbox_providers_stats(start_date: '2015-01-01')
|
202
|
+
expect(top_stats).to be_a(Array)
|
203
|
+
top_stats.each do |top_stat|
|
204
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
205
|
+
expect(top_stat.date).to be_a(String)
|
206
|
+
expect(top_stat.stats).to be_a(Array)
|
207
|
+
top_stat.stats.each do |stat|
|
208
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
209
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
210
|
+
expect(stat.metrics.blocks.nil?).to be(false)
|
211
|
+
expect(stat.metrics.bounces.nil?).to be(false)
|
212
|
+
expect(stat.metrics.clicks.nil?).to be(false)
|
213
|
+
expect(stat.metrics.deferred.nil?).to be(false)
|
214
|
+
expect(stat.metrics.delivered.nil?).to be(false)
|
215
|
+
expect(stat.metrics.drops.nil?).to be(false)
|
216
|
+
expect(stat.metrics.opens.nil?).to be(false)
|
217
|
+
expect(stat.metrics.spam_reports.nil?).to be(false)
|
218
|
+
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
219
|
+
expect(stat.metrics.unique_opens.nil?).to be(false)
|
220
|
+
expect(stat.name).to be_a(String)
|
221
|
+
expect(stat.type).to eq('mailbox_provider')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
rescue => e
|
225
|
+
puts e.inspect
|
226
|
+
raise e
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it '#get_mailbox_providers_stats with all params' do
|
231
|
+
begin
|
232
|
+
top_stats = @client.get_mailbox_providers_stats(
|
233
|
+
start_date: '2015-01-01',
|
234
|
+
end_date: '2015-01-02',
|
235
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
236
|
+
esps: 'sss'
|
237
|
+
)
|
238
|
+
expect(top_stats).to be_a(Array)
|
239
|
+
top_stats.each do |top_stat|
|
240
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
241
|
+
expect(top_stat.date).to be_a(String)
|
242
|
+
expect(top_stat.stats).to be_a(Array)
|
243
|
+
top_stat.stats.each do |stat|
|
244
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
245
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
rescue => e
|
249
|
+
puts e.inspect
|
250
|
+
raise e
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
it '#get_browsers_stats with mandatory params' do
|
255
|
+
begin
|
256
|
+
top_stats = @client.get_browsers_stats(start_date: '2015-01-01')
|
257
|
+
expect(top_stats).to be_a(Array)
|
258
|
+
top_stats.each do |top_stat|
|
259
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
260
|
+
expect(top_stat.date).to be_a(String)
|
261
|
+
expect(top_stat.stats).to be_a(Array)
|
262
|
+
top_stat.stats.each do |stat|
|
263
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
264
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
265
|
+
expect(stat.name).to eq(nil)
|
266
|
+
expect(stat.type).to eq('browser')
|
267
|
+
end
|
268
|
+
end
|
269
|
+
rescue => e
|
270
|
+
puts e.inspect
|
271
|
+
raise e
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
it '#get_browsers_stats with all params' do
|
276
|
+
begin
|
277
|
+
top_stats = @client.get_browsers_stats(
|
278
|
+
start_date: '2015-01-01',
|
279
|
+
end_date: '2015-01-02',
|
280
|
+
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
281
|
+
browsers: 'chrome'
|
282
|
+
)
|
283
|
+
expect(top_stats).to be_a(Array)
|
284
|
+
top_stats.each do |top_stat|
|
285
|
+
expect(top_stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
286
|
+
expect(top_stat.date).to be_a(String)
|
287
|
+
expect(top_stat.stats).to be_a(Array)
|
288
|
+
top_stat.stats.each do |stat|
|
289
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
290
|
+
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
rescue => e
|
294
|
+
puts e.inspect
|
295
|
+
raise e
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
context 'with block call' do
|
301
|
+
it '#get_geo_stats with all params' do
|
302
|
+
@client.get_geo_stats(
|
33
303
|
start_date: '2015-01-01',
|
34
304
|
end_date: '2015-01-02',
|
35
305
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
36
306
|
country: 'US'
|
37
|
-
)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
46
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
307
|
+
) do |resp, req, res|
|
308
|
+
resp =
|
309
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
310
|
+
JSON.parse(resp)
|
311
|
+
)
|
312
|
+
expect(resp).to be_a(Array)
|
313
|
+
resp.each do |stat|
|
314
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
47
315
|
end
|
316
|
+
expect(req).to be_a(RestClient::Request)
|
317
|
+
expect(res).to be_a(Net::HTTPOK)
|
48
318
|
end
|
49
319
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
actual = @client.get_devices_stats(start_date: '2015-01-01')
|
54
|
-
expect(actual.class).to be(Array)
|
55
|
-
expect(actual.length > 0).to be(true)
|
56
|
-
actual.each do |global_stat|
|
57
|
-
expect(global_stat.class).to be(SendGrid4r::REST::Stats::TopStat)
|
58
|
-
stats = global_stat.stats
|
59
|
-
expect(stats.length).to eq(5)
|
60
|
-
stats.each do |stat|
|
61
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
62
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
63
|
-
expect(stat.metrics.opens.nil?).to be(false)
|
64
|
-
expect(stat.metrics.unique_opens.nil?).to be(false)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
it 'returns devices stats if specify all params' do
|
69
|
-
actual = @client.get_devices_stats(
|
320
|
+
|
321
|
+
it '#get_devices_stats with all params' do
|
322
|
+
@client.get_devices_stats(
|
70
323
|
start_date: '2015-01-01',
|
71
324
|
end_date: '2015-01-02',
|
72
325
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
73
|
-
)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
82
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
326
|
+
) do |resp, req, res|
|
327
|
+
resp =
|
328
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
329
|
+
JSON.parse(resp)
|
330
|
+
)
|
331
|
+
expect(resp).to be_a(Array)
|
332
|
+
resp.each do |stat|
|
333
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
83
334
|
end
|
335
|
+
expect(req).to be_a(RestClient::Request)
|
336
|
+
expect(res).to be_a(Net::HTTPOK)
|
84
337
|
end
|
85
338
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
actual = @client.get_clients_stats(start_date: '2015-01-01')
|
90
|
-
expect(actual.class).to be(Array)
|
91
|
-
expect(actual.length > 0).to be(true)
|
92
|
-
actual.each do |global_stat|
|
93
|
-
expect(global_stat.class).to be(SendGrid4r::REST::Stats::TopStat)
|
94
|
-
stats = global_stat.stats
|
95
|
-
expect(stats.length).to eq(17)
|
96
|
-
stats.each do |stat|
|
97
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
98
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
99
|
-
expect(stat.metrics.opens.nil?).to be(false)
|
100
|
-
expect(stat.metrics.unique_opens.nil?).to be(false)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
it 'returns clients stats if specify all params' do
|
105
|
-
actual = @client.get_clients_stats(
|
339
|
+
|
340
|
+
it '#get_clients_stats with all params' do
|
341
|
+
@client.get_clients_stats(
|
106
342
|
start_date: '2015-01-01',
|
107
343
|
end_date: '2015-01-02',
|
108
344
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
109
|
-
)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
118
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
345
|
+
) do |resp, req, res|
|
346
|
+
resp =
|
347
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
348
|
+
JSON.parse(resp)
|
349
|
+
)
|
350
|
+
expect(resp).to be_a(Array)
|
351
|
+
resp.each do |stat|
|
352
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
119
353
|
end
|
354
|
+
expect(req).to be_a(RestClient::Request)
|
355
|
+
expect(res).to be_a(Net::HTTPOK)
|
120
356
|
end
|
121
357
|
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
actual = @client.get_clients_type_stats(
|
126
|
-
start_date: '2015-01-01', client_type: 'webmail'
|
127
|
-
)
|
128
|
-
expect(actual.class).to be(Array)
|
129
|
-
expect(actual.length > 0).to be(true)
|
130
|
-
actual.each do |global_stat|
|
131
|
-
expect(global_stat.class).to be(SendGrid4r::REST::Stats::TopStat)
|
132
|
-
stats = global_stat.stats
|
133
|
-
expect(stats.length).to eq(5)
|
134
|
-
stats.each do |stat|
|
135
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
136
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
137
|
-
expect(stat.metrics.opens.nil?).to be(false)
|
138
|
-
expect(stat.metrics.unique_opens.nil?).to be(false)
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
it 'returns clients type stats if specify all params' do
|
143
|
-
actual = @client.get_clients_type_stats(
|
358
|
+
|
359
|
+
it '#get_clients_type_stats with all params' do
|
360
|
+
@client.get_clients_type_stats(
|
144
361
|
start_date: '2015-01-01',
|
145
362
|
end_date: '2015-01-02',
|
146
363
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
147
364
|
client_type: 'webmail'
|
148
|
-
)
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
157
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
365
|
+
) do |resp, req, res|
|
366
|
+
resp =
|
367
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
368
|
+
JSON.parse(resp)
|
369
|
+
)
|
370
|
+
expect(resp).to be_a(Array)
|
371
|
+
resp.each do |stat|
|
372
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
158
373
|
end
|
374
|
+
expect(req).to be_a(RestClient::Request)
|
375
|
+
expect(res).to be_a(Net::HTTPOK)
|
159
376
|
end
|
160
377
|
end
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
actual = @client.get_esp_stats(start_date: '2015-01-01')
|
165
|
-
expect(actual.class).to be(Array)
|
166
|
-
expect(actual.length > 0).to be(true)
|
167
|
-
actual.each do |global_stat|
|
168
|
-
expect(global_stat.class).to be(SendGrid4r::REST::Stats::TopStat)
|
169
|
-
stats = global_stat.stats
|
170
|
-
expect(stats.length).to eq(1)
|
171
|
-
stats.each do |stat|
|
172
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
173
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
174
|
-
expect(stat.metrics.blocks.nil?).to be(false)
|
175
|
-
expect(stat.metrics.bounces.nil?).to be(false)
|
176
|
-
expect(stat.metrics.clicks.nil?).to be(false)
|
177
|
-
expect(stat.metrics.deferred.nil?).to be(false)
|
178
|
-
expect(stat.metrics.delivered.nil?).to be(false)
|
179
|
-
expect(stat.metrics.drops.nil?).to be(false)
|
180
|
-
expect(stat.metrics.opens.nil?).to be(false)
|
181
|
-
expect(stat.metrics.spam_reports.nil?).to be(false)
|
182
|
-
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
183
|
-
expect(stat.metrics.unique_opens.nil?).to be(false)
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
it 'returns esp stats if specify all params' do
|
188
|
-
actual = @client.get_esp_stats(
|
378
|
+
|
379
|
+
it '#get_mailbox_providers_stats with all params' do
|
380
|
+
@client.get_mailbox_providers_stats(
|
189
381
|
start_date: '2015-01-01',
|
190
382
|
end_date: '2015-01-02',
|
191
383
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
192
384
|
esps: 'sss'
|
193
|
-
)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
expect(stat
|
201
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
385
|
+
) do |resp, req, res|
|
386
|
+
resp =
|
387
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
388
|
+
JSON.parse(resp)
|
389
|
+
)
|
390
|
+
expect(resp).to be_a(Array)
|
391
|
+
resp.each do |stat|
|
392
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
202
393
|
end
|
394
|
+
expect(req).to be_a(RestClient::Request)
|
395
|
+
expect(res).to be_a(Net::HTTPOK)
|
203
396
|
end
|
204
397
|
end
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
actual = @client.get_browsers_stats(start_date: '2015-01-01')
|
209
|
-
expect(actual.class).to be(Array)
|
210
|
-
expect(actual.length > 0).to be(true)
|
211
|
-
actual.each do |global_stat|
|
212
|
-
expect(global_stat.class).to be(SendGrid4r::REST::Stats::TopStat)
|
213
|
-
stats = global_stat.stats
|
214
|
-
expect(stats.length).to eq(1)
|
215
|
-
stats.each do |stat|
|
216
|
-
expect(stat.class).to be(SendGrid4r::REST::Stats::Stat)
|
217
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
218
|
-
expect(stat.metrics.clicks.nil?).to be(false)
|
219
|
-
expect(stat.metrics.unique_clicks.nil?).to be(false)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
it 'returns browsers stats if specify all params' do
|
224
|
-
actual = @client.get_browsers_stats(
|
398
|
+
|
399
|
+
it '#get_browsers_stats with all params' do
|
400
|
+
@client.get_browsers_stats(
|
225
401
|
start_date: '2015-01-01',
|
226
402
|
end_date: '2015-01-02',
|
227
403
|
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
228
404
|
browsers: 'chrome'
|
229
|
-
)
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
expect(stat
|
237
|
-
expect(stat.metrics.class).to be(SendGrid4r::REST::Stats::Metric)
|
405
|
+
) do |resp, req, res|
|
406
|
+
resp =
|
407
|
+
SendGrid4r::REST::Stats.create_top_stats(
|
408
|
+
JSON.parse(resp)
|
409
|
+
)
|
410
|
+
expect(resp).to be_a(Array)
|
411
|
+
resp.each do |stat|
|
412
|
+
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
238
413
|
end
|
414
|
+
expect(req).to be_a(RestClient::Request)
|
415
|
+
expect(res).to be_a(Net::HTTPOK)
|
239
416
|
end
|
240
417
|
end
|
241
418
|
end
|