notifications-ruby-client 6.2.0 → 6.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/CHANGELOG.md +6 -0
- data/Dockerfile +3 -1
- data/bin/test_client.rb +70 -61
- data/lib/notifications/client/version.rb +1 -1
- data/notifications-ruby-client.gemspec +6 -3
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77a8a364fe112385dd966dc7d1c694596b5c7e786cb9c88e15f44fdf077868dc
|
4
|
+
data.tar.gz: 4e9dab5c9f3c1162acd687f5281855e6e62b019bafdd3b80b41fd2d524dca431
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d76d657dfaaf195cf47fc547f03cd43070e639e5aa4cb0e83c4704593e59a77af37ffdac614eb8f6167935497f8b7c3a5cc9788ee41b169817b9c8df38ff0d
|
7
|
+
data.tar.gz: 8c7be5c4533ce2e475bdde4db8aea698339bb6f940fa6f71825c7e28299c53c0feebd513d209239a1dae56caf4502ebc8a4cfc5ec6f0f1afe38a08205bccdf6d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 6.3.0
|
2
|
+
* Update dependencies
|
3
|
+
* Permit the `jwt` gem to be upgraded to version 3
|
4
|
+
* Remove the `bundler` gem dependency
|
5
|
+
* Allow the `factory_bot` gem to be upgraded whilst keeping the restriction in place for Ruby versions below 3
|
6
|
+
|
1
7
|
## 6.2.0
|
2
8
|
* Added fields related to cost data in response:
|
3
9
|
* `is_cost_data_ready`: This field is true if cost data is ready, and false if it isn't (Boolean).
|
data/Dockerfile
CHANGED
data/bin/test_client.rb
CHANGED
@@ -24,7 +24,6 @@ def main
|
|
24
24
|
test_get_received_texts
|
25
25
|
test_get_pdf_for_letter(client, letter_notification.id)
|
26
26
|
p 'ruby client integration tests pass'
|
27
|
-
exit 0
|
28
27
|
end
|
29
28
|
|
30
29
|
def test_get_email_template_by_id(client, id)
|
@@ -50,27 +49,23 @@ end
|
|
50
49
|
def test_get_all_templates(client)
|
51
50
|
response = client.get_all_templates
|
52
51
|
unless response.is_a?(Notifications::Client::TemplateCollection)
|
53
|
-
|
54
|
-
exit 1
|
52
|
+
raise 'failed test_get_all_templates response is not a Notifications::Client::TemplateCollection'
|
55
53
|
end
|
56
54
|
unless response.collection.length >= 3
|
57
|
-
|
58
|
-
exit 1
|
55
|
+
raise 'failed test_get_all_templates, expected at least 3 templates returned.'
|
59
56
|
end
|
60
|
-
test_template_response(response.collection[
|
61
|
-
test_template_response(response.collection[
|
62
|
-
test_template_response(response.collection[
|
57
|
+
test_template_response(response.collection.find { |template| template.id == ENV['LETTER_TEMPLATE_ID'] }, 'letter', 'test_get_all_templates')
|
58
|
+
test_template_response(response.collection.find { |template| template.id == ENV['EMAIL_TEMPLATE_ID'] }, 'email', 'test_get_all_templates')
|
59
|
+
test_template_response(response.collection.find { |template| template.id == ENV['SMS_TEMPLATE_ID'] }, 'sms', 'test_get_all_templates')
|
63
60
|
end
|
64
61
|
|
65
62
|
def test_get_all_templates_filter_by_type(client)
|
66
63
|
response = client.get_all_templates('type' => 'sms')
|
67
64
|
unless response.is_a?(Notifications::Client::TemplateCollection)
|
68
|
-
|
69
|
-
exit 1
|
65
|
+
raise 'failed test_get_all_templates response is not a Notifications::Client::TemplateCollection'
|
70
66
|
end
|
71
67
|
unless response.collection.length >= 1
|
72
|
-
|
73
|
-
exit 1
|
68
|
+
raise 'failed test_get_all_templates, expected at least 1 template to be returned.'
|
74
69
|
end
|
75
70
|
test_template_response(response.collection[0], 'sms', 'test_get_all_templates')
|
76
71
|
end
|
@@ -82,12 +77,10 @@ end
|
|
82
77
|
|
83
78
|
def test_template_response(response, template_type, test_method)
|
84
79
|
unless response.is_a?(Notifications::Client::Template)
|
85
|
-
|
86
|
-
exit 1
|
80
|
+
raise 'failed test_get_template_by_id response is not a Notifications::Client::Template'
|
87
81
|
end
|
88
82
|
unless response.id.is_a?(String)
|
89
|
-
|
90
|
-
exit 1
|
83
|
+
raise 'failed template id is not a String'
|
91
84
|
end
|
92
85
|
|
93
86
|
field_should_not_be_nil(
|
@@ -104,12 +97,10 @@ end
|
|
104
97
|
|
105
98
|
def test_template_preview(response)
|
106
99
|
unless response.is_a?(Notifications::Client::TemplatePreview)
|
107
|
-
|
108
|
-
exit 1
|
100
|
+
raise 'failed test_generate_template_preview response is not a Notifications::Client::TemplatePreview'
|
109
101
|
end
|
110
102
|
unless response.id.is_a?(String)
|
111
|
-
|
112
|
-
exit 1
|
103
|
+
raise 'failed template id is not a String'
|
113
104
|
end
|
114
105
|
field_should_not_be_nil(expected_fields_in_template_preview, response, 'generate_template_preview')
|
115
106
|
end
|
@@ -176,19 +167,16 @@ end
|
|
176
167
|
|
177
168
|
def test_notification_response_data_type(notification, message_type)
|
178
169
|
unless notification.is_a?(Notifications::Client::ResponseNotification) || (notification.is_a?(Notifications::Client::ResponsePrecompiledLetter) && message_type == "precompiled_letter")
|
179
|
-
|
180
|
-
exit 1
|
170
|
+
raise 'failed ' + message_type + ' response is not a Notifications::Client::ResponseNotification'
|
181
171
|
end
|
182
172
|
unless notification.id.is_a?(String)
|
183
|
-
|
184
|
-
exit 1
|
173
|
+
raise 'failed ' + message_type + 'id is not a String'
|
185
174
|
end
|
186
175
|
|
187
176
|
if message_type == 'precompiled_letter'
|
188
177
|
field_should_not_be_nil(expected_fields_in_precompiled_letter_response, notification, 'send_precompiled_letter')
|
189
178
|
if notification.postage != "first"
|
190
|
-
|
191
|
-
exit 1
|
179
|
+
raise "Postage should be set to 'first' for precompiled letter sending test. Right now it is set to #{notification.postage}"
|
192
180
|
end
|
193
181
|
return
|
194
182
|
end
|
@@ -206,68 +194,80 @@ def test_notification_response_data_type(notification, message_type)
|
|
206
194
|
end
|
207
195
|
|
208
196
|
def test_get_notification_by_id_endpoint(client, id, message_type)
|
209
|
-
get_notification_response =
|
197
|
+
get_notification_response = nil
|
198
|
+
24.times do
|
199
|
+
get_notification_response = client.get_notification(id)
|
200
|
+
break if get_notification_response&.is_cost_data_ready
|
201
|
+
sleep 5
|
202
|
+
end
|
203
|
+
|
204
|
+
raise "cost data didn't become ready in time" unless get_notification_response&.is_cost_data_ready
|
210
205
|
|
211
206
|
unless get_notification_response.is_a?(Notifications::Client::Notification)
|
212
|
-
|
213
|
-
exit 1
|
207
|
+
raise 'get notification is not a Notifications::Client::Notification for id ' + id
|
214
208
|
end
|
215
209
|
|
216
210
|
if message_type == 'email'
|
217
211
|
field_should_not_be_nil(expected_fields_in_email_notification, get_notification_response, 'Notifications::Client::Notification for type email')
|
218
212
|
field_should_be_nil(expected_fields_in_email_notification_that_are_nil, get_notification_response, 'Notifications::Client::Notification for type email')
|
219
213
|
hash_key_should_not_be_nil(expected_fields_in_template, get_notification_response.send('template'), 'Notifications::Client::Notification.template for type email')
|
214
|
+
hash_should_be_empty(get_notification_response.send('cost_details'), 'Notifications::Client::Notification.cost_details for type sms')
|
215
|
+
|
220
216
|
elsif message_type == 'sms'
|
221
217
|
field_should_not_be_nil(expected_fields_in_sms_notification, get_notification_response, 'Notifications::Client::Notification for type sms')
|
222
218
|
field_should_be_nil(expected_fields_in_sms_notification_that_are_nil, get_notification_response, 'Notifications::Client::Notification for type sms')
|
223
219
|
hash_key_should_not_be_nil(expected_fields_in_template, get_notification_response.send('template'), 'Notifications::Client::Notification.template for type sms')
|
220
|
+
hash_key_should_not_be_nil(expected_cost_details_fields, get_notification_response.send('cost_details'), 'Notifications::Client::Notification.cost_details for type sms')
|
221
|
+
|
224
222
|
elsif message_type == 'letter'
|
225
223
|
field_should_not_be_nil(expected_fields_in_letter_notification, get_notification_response, 'Notifications::Client::Notification for type letter')
|
226
224
|
field_should_be_nil(expected_fields_in_letter_notification_that_are_nil, get_notification_response, 'Notifications::Client::Notification for type letter')
|
227
225
|
hash_key_should_not_be_nil(expected_fields_in_template, get_notification_response.send('template'), 'Notifications::Client::Notification.template for type letter')
|
226
|
+
hash_key_should_not_be_nil(expected_cost_details_fields, get_notification_response.send('cost_details'), 'Notifications::Client::Notification.cost_details for type sms')
|
227
|
+
|
228
228
|
elsif message_type == 'precompiled_letter'
|
229
229
|
field_should_not_be_nil(expected_fields_in_precompiled_letter_notification, get_notification_response, 'Notifications::Client::Notification for type precompiled letter')
|
230
230
|
field_should_be_nil(expected_fields_in_precompiled_letter_notification_that_are_nil, get_notification_response, 'Notifications::Client::Notification for type precompiled letter')
|
231
231
|
hash_key_should_not_be_nil(expected_fields_in_template, get_notification_response.send('template'), 'Notifications::Client::Notification.template for type precompiled letter')
|
232
|
+
hash_key_should_not_be_nil(expected_cost_details_fields, get_notification_response.send('cost_details'), 'Notifications::Client::Notification.cost_details for type sms')
|
233
|
+
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
235
237
|
def test_get_pdf_for_letter(client, id)
|
236
238
|
response = nil
|
237
239
|
|
238
|
-
|
239
|
-
15.times do
|
240
|
+
24.times do
|
240
241
|
begin
|
241
242
|
response = client.get_pdf_for_letter(id)
|
242
|
-
rescue Notifications::Client::BadRequestError
|
243
|
-
sleep(3)
|
244
|
-
end
|
245
|
-
|
246
|
-
if !response.nil?
|
247
243
|
break
|
244
|
+
rescue Notifications::Client::BadRequestError
|
245
|
+
sleep(5)
|
248
246
|
end
|
249
247
|
end
|
250
248
|
|
251
|
-
|
252
|
-
|
253
|
-
exit 1
|
254
|
-
end
|
249
|
+
raise "pdf didn't become ready in time" if response.nil?
|
250
|
+
raise "get_pdf_for_letter response for #{id} is not a PDF: #{response}" unless response.start_with?('%PDF-')
|
255
251
|
end
|
256
252
|
|
257
253
|
def hash_key_should_not_be_nil(fields, obj, method_name)
|
258
254
|
fields.each do |field|
|
259
255
|
if obj.has_value?(:"#{field}")
|
260
|
-
|
261
|
-
exit 1
|
256
|
+
raise 'contract test failed because ' + field + ' should not be nil for ' + method_name + ' response'
|
262
257
|
end
|
263
258
|
end
|
264
259
|
end
|
265
260
|
|
261
|
+
def hash_should_be_empty(hash, method_name)
|
262
|
+
if !hash.empty?
|
263
|
+
raise "contract test failed because #{hash} should be empty for #{method_name} response"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
266
267
|
def field_should_not_be_nil(fields, obj, method_name)
|
267
268
|
fields.each do |field|
|
268
269
|
if obj.send(:"#{field}") == nil
|
269
|
-
|
270
|
-
exit 1
|
270
|
+
raise 'contract test failed because ' + field + ' should not be nil for ' + method_name + ' response'
|
271
271
|
end
|
272
272
|
end
|
273
273
|
end
|
@@ -275,8 +275,7 @@ end
|
|
275
275
|
def field_should_be_nil(fields, obj, method_name)
|
276
276
|
fields.each do |field|
|
277
277
|
if obj.send(:"#{field}") != nil
|
278
|
-
|
279
|
-
exit 1
|
278
|
+
raise 'contract test failed because ' + field + ' should be nil for ' + method_name + ' response'
|
280
279
|
end
|
281
280
|
end
|
282
281
|
end
|
@@ -348,7 +347,11 @@ def expected_fields_in_email_notification
|
|
348
347
|
body
|
349
348
|
subject
|
350
349
|
created_at
|
351
|
-
one_click_unsubscribe_url
|
350
|
+
one_click_unsubscribe_url
|
351
|
+
is_cost_data_ready
|
352
|
+
cost_in_pounds
|
353
|
+
cost_details
|
354
|
+
)
|
352
355
|
end
|
353
356
|
|
354
357
|
def expected_fields_in_email_notification_that_are_nil
|
@@ -372,7 +375,10 @@ def expected_fields_in_sms_notification
|
|
372
375
|
status
|
373
376
|
template
|
374
377
|
body
|
375
|
-
created_at
|
378
|
+
created_at
|
379
|
+
is_cost_data_ready
|
380
|
+
cost_in_pounds
|
381
|
+
cost_details)
|
376
382
|
end
|
377
383
|
|
378
384
|
def expected_fields_in_sms_notification_that_are_nil
|
@@ -404,6 +410,9 @@ def expected_fields_in_letter_notification
|
|
404
410
|
postcode
|
405
411
|
created_at
|
406
412
|
postage
|
413
|
+
is_cost_data_ready
|
414
|
+
cost_in_pounds
|
415
|
+
cost_details
|
407
416
|
)
|
408
417
|
end
|
409
418
|
|
@@ -438,7 +447,6 @@ end
|
|
438
447
|
|
439
448
|
def expected_fields_in_precompiled_letter_notification_that_are_nil
|
440
449
|
%w(
|
441
|
-
completed_at
|
442
450
|
created_by_name
|
443
451
|
email_address
|
444
452
|
line_2
|
@@ -459,6 +467,14 @@ def expected_fields_in_template
|
|
459
467
|
uri)
|
460
468
|
end
|
461
469
|
|
470
|
+
def expected_cost_details_fields
|
471
|
+
%w(billable_sms_fragments
|
472
|
+
international_rate_multiplier
|
473
|
+
sms_rate
|
474
|
+
billable_sheets_of_paper
|
475
|
+
postage)
|
476
|
+
end
|
477
|
+
|
462
478
|
def expected_fields_in_received_text_response
|
463
479
|
%w(id
|
464
480
|
created_at
|
@@ -471,8 +487,7 @@ end
|
|
471
487
|
def test_get_all_notifications(client)
|
472
488
|
notifications = client.get_notifications
|
473
489
|
unless notifications.is_a?(Notifications::Client::NotificationsCollection)
|
474
|
-
|
475
|
-
exit 1
|
490
|
+
raise 'get all notifications is not Notifications::Client::NotificationsCollection'
|
476
491
|
end
|
477
492
|
field_should_not_be_nil(expected_fields_for_get_all_notifications, notifications, 'get_notifications')
|
478
493
|
end
|
@@ -481,26 +496,20 @@ def test_get_received_texts
|
|
481
496
|
client = Notifications::Client.new(ENV['INBOUND_SMS_QUERY_KEY'], ENV['NOTIFY_API_URL'])
|
482
497
|
response = client.get_received_texts
|
483
498
|
unless response.is_a?(Notifications::Client::ReceivedTextCollection)
|
484
|
-
|
485
|
-
exit 1
|
499
|
+
raise 'failed test_get_received_texts response is not a Notifications::Client::ReceivedTextCollection'
|
486
500
|
end
|
487
501
|
unless response.collection.length >= 0
|
488
|
-
|
489
|
-
exit 1
|
502
|
+
raise 'failed test_get_received_texts, expected at least 1 received text returned.'
|
490
503
|
end
|
491
504
|
test_received_text_response(response.collection[0], 'test_received_text_response')
|
492
|
-
test_received_text_response(response.collection[1], 'test_received_text_response')
|
493
|
-
test_received_text_response(response.collection[2], 'test_received_text_response')
|
494
505
|
end
|
495
506
|
|
496
507
|
def test_received_text_response(response, test_method)
|
497
508
|
unless response.is_a?(Notifications::Client::ReceivedText)
|
498
|
-
|
499
|
-
exit 1
|
509
|
+
raise 'failed test_get_received_texts response is not a Notifications::Client::ReceivedText'
|
500
510
|
end
|
501
511
|
unless response.id.is_a?(String)
|
502
|
-
|
503
|
-
exit 1
|
512
|
+
raise 'failed received text id is not a String'
|
504
513
|
end
|
505
514
|
field_should_not_be_nil(expected_fields_in_received_text_response, response, test_method)
|
506
515
|
end
|
@@ -20,11 +20,14 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "jwt", ">= 1.5", "<
|
23
|
+
spec.add_runtime_dependency "jwt", ">= 1.5", "< 4"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
26
25
|
spec.add_development_dependency "rake", "~> 13.0"
|
27
26
|
spec.add_development_dependency "rspec", "~> 3.7"
|
28
27
|
spec.add_development_dependency "webmock", "~> 3.4"
|
29
|
-
|
28
|
+
if RUBY_VERSION < '3.0.0'
|
29
|
+
spec.add_development_dependency "factory_bot", "~> 6.1", "< 6.4.5"
|
30
|
+
else
|
31
|
+
spec.add_development_dependency "factory_bot", "~> 6.1"
|
32
|
+
end
|
30
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifications-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Government Digital Service
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '1.5'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '4'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,21 +29,7 @@ dependencies:
|
|
29
29
|
version: '1.5'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: bundler
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.7'
|
40
|
-
type: :development
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '1.7'
|
32
|
+
version: '4'
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: rake
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|