notifications-ruby-client 5.2.0 → 5.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 +4 -0
- data/DOCUMENTATION.md +3 -0
- data/bin/test_client.rb +47 -18
- data/lib/notifications/client/response_template.rb +1 -0
- data/lib/notifications/client/version.rb +1 -1
- data/notifications-ruby-client.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c7ff68fddc3b2837e47a1b89476f0d391ec432cc096176733a5944ed20dd107
|
4
|
+
data.tar.gz: 84e59511973f65604fc0617c14871848517e23fe615d7d0c075733a435ce06e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92f58edf7ea3cc8966d51e2902f0846082d6667290bdb1123e9c399354fb975dd33e297e4f30667aef275ee2482750932f160857c97459ae89200d162d459373
|
7
|
+
data.tar.gz: d3d5784f52bce5bc164ce10d76ef14f83a82caab0f6b3b2e540db3a9ff45d7ea10e0c145deacb8d9501fa3d3ada8770041b5ff80839701526fece51f4391dc7f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 5.3.0
|
2
|
+
|
3
|
+
* Added `letter_contact_block` as a new attribute of the `Notifications::Client::Template` class. This affects the responses from the `get_template_by_id`, `get_template_version` and `get_all_templates` methods.
|
4
|
+
|
1
5
|
## 5.2.0
|
2
6
|
|
3
7
|
* Add support for an optional `is_csv` parameter in the `prepare_upload()` function. This fixes a bug when sending a CSV file by email. This ensures that the file is downloaded as a CSV rather than a TXT file.
|
data/DOCUMENTATION.md
CHANGED
@@ -770,6 +770,7 @@ You can then call different methods on this object to return the requested infor
|
|
770
770
|
|`response.version`|Template version|String|
|
771
771
|
|`response.body`|Template content|String|
|
772
772
|
|`response.subject`|Template subject (email and letter)|String|
|
773
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
773
774
|
|
774
775
|
### Error codes
|
775
776
|
|
@@ -821,6 +822,7 @@ You can then call different methods on this object to return the requested infor
|
|
821
822
|
|`response.version`|Template version|String|
|
822
823
|
|`response.body`|Template content|String|
|
823
824
|
|`response.subject`|Template subject (email and letter)|String|
|
825
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
824
826
|
|
825
827
|
### Error codes
|
826
828
|
|
@@ -875,6 +877,7 @@ Once the client has returned a template array, you must then call the following
|
|
875
877
|
|`response.version`|Template version|String|
|
876
878
|
|`response.body`|Template content|String|
|
877
879
|
|`response.subject`|Template subject (email and letter)|String|
|
880
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
878
881
|
|
879
882
|
If no templates exist for a template type or there no templates for a service, the templates array will be empty.
|
880
883
|
|
data/bin/test_client.rb
CHANGED
@@ -3,7 +3,9 @@ require './lib/notifications/client'
|
|
3
3
|
|
4
4
|
def main
|
5
5
|
client = Notifications::Client.new(ENV['API_KEY'], ENV['NOTIFY_API_URL'])
|
6
|
-
|
6
|
+
test_get_email_template_by_id(client, ENV['EMAIL_TEMPLATE_ID'])
|
7
|
+
test_get_sms_template_by_id(client, ENV['SMS_TEMPLATE_ID'])
|
8
|
+
test_get_letter_template_by_id(client, ENV['LETTER_TEMPLATE_ID'])
|
7
9
|
test_get_template_version(client, ENV['SMS_TEMPLATE_ID'], 1)
|
8
10
|
test_get_all_templates(client)
|
9
11
|
test_get_all_templates_filter_by_type(client)
|
@@ -25,14 +27,24 @@ def main
|
|
25
27
|
exit 0
|
26
28
|
end
|
27
29
|
|
28
|
-
def
|
30
|
+
def test_get_email_template_by_id(client, id)
|
29
31
|
response = client.get_template_by_id(id)
|
30
|
-
test_template_response(response, '
|
32
|
+
test_template_response(response, 'email', 'test_get_email_template_by_id')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_get_sms_template_by_id(client, id)
|
36
|
+
response = client.get_template_by_id(id)
|
37
|
+
test_template_response(response, 'sms', 'test_get_sms_template_by_id')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_get_letter_template_by_id(client, id)
|
41
|
+
response = client.get_template_by_id(id)
|
42
|
+
test_template_response(response, 'letter', 'test_get_letter_template_by_id')
|
31
43
|
end
|
32
44
|
|
33
45
|
def test_get_template_version(client, id, version)
|
34
46
|
response = client.get_template_version(id, version)
|
35
|
-
test_template_response(response, 'test_get_template_version')
|
47
|
+
test_template_response(response, 'sms', 'test_get_template_version')
|
36
48
|
end
|
37
49
|
|
38
50
|
def test_get_all_templates(client)
|
@@ -45,9 +57,9 @@ def test_get_all_templates(client)
|
|
45
57
|
p 'failed test_get_all_templates, expected at least 3 templates returned.'
|
46
58
|
exit 1
|
47
59
|
end
|
48
|
-
test_template_response(response.collection[0], 'test_get_all_templates')
|
49
|
-
test_template_response(response.collection[1], 'test_get_all_templates')
|
50
|
-
test_template_response(response.collection[2], 'test_get_all_templates')
|
60
|
+
test_template_response(response.collection[0], 'letter', 'test_get_all_templates')
|
61
|
+
test_template_response(response.collection[1], 'email', 'test_get_all_templates')
|
62
|
+
test_template_response(response.collection[2], 'sms', 'test_get_all_templates')
|
51
63
|
end
|
52
64
|
|
53
65
|
def test_get_all_templates_filter_by_type(client)
|
@@ -60,7 +72,7 @@ def test_get_all_templates_filter_by_type(client)
|
|
60
72
|
p 'failed test_get_all_templates, expected at least 2 templates returned.'
|
61
73
|
exit 1
|
62
74
|
end
|
63
|
-
test_template_response(response.collection[0], 'test_get_all_templates')
|
75
|
+
test_template_response(response.collection[0], 'sms', 'test_get_all_templates')
|
64
76
|
end
|
65
77
|
|
66
78
|
def test_generate_template_preview(client, id)
|
@@ -68,7 +80,7 @@ def test_generate_template_preview(client, id)
|
|
68
80
|
test_template_preview(response)
|
69
81
|
end
|
70
82
|
|
71
|
-
def test_template_response(response, test_method)
|
83
|
+
def test_template_response(response, template_type, test_method)
|
72
84
|
unless response.is_a?(Notifications::Client::Template)
|
73
85
|
p 'failed test_get_template_by_id response is not a Notifications::Client::Template'
|
74
86
|
exit 1
|
@@ -77,7 +89,17 @@ def test_template_response(response, test_method)
|
|
77
89
|
p 'failed template id is not a String'
|
78
90
|
exit 1
|
79
91
|
end
|
80
|
-
|
92
|
+
|
93
|
+
field_should_not_be_nil(
|
94
|
+
expected_fields_in_template_response(template_type),
|
95
|
+
response,
|
96
|
+
test_method
|
97
|
+
)
|
98
|
+
field_should_be_nil(
|
99
|
+
expected_nil_fields_in_template_response(template_type),
|
100
|
+
response,
|
101
|
+
test_method
|
102
|
+
)
|
81
103
|
end
|
82
104
|
|
83
105
|
def test_template_preview(response)
|
@@ -255,14 +277,21 @@ def field_should_be_nil(fields, obj, method_name)
|
|
255
277
|
end
|
256
278
|
end
|
257
279
|
|
258
|
-
def expected_fields_in_template_response
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
280
|
+
def expected_fields_in_template_response(template_type)
|
281
|
+
{
|
282
|
+
"email" => ["id", "name", "type", "created_at", "created_by", "version", "body", "subject"],
|
283
|
+
"sms" => ["id", "name", "type", "created_at", "created_by", "version", "body"],
|
284
|
+
"letter" => ["id", "name", "type", "created_at", "created_by", "version", "body", "subject",
|
285
|
+
"letter_contact_block"],
|
286
|
+
}[template_type]
|
287
|
+
end
|
288
|
+
|
289
|
+
def expected_nil_fields_in_template_response(template_type)
|
290
|
+
{
|
291
|
+
"email" => ["letter_contact_block"],
|
292
|
+
"sms" => ["subject", "letter_contact_block"],
|
293
|
+
"letter" => [],
|
294
|
+
}[template_type]
|
266
295
|
end
|
267
296
|
|
268
297
|
def expected_fields_in_template_preview
|
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rake", "~> 13.0"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.7"
|
28
28
|
spec.add_development_dependency "webmock", "~> 3.4"
|
29
|
-
spec.add_development_dependency "factory_bot", "~>
|
29
|
+
spec.add_development_dependency "factory_bot", "~> 6.1"
|
30
30
|
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: 5.
|
4
|
+
version: 5.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: 2020-08-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
95
|
+
version: '6.1'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
102
|
+
version: '6.1'
|
103
103
|
description:
|
104
104
|
email:
|
105
105
|
- notify@digital.cabinet-office.gov.uk
|