notifications-ruby-client 6.3.0 → 6.5.1

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: 77a8a364fe112385dd966dc7d1c694596b5c7e786cb9c88e15f44fdf077868dc
4
- data.tar.gz: 4e9dab5c9f3c1162acd687f5281855e6e62b019bafdd3b80b41fd2d524dca431
3
+ metadata.gz: a729f4a4babb045a13f1b649025a786220afd9e72f1c919f30deaf256e1c9560
4
+ data.tar.gz: 5bbc31ccee18125aae5fcf9635f034c3658f3aa7aee2c6096ce2a310c824890d
5
5
  SHA512:
6
- metadata.gz: d2d76d657dfaaf195cf47fc547f03cd43070e639e5aa4cb0e83c4704593e59a77af37ffdac614eb8f6167935497f8b7c3a5cc9788ee41b169817b9c8df38ff0d
7
- data.tar.gz: 8c7be5c4533ce2e475bdde4db8aea698339bb6f940fa6f71825c7e28299c53c0feebd513d209239a1dae56caf4502ebc8a4cfc5ec6f0f1afe38a08205bccdf6d
6
+ metadata.gz: ea1ad32ca2113e6e6cd2a8760bf25543ddfb16bc6e38a3f54d4cc4b1aba71877ec5e2ec19aba6392d418c68f1f0dca5d12c3b82b93721410ed560280698de157
7
+ data.tar.gz: e87702a7c357460cfa659cc0c5d2a283a82e3fa8437bd385bbccf9ea0514e6bce3f80ea1066da0fd08ff3437fe52997e5d18a4a617a5ca9f4313fbefdd29cf9e
data/.dockerignore CHANGED
@@ -1 +1,3 @@
1
+ **/.git/*
1
2
  environment*.sh
3
+ Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 6.5.1
2
+
3
+ * Same contents as 6.5.0. That version was never published because the CI image failed to build after Debian 11 LTS ended.
4
+ * Move the CI Docker image from `ruby:2.6-slim` (Debian 11) to `ruby:3.4-slim`. This does not change the gem for users.
5
+
6
+ ## 6.5.0
7
+
8
+ * Add `personalisation` to the `Notifications::Client::Template` object returned by `get_template_by_id`, `get_template_version` and `get_all_templates`. This is a hash of placeholder names, for example `{"name" => {"required" => true}}`.
9
+ * Not published to RubyGems. Use 6.5.1.
10
+
11
+ ## 6.4.0
12
+
13
+ * 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`.
14
+ * 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`.
15
+
1
16
  ## 6.3.0
2
17
  * Update dependencies
3
18
  * Permit the `jwt` gem to be upgraded to version 3
data/Dockerfile CHANGED
@@ -1,12 +1,11 @@
1
- FROM ruby:2.6-slim
1
+ FROM ruby:3.4-slim
2
2
 
3
3
  RUN \
4
4
  echo "Install Debian packages" \
5
5
  && apt-get update \
6
6
  && apt-get install -y --no-install-recommends \
7
7
  awscli \
8
- gcc \
9
- make \
8
+ build-essential \
10
9
  curl \
11
10
  git \
12
11
  gnupg \
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source 'https://rubygems.org', cooldown: 7
2
2
 
3
3
  gemspec
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}")
@@ -7,6 +7,7 @@ module Notifications
7
7
  content
8
8
  template
9
9
  uri
10
+ sanitised_content
10
11
  ).freeze
11
12
 
12
13
  attr_reader(*FIELDS)
@@ -14,6 +14,7 @@ module Notifications
14
14
  body
15
15
  subject
16
16
  letter_contact_block
17
+ personalisation
17
18
  ).freeze
18
19
 
19
20
  attr_reader(*FIELDS)
@@ -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(
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Notifications
11
11
  class Client
12
- VERSION = "6.3.0".freeze
12
+ VERSION = "6.5.1".freeze
13
13
  end
14
14
  end
@@ -30,7 +30,8 @@ module Notifications
30
30
  end
31
31
 
32
32
  ##
33
- # @see Notifications::Client::Speaker#post
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,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.0
4
+ version: 6.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-09-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: jwt
@@ -79,9 +78,6 @@ dependencies:
79
78
  - - "~>"
80
79
  - !ruby/object:Gem::Version
81
80
  version: '6.1'
82
- - - "<"
83
- - !ruby/object:Gem::Version
84
- version: 6.4.5
85
81
  type: :development
86
82
  prerelease: false
87
83
  version_requirements: !ruby/object:Gem::Requirement
@@ -89,10 +85,6 @@ dependencies:
89
85
  - - "~>"
90
86
  - !ruby/object:Gem::Version
91
87
  version: '6.1'
92
- - - "<"
93
- - !ruby/object:Gem::Version
94
- version: 6.4.5
95
- description:
96
88
  email:
97
89
  - notify@digital.cabinet-office.gov.uk
98
90
  executables: []
@@ -135,7 +127,6 @@ files:
135
127
  homepage: https://github.com/alphagov/notifications-ruby-client
136
128
  licenses: []
137
129
  metadata: {}
138
- post_install_message:
139
130
  rdoc_options: []
140
131
  require_paths:
141
132
  - lib
@@ -150,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
141
  - !ruby/object:Gem::Version
151
142
  version: '0'
152
143
  requirements: []
153
- rubygems_version: 3.0.3.1
154
- signing_key:
144
+ rubygems_version: 3.6.9
155
145
  specification_version: 4
156
146
  summary: Ruby client for GOV.UK Notifications API
157
147
  test_files: []