From 6715c7ff3cf437d426c4fcd54c8b2011a73abcb5 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Thu, 9 May 2024 14:19:21 +0100 Subject: [PATCH 1/3] Add unsubscribe link to client arguments --- bin/test_client.rb | 27 ++++++++++++++++-------- lib/notifications/client/notification.rb | 1 + lib/notifications/client/speaker.rb | 2 ++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/bin/test_client.rb b/bin/test_client.rb index 839c50c..0532bbc 100755 --- a/bin/test_client.rb +++ b/bin/test_client.rb @@ -115,11 +115,14 @@ def test_template_preview(response) end def test_send_email_endpoint(client) - email_resp = client.send_email(email_address: ENV['FUNCTIONAL_TEST_EMAIL'], - template_id: ENV['EMAIL_TEMPLATE_ID'], - personalisation: { "name" => "some name" }, - reference: "some reference", - email_reply_to_id: ENV['EMAIL_REPLY_TO_ID']) + email_resp = client.send_email( + email_address: ENV['FUNCTIONAL_TEST_EMAIL'], + template_id: ENV['EMAIL_TEMPLATE_ID'], + personalisation: { "name" => "some name" }, + reference: "some reference", + email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'], + unsubscribe_link: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com" + ) test_notification_response_data_type(email_resp, 'email') email_resp end @@ -130,7 +133,8 @@ def test_send_email_endpoint_with_document(client) template_id: ENV['EMAIL_TEMPLATE_ID'], personalisation: { name: Notifications.prepare_upload(f) }, reference: "some reference", - email_reply_to_id: ENV['EMAIL_REPLY_TO_ID']) + email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'], + unsubscribe_link: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com") end test_notification_response_data_type(email_resp, 'email') @@ -319,7 +323,8 @@ def expected_fields_in_precompiled_letter_response def expected_fields_in_email_content %w(from_email body - subject) + subject + unsubscribe_link) end def expected_fields_in_sms_content @@ -342,7 +347,8 @@ def expected_fields_in_email_notification template body subject - created_at) + created_at + unsubscribe_link) end def expected_fields_in_email_notification_that_are_nil @@ -381,7 +387,8 @@ def expected_fields_in_sms_notification_that_are_nil postcode subject created_by_name - postage) + postage + unsubscribe_link) end def expected_fields_in_letter_notification @@ -410,6 +417,7 @@ def expected_fields_in_letter_notification_that_are_nil line_5 line_6 created_by_name + unsubscribe_link ) end @@ -441,6 +449,7 @@ def expected_fields_in_precompiled_letter_notification_that_are_nil phone_number postcode sent_at + unsubscribe_link ) end diff --git a/lib/notifications/client/notification.rb b/lib/notifications/client/notification.rb index e45f066..cb8ed2a 100644 --- a/lib/notifications/client/notification.rb +++ b/lib/notifications/client/notification.rb @@ -25,6 +25,7 @@ class Notification created_at completed_at created_by_name + unsubscribe_link ).freeze attr_reader(*FIELDS) diff --git a/lib/notifications/client/speaker.rb b/lib/notifications/client/speaker.rb index cfa50bf..9e6472c 100644 --- a/lib/notifications/client/speaker.rb +++ b/lib/notifications/client/speaker.rb @@ -47,6 +47,8 @@ def initialize(secret_token = nil, base_url = nil) # id of the email address that replies to email notifications will be sent to # @option form_data [String] :sms_sender_id # id of the sender to be used for an sms notification + # @option form_data [String] :unsubscribe_link + # link that user can click to unsubscribe from the distribution list. We will pass this link in the email headers. # @see #perform_request! def post(kind, form_data) request = Net::HTTP::Post.new( From b7ceabcaf7e6ff30a4d8f4d635059ec5cdd0471a Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Thu, 9 May 2024 17:09:40 +0100 Subject: [PATCH 2/3] Version change --- CHANGELOG.md | 5 +++++ lib/notifications/client/speaker.rb | 2 +- lib/notifications/client/version.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d960459..f8790c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.1.0 + +* Adds a `unsubscribe_link` parameter to `send_email` so services can allow users to easily unsubscribe from distribution lists. +* Adds a `unsubscribe_link` attribute to `Notification` class, so responses for get_notification include the unsubscribe link. + ## 6.0.0 * Removes the `is_csv` parameter from `prepare_upload` diff --git a/lib/notifications/client/speaker.rb b/lib/notifications/client/speaker.rb index 9e6472c..af61317 100644 --- a/lib/notifications/client/speaker.rb +++ b/lib/notifications/client/speaker.rb @@ -48,7 +48,7 @@ def initialize(secret_token = nil, base_url = nil) # @option form_data [String] :sms_sender_id # id of the sender to be used for an sms notification # @option form_data [String] :unsubscribe_link - # link that user can click to unsubscribe from the distribution list. We will pass this link in the email headers. + # link that end user can click to unsubscribe from the distribution list. We will pass this link in the email headers. # @see #perform_request! def post(kind, form_data) request = Net::HTTP::Post.new( diff --git a/lib/notifications/client/version.rb b/lib/notifications/client/version.rb index ec34e3a..c864a52 100644 --- a/lib/notifications/client/version.rb +++ b/lib/notifications/client/version.rb @@ -9,6 +9,6 @@ module Notifications class Client - VERSION = "6.0.0".freeze + VERSION = "6.1.0".freeze end end From 8bfc9ceb560c819bb744c6ae18a621bf30a7236f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 14 May 2024 16:46:36 +0100 Subject: [PATCH 3/3] Rename `unsubscribe_link` to `one_click_unsubscribe_url` To reflect https://github.com/alphagov/notifications-api/pull/4084/files --- CHANGELOG.md | 4 ++-- bin/test_client.rb | 14 +++++++------- lib/notifications/client/notification.rb | 2 +- lib/notifications/client/speaker.rb | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8790c9..60024f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 6.1.0 -* Adds a `unsubscribe_link` parameter to `send_email` so services can allow users to easily unsubscribe from distribution lists. -* Adds a `unsubscribe_link` attribute to `Notification` class, so responses for get_notification include the unsubscribe link. +* Adds a `one_click_unsubscribe_url` parameter to `send_email` so services can allow users to easily unsubscribe from distribution lists. +* Adds a `one_click_unsubscribe_url` attribute to `Notification` class, so responses for get_notification include the unsubscribe link. ## 6.0.0 diff --git a/bin/test_client.rb b/bin/test_client.rb index 0532bbc..f6ba274 100755 --- a/bin/test_client.rb +++ b/bin/test_client.rb @@ -121,7 +121,7 @@ def test_send_email_endpoint(client) personalisation: { "name" => "some name" }, reference: "some reference", email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'], - unsubscribe_link: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com" + one_click_unsubscribe_url: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com" ) test_notification_response_data_type(email_resp, 'email') email_resp @@ -134,7 +134,7 @@ def test_send_email_endpoint_with_document(client) personalisation: { name: Notifications.prepare_upload(f) }, reference: "some reference", email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'], - unsubscribe_link: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com") + one_click_unsubscribe_url: "https://www.clovercouncil.gov.uk/unsubscribe?email_address=faye@example.com") end test_notification_response_data_type(email_resp, 'email') @@ -324,7 +324,7 @@ def expected_fields_in_email_content %w(from_email body subject - unsubscribe_link) + one_click_unsubscribe_url) end def expected_fields_in_sms_content @@ -348,7 +348,7 @@ def expected_fields_in_email_notification body subject created_at - unsubscribe_link) + one_click_unsubscribe_url) end def expected_fields_in_email_notification_that_are_nil @@ -388,7 +388,7 @@ def expected_fields_in_sms_notification_that_are_nil subject created_by_name postage - unsubscribe_link) + one_click_unsubscribe_url) end def expected_fields_in_letter_notification @@ -417,7 +417,7 @@ def expected_fields_in_letter_notification_that_are_nil line_5 line_6 created_by_name - unsubscribe_link + one_click_unsubscribe_url ) end @@ -449,7 +449,7 @@ def expected_fields_in_precompiled_letter_notification_that_are_nil phone_number postcode sent_at - unsubscribe_link + one_click_unsubscribe_url ) end diff --git a/lib/notifications/client/notification.rb b/lib/notifications/client/notification.rb index cb8ed2a..7e0edfe 100644 --- a/lib/notifications/client/notification.rb +++ b/lib/notifications/client/notification.rb @@ -25,7 +25,7 @@ class Notification created_at completed_at created_by_name - unsubscribe_link + one_click_unsubscribe_url ).freeze attr_reader(*FIELDS) diff --git a/lib/notifications/client/speaker.rb b/lib/notifications/client/speaker.rb index af61317..94e6b00 100644 --- a/lib/notifications/client/speaker.rb +++ b/lib/notifications/client/speaker.rb @@ -47,7 +47,7 @@ def initialize(secret_token = nil, base_url = nil) # id of the email address that replies to email notifications will be sent to # @option form_data [String] :sms_sender_id # id of the sender to be used for an sms notification - # @option form_data [String] :unsubscribe_link + # @option form_data [String] :one_click_unsubscribe_url # link that end user can click to unsubscribe from the distribution list. We will pass this link in the email headers. # @see #perform_request! def post(kind, form_data)