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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c2ca0e37a78051cacf6b35de97f7a2a6e1e45e41355d2cb91a3ded84571a357
4
- data.tar.gz: cf2652751ae7b86361688e18ddd6dc6487e88dfb7d7758a119720cb5b7544ecd
3
+ metadata.gz: 5c7ff68fddc3b2837e47a1b89476f0d391ec432cc096176733a5944ed20dd107
4
+ data.tar.gz: 84e59511973f65604fc0617c14871848517e23fe615d7d0c075733a435ce06e7
5
5
  SHA512:
6
- metadata.gz: 037f381822efe210e32e3a4a398f946cba3923f2593826a91486ea0710544cf0c72bc0d38b88ff223705bcb984763bbb51052d0a43090223f47bf0607f82348d
7
- data.tar.gz: b0980abf21fd435ad2350f256b04b4cc9ef3db892d642f753e5ba3be4d029f4359a1e37efff6b2197d74b0652c1b4ae49857f3d253a332f9b4ffad945b730afb
6
+ metadata.gz: 92f58edf7ea3cc8966d51e2902f0846082d6667290bdb1123e9c399354fb975dd33e297e4f30667aef275ee2482750932f160857c97459ae89200d162d459373
7
+ data.tar.gz: d3d5784f52bce5bc164ce10d76ef14f83a82caab0f6b3b2e540db3a9ff45d7ea10e0c145deacb8d9501fa3d3ada8770041b5ff80839701526fece51f4391dc7f
@@ -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.
@@ -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
 
@@ -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
- test_get_template_by_id(client, ENV['EMAIL_TEMPLATE_ID'])
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 test_get_template_by_id(client, id)
30
+ def test_get_email_template_by_id(client, id)
29
31
  response = client.get_template_by_id(id)
30
- test_template_response(response, 'test_get_template_by_id')
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
- field_should_not_be_nil(expected_fields_in_template_response, response, test_method)
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
- %w(id
260
- name
261
- type
262
- created_at
263
- created_by
264
- body
265
- version)
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
@@ -13,6 +13,7 @@ module Notifications
13
13
  version
14
14
  body
15
15
  subject
16
+ letter_contact_block
16
17
  ).freeze
17
18
 
18
19
  attr_reader(*FIELDS)
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Notifications
11
11
  class Client
12
- VERSION = "5.2.0".freeze
12
+ VERSION = "5.3.0".freeze
13
13
  end
14
14
  end
@@ -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", "~> 5.2"
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.2.0
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-04 00:00:00.000000000 Z
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: '5.2'
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: '5.2'
102
+ version: '6.1'
103
103
  description:
104
104
  email:
105
105
  - notify@digital.cabinet-office.gov.uk