sendgrid4r 0.5.0 → 1.0.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 +6 -8
- data/.rubocop.yml +1 -1
- data/README.md +0 -2
- data/lib/sendgrid4r/rest/api.rb +6 -0
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +5 -5
- data/lib/sendgrid4r/rest/asm/global_suppressions.rb +3 -3
- data/lib/sendgrid4r/rest/asm/groups.rb +4 -4
- data/lib/sendgrid4r/rest/asm/suppressions.rb +4 -4
- data/lib/sendgrid4r/rest/categories/categories.rb +1 -1
- data/lib/sendgrid4r/rest/contacts/custom_fields.rb +3 -3
- data/lib/sendgrid4r/rest/contacts/lists.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/recipients.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/segments.rb +5 -5
- data/lib/sendgrid4r/rest/ips/addresses.rb +3 -3
- data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
- data/lib/sendgrid4r/rest/ips/warmup.rb +6 -6
- data/lib/sendgrid4r/rest/request.rb +2 -2
- data/lib/sendgrid4r/rest/subusers/subusers.rb +63 -3
- data/lib/sendgrid4r/rest/templates/templates.rb +14 -9
- data/lib/sendgrid4r/rest/templates/versions.rb +12 -10
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +257 -0
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +140 -0
- data/lib/sendgrid4r/rest/whitelabel/links.rb +185 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +93 -1
- data/spec/rest/api_keys/api_keys_spec.rb +23 -55
- data/spec/rest/asm/global_suppressions_spec.rb +40 -68
- data/spec/rest/asm/groups_spec.rb +31 -82
- data/spec/rest/asm/suppressions_spec.rb +33 -76
- data/spec/rest/categories/categories_spec.rb +8 -27
- data/spec/rest/contacts/custom_fields_spec.rb +18 -71
- data/spec/rest/contacts/lists_spec.rb +64 -187
- data/spec/rest/contacts/recipients_spec.rb +41 -196
- data/spec/rest/contacts/reserved_fields_spec.rb +2 -20
- data/spec/rest/contacts/segments_spec.rb +47 -33
- data/spec/rest/email_activity/email_activity_spec.rb +8 -21
- data/spec/rest/ips/addresses_spec.rb +18 -77
- data/spec/rest/ips/pools_spec.rb +21 -80
- data/spec/rest/ips/warmup_spec.rb +11 -58
- data/spec/rest/settings/enforced_tls_spec.rb +3 -40
- data/spec/rest/settings/mail_spec.rb +21 -294
- data/spec/rest/settings/partner_spec.rb +6 -79
- data/spec/rest/settings/tracking_spec.rb +10 -147
- data/spec/rest/stats/advanced_spec.rb +13 -135
- data/spec/rest/stats/category_spec.rb +5 -48
- data/spec/rest/stats/global_spec.rb +3 -5
- data/spec/rest/stats/parse_spec.rb +1 -24
- data/spec/rest/stats/subuser_spec.rb +6 -49
- data/spec/rest/subusers/subusers_spec.rb +156 -81
- data/spec/rest/templates/templates_spec.rb +32 -81
- data/spec/rest/templates/versions_spec.rb +50 -28
- data/spec/rest/whitelabel/domains_spec.rb +637 -0
- data/spec/rest/whitelabel/ips_spec.rb +231 -0
- data/spec/rest/whitelabel/links_spec.rb +359 -0
- metadata +22 -8
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
Dotenv.load
|
8
|
-
@client = SendGrid4r::Client.new(
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'without block call' do
|
@@ -17,7 +15,7 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
17
15
|
expect(
|
18
16
|
actual
|
19
17
|
).to be_a(SendGrid4r::REST::Settings::Results)
|
20
|
-
rescue => e
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
19
|
puts e.inspect
|
22
20
|
raise e
|
23
21
|
end
|
@@ -29,7 +27,7 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
29
27
|
expect(actual).to be_a(
|
30
28
|
SendGrid4r::REST::Settings::Partner::Partner
|
31
29
|
)
|
32
|
-
rescue => e
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
33
31
|
puts e.inspect
|
34
32
|
raise e
|
35
33
|
end
|
@@ -45,7 +43,7 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
45
43
|
edit = @client.patch_settings_new_relic(params: actual)
|
46
44
|
expect(edit.enabled).to eq(false)
|
47
45
|
expect(edit.license_key).to eq('new_relic_license_key')
|
48
|
-
rescue => e
|
46
|
+
rescue RestClient::ExceptionWithResponse => e
|
49
47
|
puts e.inspect
|
50
48
|
raise e
|
51
49
|
end
|
@@ -55,7 +53,7 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
55
53
|
begin
|
56
54
|
actual = @client.get_settings_sendwithus
|
57
55
|
expect(actual).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
58
|
-
rescue => e
|
56
|
+
rescue RestClient::ExceptionWithResponse => e
|
59
57
|
puts e.inspect
|
60
58
|
raise e
|
61
59
|
end
|
@@ -71,83 +69,12 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
71
69
|
edit = @client.patch_settings_sendwithus(params: actual)
|
72
70
|
expect(edit.enabled).to eq(false)
|
73
71
|
expect(edit.license_key).to eq('sendwithus_license_key')
|
74
|
-
rescue => e
|
72
|
+
rescue RestClient::ExceptionWithResponse => e
|
75
73
|
puts e.inspect
|
76
74
|
raise e
|
77
75
|
end
|
78
76
|
end
|
79
77
|
end
|
80
|
-
|
81
|
-
context 'with block call' do
|
82
|
-
it '#get_partner_settings' do
|
83
|
-
@client.get_partner_settings do |resp, req, res|
|
84
|
-
resp =
|
85
|
-
SendGrid4r::REST::Settings.create_results(
|
86
|
-
JSON.parse(resp)
|
87
|
-
)
|
88
|
-
expect(resp).to be_a(SendGrid4r::REST::Settings::Results)
|
89
|
-
resp.result.each do |result|
|
90
|
-
expect(result).to be_a(SendGrid4r::REST::Settings::Result)
|
91
|
-
end
|
92
|
-
expect(req).to be_a(RestClient::Request)
|
93
|
-
expect(res).to be_a(Net::HTTPOK)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
it '#get_settings_new_relic' do
|
98
|
-
@client.get_settings_new_relic do |resp, req, res|
|
99
|
-
resp =
|
100
|
-
SendGrid4r::REST::Settings::Partner.create_partner(
|
101
|
-
JSON.parse(resp)
|
102
|
-
)
|
103
|
-
expect(resp).to be_a(
|
104
|
-
SendGrid4r::REST::Settings::Partner::Partner
|
105
|
-
)
|
106
|
-
expect(req).to be_a(RestClient::Request)
|
107
|
-
expect(res).to be_a(Net::HTTPOK)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
it '#patch_settings_new_relic' do
|
112
|
-
params = @client.get_settings_new_relic
|
113
|
-
@client.patch_settings_new_relic(params: params) do |resp, req, res|
|
114
|
-
resp =
|
115
|
-
SendGrid4r::REST::Settings::Partner.create_partner(
|
116
|
-
JSON.parse(resp)
|
117
|
-
)
|
118
|
-
expect(resp).to be_a(
|
119
|
-
SendGrid4r::REST::Settings::Partner::Partner
|
120
|
-
)
|
121
|
-
expect(req).to be_a(RestClient::Request)
|
122
|
-
expect(res).to be_a(Net::HTTPOK)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
it '#get_settings_sendwithus' do
|
127
|
-
@client.get_settings_sendwithus do |resp, req, res|
|
128
|
-
resp =
|
129
|
-
SendGrid4r::REST::Settings::Partner.create_partner(
|
130
|
-
JSON.parse(resp)
|
131
|
-
)
|
132
|
-
expect(resp).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
133
|
-
expect(req).to be_a(RestClient::Request)
|
134
|
-
expect(res).to be_a(Net::HTTPOK)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
it '#patch_settings_sendwithus' do
|
139
|
-
params = @client.get_settings_sendwithus
|
140
|
-
@client.patch_settings_sendwithus(params: params) do |resp, req, res|
|
141
|
-
resp =
|
142
|
-
SendGrid4r::REST::Settings::Partner.create_partner(
|
143
|
-
JSON.parse(resp)
|
144
|
-
)
|
145
|
-
expect(resp).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
146
|
-
expect(req).to be_a(RestClient::Request)
|
147
|
-
expect(res).to be_a(Net::HTTPOK)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
78
|
end
|
152
79
|
|
153
80
|
describe 'unit test', :ut do
|
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
Dotenv.load
|
8
|
-
@client = SendGrid4r::Client.new(
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'without block call' do
|
@@ -17,7 +15,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
17
15
|
expect(
|
18
16
|
actual
|
19
17
|
).to be_a(SendGrid4r::REST::Settings::Results)
|
20
|
-
rescue => e
|
18
|
+
rescue RestClient::ExceptionWithResponse => e
|
21
19
|
puts e.inspect
|
22
20
|
raise e
|
23
21
|
end
|
@@ -29,7 +27,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
29
27
|
expect(actual).to be_a(
|
30
28
|
SendGrid4r::REST::Settings::Tracking::Click
|
31
29
|
)
|
32
|
-
rescue => e
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
33
31
|
puts e.inspect
|
34
32
|
raise e
|
35
33
|
end
|
@@ -43,7 +41,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
43
41
|
actual.enabled = false
|
44
42
|
edit = @client.patch_settings_click(params: actual)
|
45
43
|
expect(edit.enabled).to eq(false)
|
46
|
-
rescue => e
|
44
|
+
rescue RestClient::ExceptionWithResponse => e
|
47
45
|
puts e.inspect
|
48
46
|
raise e
|
49
47
|
end
|
@@ -55,7 +53,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
55
53
|
expect(actual).to be_a(
|
56
54
|
SendGrid4r::REST::Settings::Tracking::GoogleAnalytics
|
57
55
|
)
|
58
|
-
rescue => e
|
56
|
+
rescue RestClient::ExceptionWithResponse => e
|
59
57
|
puts e.inspect
|
60
58
|
raise e
|
61
59
|
end
|
@@ -79,7 +77,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
79
77
|
expect(edit.utm_term).to eq('c')
|
80
78
|
expect(edit.utm_content).to eq('d')
|
81
79
|
expect(edit.utm_campaign).to eq('e')
|
82
|
-
rescue => e
|
80
|
+
rescue RestClient::ExceptionWithResponse => e
|
83
81
|
puts e.inspect
|
84
82
|
raise e
|
85
83
|
end
|
@@ -91,7 +89,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
91
89
|
expect(actual).to be_a(
|
92
90
|
SendGrid4r::REST::Settings::Tracking::Open
|
93
91
|
)
|
94
|
-
rescue => e
|
92
|
+
rescue RestClient::ExceptionWithResponse => e
|
95
93
|
puts e.inspect
|
96
94
|
raise e
|
97
95
|
end
|
@@ -105,7 +103,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
105
103
|
actual.enabled = false
|
106
104
|
edit = @client.patch_settings_open(params: actual)
|
107
105
|
expect(edit.enabled).to eq(false)
|
108
|
-
rescue => e
|
106
|
+
rescue RestClient::ExceptionWithResponse => e
|
109
107
|
puts e.inspect
|
110
108
|
raise e
|
111
109
|
end
|
@@ -117,7 +115,7 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
117
115
|
expect(actual).to be_a(
|
118
116
|
SendGrid4r::REST::Settings::Tracking::Subscription
|
119
117
|
)
|
120
|
-
rescue => e
|
118
|
+
rescue RestClient::ExceptionWithResponse => e
|
121
119
|
puts e.inspect
|
122
120
|
raise e
|
123
121
|
end
|
@@ -131,147 +129,12 @@ describe SendGrid4r::REST::Settings::Tracking do
|
|
131
129
|
actual.enabled = false
|
132
130
|
edit = @client.patch_settings_subscription(params: actual)
|
133
131
|
expect(edit.enabled).to eq(false)
|
134
|
-
rescue => e
|
132
|
+
rescue RestClient::ExceptionWithResponse => e
|
135
133
|
puts e.inspect
|
136
134
|
raise e
|
137
135
|
end
|
138
136
|
end
|
139
137
|
end
|
140
|
-
|
141
|
-
context 'with block call' do
|
142
|
-
it '#get_tracking_settings' do
|
143
|
-
@client.get_tracking_settings do |resp, req, res|
|
144
|
-
resp =
|
145
|
-
SendGrid4r::REST::Settings.create_results(
|
146
|
-
JSON.parse(resp)
|
147
|
-
)
|
148
|
-
expect(resp).to be_a(SendGrid4r::REST::Settings::Results)
|
149
|
-
resp.result.each do |result|
|
150
|
-
expect(result).to be_a(SendGrid4r::REST::Settings::Result)
|
151
|
-
end
|
152
|
-
expect(req).to be_a(RestClient::Request)
|
153
|
-
expect(res).to be_a(Net::HTTPOK)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
it '#get_settings_click' do
|
158
|
-
@client.get_settings_click do |resp, req, res|
|
159
|
-
resp =
|
160
|
-
SendGrid4r::REST::Settings::Tracking.create_click(
|
161
|
-
JSON.parse(resp)
|
162
|
-
)
|
163
|
-
expect(resp).to be_a(
|
164
|
-
SendGrid4r::REST::Settings::Tracking::Click
|
165
|
-
)
|
166
|
-
expect(req).to be_a(RestClient::Request)
|
167
|
-
expect(res).to be_a(Net::HTTPOK)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
it '#patch_settings_click' do
|
172
|
-
params = @client.get_settings_click
|
173
|
-
@client.patch_settings_click(params: params) do |resp, req, res|
|
174
|
-
resp =
|
175
|
-
SendGrid4r::REST::Settings::Tracking.create_click(
|
176
|
-
JSON.parse(resp)
|
177
|
-
)
|
178
|
-
expect(resp).to be_a(
|
179
|
-
SendGrid4r::REST::Settings::Tracking::Click
|
180
|
-
)
|
181
|
-
expect(req).to be_a(RestClient::Request)
|
182
|
-
expect(res).to be_a(Net::HTTPOK)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
it '#get_settings_google_analytics' do
|
187
|
-
@client.get_settings_google_analytics do |resp, req, res|
|
188
|
-
resp =
|
189
|
-
SendGrid4r::REST::Settings::Tracking.create_google_analytics(
|
190
|
-
JSON.parse(resp)
|
191
|
-
)
|
192
|
-
expect(resp).to be_a(
|
193
|
-
SendGrid4r::REST::Settings::Tracking::GoogleAnalytics
|
194
|
-
)
|
195
|
-
expect(req).to be_a(RestClient::Request)
|
196
|
-
expect(res).to be_a(Net::HTTPOK)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
it '#patch_settings_google_analytics' do
|
201
|
-
params = @client.get_settings_google_analytics
|
202
|
-
@client.patch_settings_google_analytics(
|
203
|
-
params: params
|
204
|
-
) do |resp, req, res|
|
205
|
-
resp =
|
206
|
-
SendGrid4r::REST::Settings::Tracking.create_google_analytics(
|
207
|
-
JSON.parse(resp)
|
208
|
-
)
|
209
|
-
expect(resp).to be_a(
|
210
|
-
SendGrid4r::REST::Settings::Tracking::GoogleAnalytics
|
211
|
-
)
|
212
|
-
expect(req).to be_a(RestClient::Request)
|
213
|
-
expect(res).to be_a(Net::HTTPOK)
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
it '#get_settings_open' do
|
218
|
-
@client.get_settings_open do |resp, req, res|
|
219
|
-
resp =
|
220
|
-
SendGrid4r::REST::Settings::Tracking.create_open(
|
221
|
-
JSON.parse(resp)
|
222
|
-
)
|
223
|
-
expect(resp).to be_a(
|
224
|
-
SendGrid4r::REST::Settings::Tracking::Open
|
225
|
-
)
|
226
|
-
expect(req).to be_a(RestClient::Request)
|
227
|
-
expect(res).to be_a(Net::HTTPOK)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
it '#patch_settings_open' do
|
232
|
-
params = @client.get_settings_open
|
233
|
-
@client.patch_settings_open(params: params) do |resp, req, res|
|
234
|
-
resp =
|
235
|
-
SendGrid4r::REST::Settings::Tracking.create_open(
|
236
|
-
JSON.parse(resp)
|
237
|
-
)
|
238
|
-
expect(resp).to be_a(
|
239
|
-
SendGrid4r::REST::Settings::Tracking::Open
|
240
|
-
)
|
241
|
-
expect(req).to be_a(RestClient::Request)
|
242
|
-
expect(res).to be_a(Net::HTTPOK)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
it '#get_settings_subscription' do
|
247
|
-
@client.get_settings_subscription do |resp, req, res|
|
248
|
-
resp =
|
249
|
-
SendGrid4r::REST::Settings::Tracking.create_subscription(
|
250
|
-
JSON.parse(resp)
|
251
|
-
)
|
252
|
-
expect(resp).to be_a(
|
253
|
-
SendGrid4r::REST::Settings::Tracking::Subscription
|
254
|
-
)
|
255
|
-
expect(req).to be_a(RestClient::Request)
|
256
|
-
expect(res).to be_a(Net::HTTPOK)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
it '#patch_settings_subscription' do
|
261
|
-
params = @client.get_settings_subscription
|
262
|
-
@client.patch_settings_subscription(params: params) do |resp, req, res|
|
263
|
-
resp =
|
264
|
-
SendGrid4r::REST::Settings::Tracking.create_subscription(
|
265
|
-
JSON.parse(resp)
|
266
|
-
)
|
267
|
-
expect(resp).to be_a(
|
268
|
-
SendGrid4r::REST::Settings::Tracking::Subscription
|
269
|
-
)
|
270
|
-
expect(req).to be_a(RestClient::Request)
|
271
|
-
expect(res).to be_a(Net::HTTPOK)
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
138
|
end
|
276
139
|
|
277
140
|
describe 'unit test', :ut do
|
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
Dotenv.load
|
8
|
-
@client = SendGrid4r::Client.new(
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'without block call' do
|
@@ -30,7 +28,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
30
28
|
expect(stat.type).to eq('country')
|
31
29
|
end
|
32
30
|
end
|
33
|
-
rescue => e
|
31
|
+
rescue RestClient::ExceptionWithResponse => e
|
34
32
|
puts e.inspect
|
35
33
|
raise e
|
36
34
|
end
|
@@ -54,7 +52,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
54
52
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
55
53
|
end
|
56
54
|
end
|
57
|
-
rescue => e
|
55
|
+
rescue RestClient::ExceptionWithResponse => e
|
58
56
|
puts e.inspect
|
59
57
|
raise e
|
60
58
|
end
|
@@ -75,7 +73,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
75
73
|
expect(stat.type).to eq('device')
|
76
74
|
end
|
77
75
|
end
|
78
|
-
rescue => e
|
76
|
+
rescue RestClient::ExceptionWithResponse => e
|
79
77
|
puts e.inspect
|
80
78
|
raise e
|
81
79
|
end
|
@@ -98,7 +96,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
98
96
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
99
97
|
end
|
100
98
|
end
|
101
|
-
rescue => e
|
99
|
+
rescue RestClient::ExceptionWithResponse => e
|
102
100
|
puts e.inspect
|
103
101
|
raise e
|
104
102
|
end
|
@@ -119,7 +117,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
119
117
|
expect(stat.type).to eq('client')
|
120
118
|
end
|
121
119
|
end
|
122
|
-
rescue => e
|
120
|
+
rescue RestClient::ExceptionWithResponse => e
|
123
121
|
puts e.inspect
|
124
122
|
raise e
|
125
123
|
end
|
@@ -142,7 +140,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
142
140
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
143
141
|
end
|
144
142
|
end
|
145
|
-
rescue => e
|
143
|
+
rescue RestClient::ExceptionWithResponse => e
|
146
144
|
puts e.inspect
|
147
145
|
raise e
|
148
146
|
end
|
@@ -165,7 +163,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
165
163
|
expect(stat.type).to eq('client')
|
166
164
|
end
|
167
165
|
end
|
168
|
-
rescue => e
|
166
|
+
rescue RestClient::ExceptionWithResponse => e
|
169
167
|
puts e.inspect
|
170
168
|
raise e
|
171
169
|
end
|
@@ -189,7 +187,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
189
187
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
190
188
|
end
|
191
189
|
end
|
192
|
-
rescue => e
|
190
|
+
rescue RestClient::ExceptionWithResponse => e
|
193
191
|
puts e.inspect
|
194
192
|
raise e
|
195
193
|
end
|
@@ -221,7 +219,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
221
219
|
expect(stat.type).to eq('mailbox_provider')
|
222
220
|
end
|
223
221
|
end
|
224
|
-
rescue => e
|
222
|
+
rescue RestClient::ExceptionWithResponse => e
|
225
223
|
puts e.inspect
|
226
224
|
raise e
|
227
225
|
end
|
@@ -245,7 +243,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
245
243
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
246
244
|
end
|
247
245
|
end
|
248
|
-
rescue => e
|
246
|
+
rescue RestClient::ExceptionWithResponse => e
|
249
247
|
puts e.inspect
|
250
248
|
raise e
|
251
249
|
end
|
@@ -266,7 +264,7 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
266
264
|
expect(stat.type).to eq('browser')
|
267
265
|
end
|
268
266
|
end
|
269
|
-
rescue => e
|
267
|
+
rescue RestClient::ExceptionWithResponse => e
|
270
268
|
puts e.inspect
|
271
269
|
raise e
|
272
270
|
end
|
@@ -290,131 +288,11 @@ describe SendGrid4r::REST::Stats::Advanced do
|
|
290
288
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
291
289
|
end
|
292
290
|
end
|
293
|
-
rescue => e
|
291
|
+
rescue RestClient::ExceptionWithResponse => e
|
294
292
|
puts e.inspect
|
295
293
|
raise e
|
296
294
|
end
|
297
295
|
end
|
298
296
|
end
|
299
|
-
|
300
|
-
context 'with block call' do
|
301
|
-
it '#get_geo_stats with all params' do
|
302
|
-
@client.get_geo_stats(
|
303
|
-
start_date: '2015-01-01',
|
304
|
-
end_date: '2015-01-02',
|
305
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
306
|
-
country: 'US'
|
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)
|
315
|
-
end
|
316
|
-
expect(req).to be_a(RestClient::Request)
|
317
|
-
expect(res).to be_a(Net::HTTPOK)
|
318
|
-
end
|
319
|
-
end
|
320
|
-
|
321
|
-
it '#get_devices_stats with all params' do
|
322
|
-
@client.get_devices_stats(
|
323
|
-
start_date: '2015-01-01',
|
324
|
-
end_date: '2015-01-02',
|
325
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
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)
|
334
|
-
end
|
335
|
-
expect(req).to be_a(RestClient::Request)
|
336
|
-
expect(res).to be_a(Net::HTTPOK)
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
it '#get_clients_stats with all params' do
|
341
|
-
@client.get_clients_stats(
|
342
|
-
start_date: '2015-01-01',
|
343
|
-
end_date: '2015-01-02',
|
344
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
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)
|
353
|
-
end
|
354
|
-
expect(req).to be_a(RestClient::Request)
|
355
|
-
expect(res).to be_a(Net::HTTPOK)
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
it '#get_clients_type_stats with all params' do
|
360
|
-
@client.get_clients_type_stats(
|
361
|
-
start_date: '2015-01-01',
|
362
|
-
end_date: '2015-01-02',
|
363
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
364
|
-
client_type: 'webmail'
|
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)
|
373
|
-
end
|
374
|
-
expect(req).to be_a(RestClient::Request)
|
375
|
-
expect(res).to be_a(Net::HTTPOK)
|
376
|
-
end
|
377
|
-
end
|
378
|
-
|
379
|
-
it '#get_mailbox_providers_stats with all params' do
|
380
|
-
@client.get_mailbox_providers_stats(
|
381
|
-
start_date: '2015-01-01',
|
382
|
-
end_date: '2015-01-02',
|
383
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
384
|
-
esps: 'sss'
|
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)
|
393
|
-
end
|
394
|
-
expect(req).to be_a(RestClient::Request)
|
395
|
-
expect(res).to be_a(Net::HTTPOK)
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
it '#get_browsers_stats with all params' do
|
400
|
-
@client.get_browsers_stats(
|
401
|
-
start_date: '2015-01-01',
|
402
|
-
end_date: '2015-01-02',
|
403
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
404
|
-
browsers: 'chrome'
|
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)
|
413
|
-
end
|
414
|
-
expect(req).to be_a(RestClient::Request)
|
415
|
-
expect(res).to be_a(Net::HTTPOK)
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|
419
297
|
end
|
420
298
|
end
|
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Stats::Category do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
Dotenv.load
|
8
|
-
@client = SendGrid4r::Client.new(
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'without block call' do
|
@@ -44,7 +42,7 @@ describe SendGrid4r::REST::Stats::Category do
|
|
44
42
|
expect(stat.type).to eq('category')
|
45
43
|
end
|
46
44
|
end
|
47
|
-
rescue => e
|
45
|
+
rescue RestClient::ExceptionWithResponse => e
|
48
46
|
puts e.inspect
|
49
47
|
raise e
|
50
48
|
end
|
@@ -67,7 +65,7 @@ describe SendGrid4r::REST::Stats::Category do
|
|
67
65
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
68
66
|
end
|
69
67
|
end
|
70
|
-
rescue => e
|
68
|
+
rescue RestClient::ExceptionWithResponse => e
|
71
69
|
puts e.inspect
|
72
70
|
raise e
|
73
71
|
end
|
@@ -101,7 +99,7 @@ describe SendGrid4r::REST::Stats::Category do
|
|
101
99
|
expect(stat.name).to be_a(String)
|
102
100
|
expect(stat.type).to eq('category')
|
103
101
|
end
|
104
|
-
rescue => e
|
102
|
+
rescue RestClient::ExceptionWithResponse => e
|
105
103
|
puts e.inspect
|
106
104
|
raise e
|
107
105
|
end
|
@@ -123,52 +121,11 @@ describe SendGrid4r::REST::Stats::Category do
|
|
123
121
|
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
124
122
|
expect(stat.metrics_a).to be(SendGrid4r::REST::Stats::Metric)
|
125
123
|
end
|
126
|
-
rescue => e
|
124
|
+
rescue RestClient::ExceptionWithResponse => e
|
127
125
|
puts e.inspect
|
128
126
|
raise e
|
129
127
|
end
|
130
128
|
end
|
131
129
|
end
|
132
|
-
|
133
|
-
context 'with block call' do
|
134
|
-
it '#get_category_stats with all params' do
|
135
|
-
@client.get_categories_stats(
|
136
|
-
start_date: '2015-01-01',
|
137
|
-
end_date: '2015-01-02',
|
138
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
139
|
-
categories: 'yui'
|
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)
|
148
|
-
end
|
149
|
-
expect(req).to be_a(RestClient::Request)
|
150
|
-
expect(res).to be_a(Net::HTTPOK)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
it '#get_categories_stats_sums with all params' do
|
155
|
-
@client.get_categories_stats_sums(
|
156
|
-
start_date: '2015-01-01',
|
157
|
-
end_date: '2015-01-02',
|
158
|
-
sort_by_metric: 'opens',
|
159
|
-
sort_by_direction: 'desc',
|
160
|
-
limit: 5,
|
161
|
-
offset: 0
|
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)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
130
|
end
|
174
131
|
end
|