notifications-ruby-client 6.3.0 → 6.4.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/.dockerignore +1 -0
- data/CHANGELOG.md +5 -0
- data/bin/test_client.rb +19 -1
- data/lib/notifications/client/response_notification.rb +1 -0
- data/lib/notifications/client/speaker.rb +2 -0
- data/lib/notifications/client/version.rb +1 -1
- data/lib/notifications/client.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f795202efa7a08dc79833a2c1ff7aec35a7deadf495c8380e290bff1c11189f
|
|
4
|
+
data.tar.gz: 0e938bb4e2a4ed8d516766131192ef8a7acae0de5dee6d25a69cdfbfe1673456
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b910c3bf6d1e115763bc4e88db202dc33a4d633439e26b5599aab48b5a5d1260cf34ebc4b4f494a911b5d039dc4b4cff2620589ee82e7d73ddfda0b9c35c7429
|
|
7
|
+
data.tar.gz: 28aef4fdb14d28c0100262fa583eaab52e9f7d949490405f13a1c5e351afa8326956f262fbe30a7a9029400f3be16e1638673dea057fff6e4746be2510eb3c4b
|
data/.dockerignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 6.4.0
|
|
2
|
+
|
|
3
|
+
* Add support for the optional `sanitise_content_for` parameter when sending email (list of personalisation placeholder keys to sanitise for Markdown). Documented on `Notifications::Client::Speaker#post`.
|
|
4
|
+
* Add `sanitised_content` to the send-email response object (`Notifications::Client::ResponseNotification`). The API returns a JSON object (Ruby `Hash`): keys are personalisation placeholder names, and each value is another object with `unsanitised` and `sanitised` for placeholders that were rewritten; the object is empty when nothing changed. If the key is absent from the JSON, the client exposes `nil`.
|
|
5
|
+
|
|
1
6
|
## 6.3.0
|
|
2
7
|
* Update dependencies
|
|
3
8
|
* Permit the `jwt` gem to be upgraded to version 3
|
data/bin/test_client.rb
CHANGED
|
@@ -112,7 +112,8 @@ def test_send_email_endpoint(client)
|
|
|
112
112
|
personalisation: { "name" => "some name" },
|
|
113
113
|
reference: "some reference",
|
|
114
114
|
email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'],
|
|
115
|
-
one_click_unsubscribe_url: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com"
|
|
115
|
+
one_click_unsubscribe_url: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com",
|
|
116
|
+
sanitise_content_for: ["name"]
|
|
116
117
|
)
|
|
117
118
|
test_notification_response_data_type(email_resp, 'email')
|
|
118
119
|
email_resp
|
|
@@ -186,6 +187,10 @@ def test_notification_response_data_type(notification, message_type)
|
|
|
186
187
|
|
|
187
188
|
if message_type == 'email'
|
|
188
189
|
hash_key_should_not_be_nil(expected_fields_in_email_content, notification.send('content'), 'send_' + message_type + '.content')
|
|
190
|
+
unless sanitised_content_matches_email_send_api_response?(notification.sanitised_content)
|
|
191
|
+
raise 'contract test failed: sanitised_content should be a JSON object whose keys are placeholder names ' \
|
|
192
|
+
'and whose values are objects with unsanitised and sanitised (see notifications-api post v2/email response)'
|
|
193
|
+
end
|
|
189
194
|
elsif message_type == 'sms'
|
|
190
195
|
hash_key_should_not_be_nil(expected_fields_in_sms_content, notification.send('content'), 'send_' + message_type + '.content')
|
|
191
196
|
elsif message_type == 'letter'
|
|
@@ -250,6 +255,19 @@ def test_get_pdf_for_letter(client, id)
|
|
|
250
255
|
raise "get_pdf_for_letter response for #{id} is not a PDF: #{response}" unless response.start_with?('%PDF-')
|
|
251
256
|
end
|
|
252
257
|
|
|
258
|
+
# POST /v2/notifications/email merges sanitised_content from the API: a JSON object mapping each changed
|
|
259
|
+
# placeholder to { "unsanitised" => ..., "sanitised" => ... }. It is {} when no placeholders differ.
|
|
260
|
+
def sanitised_content_matches_email_send_api_response?(sanitised_content)
|
|
261
|
+
return false unless sanitised_content.is_a?(Hash)
|
|
262
|
+
|
|
263
|
+
sanitised_content.all? do |placeholder_key, entry|
|
|
264
|
+
placeholder_key.is_a?(String) &&
|
|
265
|
+
entry.is_a?(Hash) &&
|
|
266
|
+
entry.key?('unsanitised') &&
|
|
267
|
+
entry.key?('sanitised')
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
253
271
|
def hash_key_should_not_be_nil(fields, obj, method_name)
|
|
254
272
|
fields.each do |field|
|
|
255
273
|
if obj.has_value?(:"#{field}")
|
|
@@ -49,6 +49,8 @@ module Notifications
|
|
|
49
49
|
# id of the sender to be used for an sms notification
|
|
50
50
|
# @option form_data [String] :one_click_unsubscribe_url
|
|
51
51
|
# link that end user can click to unsubscribe from the distribution list. We will pass this link in the email headers.
|
|
52
|
+
# @option form_data [Array<String>] :sanitise_content_for
|
|
53
|
+
# email only: optional list of personalisation placeholder keys to sanitise for Markdown before the template is rendered.
|
|
52
54
|
# @see #perform_request!
|
|
53
55
|
def post(kind, form_data)
|
|
54
56
|
request = Net::HTTP::Post.new(
|
data/lib/notifications/client.rb
CHANGED
|
@@ -30,7 +30,8 @@ module Notifications
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
##
|
|
33
|
-
#
|
|
33
|
+
# @see Notifications::Client::Speaker#post
|
|
34
|
+
# Optional email-only keys are documented on {Notifications::Client::Speaker#post}.
|
|
34
35
|
# @return [ResponseNotification]
|
|
35
36
|
def send_email(args)
|
|
36
37
|
ResponseNotification.new(
|
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.4.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: 2026-05-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jwt
|