gds-api-adapters 61.1.0 → 62.0.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: d5f65962436358074fac776cc44bb46b9eb6f6468d5535cee98f3d74eb6d023f
4
- data.tar.gz: d1db9044e8d30b6f9663c538c3899f6e91f89784976944a47fc1eedff628a864
3
+ metadata.gz: 92eba8c68e225ff418851d17f752e878114c846406a537081ebe34e0ae2e34c4
4
+ data.tar.gz: 7f42445ceb3ab057ded3a60a1dc8689fcec344398c1b735dbafb43e01c51653d
5
5
  SHA512:
6
- metadata.gz: 8e13eabfbe27a41b911d00c2d8e3476ef76785a1879e0356aec501d397343a7c25fe7c2b76f9806a12060d0279b76b0bc6dc39b286aef216975edae592a90af5
7
- data.tar.gz: c79eda01413dab578ab7eed8edaf2f468fc7702ef8ae280407431d1d6026373c078a4b98114ba80b8448b77f13e6c64a58bde11a024a1e2bbd3db688db550eac
6
+ metadata.gz: e9d9b95df9631d8b54ac61ae808be26cc8f47d48fb8a9a13489aa1bb04457d76a044eae8732b7abd0a774304be484c5c29f0fa7a4430a06e2f9daf1cad698008
7
+ data.tar.gz: 326e54ff7b2f4fb098ce3d39f50fd96897cedd25d9a73c86f1eba71b7b70a188ab4952bddc59cd8059abc4caf01b2c80d1326cde50bc4a7dcd464283e6ed61a3
@@ -220,15 +220,15 @@ class GdsApi::EmailAlertApi < GdsApi::Base
220
220
  )
221
221
  end
222
222
 
223
- # Create an authentication token for a subscriber
223
+ # Verify a subscriber has control of a provided email
224
224
  #
225
- # @param [string] address Email address of subscriber to create token for
225
+ # @param [string] address Address to send verification email to
226
226
  # @param [string] destination Path on GOV.UK that subscriber will be emailed
227
227
  # @param [string, nil] redirect Path on GOV.UK to be encoded into the token for redirecting
228
228
  #
229
229
  # @return [Hash] subscriber
230
230
  #
231
- def create_auth_token(address:, destination:, redirect: nil)
231
+ def send_subscriber_verification_email(address:, destination:, redirect: nil)
232
232
  post_json(
233
233
  "#{endpoint}/subscribers/auth-token",
234
234
  address: address,
@@ -237,6 +237,23 @@ class GdsApi::EmailAlertApi < GdsApi::Base
237
237
  )
238
238
  end
239
239
 
240
+ # Verify a subscriber intends to be added to a subscription
241
+ #
242
+ # @param [string] address Address to send verification email to
243
+ # @param [string] frequency How often the subscriber wishes to be notified of new items
244
+ # @param [string] topic_id The slugs/ID for the topic being subscribed to
245
+ #
246
+ # return [Hash] subscription
247
+ #
248
+ def send_subscription_verification_email(address:, frequency:, topic_id:)
249
+ post_json(
250
+ "#{endpoint}/subscriptions/auth-token",
251
+ address: address,
252
+ frequency: frequency,
253
+ topic_id: topic_id,
254
+ )
255
+ end
256
+
240
257
  private
241
258
 
242
259
  def nested_query_string(params)
@@ -239,7 +239,21 @@ module GdsApi
239
239
  ).to_return(status: 422)
240
240
  end
241
241
 
242
- def stub_email_alert_api_creates_an_auth_token(subscriber_id, address)
242
+ def stub_email_alert_api_sends_subscription_verification_email(address, frequency, topic_id)
243
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token")
244
+ .with(
245
+ body: { address: address, frequency: frequency, topic_id: topic_id }.to_json,
246
+ ).to_return(status: 200)
247
+ end
248
+
249
+ def stub_email_alert_api_subscription_verification_email_invalid(address, frequency, topic_id)
250
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/auth-token")
251
+ .with(
252
+ body: { address: address, frequency: frequency, topic_id: topic_id }.to_json,
253
+ ).to_return(status: 422)
254
+ end
255
+
256
+ def stub_email_alert_api_sends_subscriber_verification_email(subscriber_id, address)
243
257
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
244
258
  .to_return(
245
259
  status: 201,
@@ -247,12 +261,12 @@ module GdsApi
247
261
  )
248
262
  end
249
263
 
250
- def stub_email_alert_api_invalid_auth_token
264
+ def stub_email_alert_api_subscriber_verification_email_invalid
251
265
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
252
266
  .to_return(status: 422)
253
267
  end
254
268
 
255
- def stub_email_alert_api_auth_token_no_subscriber
269
+ def stub_email_alert_api_subscriber_verification_email_no_subscriber
256
270
  stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscribers/auth-token")
257
271
  .to_return(status: 404)
258
272
  end
@@ -307,7 +321,6 @@ module GdsApi
307
321
  alias_method :email_alert_api_creates_a_subscription, :stub_email_alert_api_creates_a_subscription
308
322
  alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
309
323
  alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
310
- alias_method :email_alert_api_creates_an_auth_token, :stub_email_alert_api_creates_an_auth_token
311
324
  alias_method :email_alert_api_has_subscriber_list_by_slug, :stub_email_alert_api_has_subscriber_list_by_slug
312
325
  alias_method :email_alert_api_does_not_have_subscriber_list_by_slug, :stub_email_alert_api_does_not_have_subscriber_list_by_slug
313
326
 
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "61.1.0".freeze
2
+ VERSION = "62.0.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 61.1.0
4
+ version: 62.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-03 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable