gds-api-adapters 77.0.0 → 79.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: 2ea534ae361e87fde66ed0a9909c3920b0a58c86ad5e26b3dd4c7d13baabe15c
4
- data.tar.gz: a24876d1c08767f5d934e9327feb212a6e35f33142c4c6764e85f28eca525de5
3
+ metadata.gz: e10a938b3148397b6c9a4ff3a06a6105f4d07ad02a80b4103440cd065b92d4ba
4
+ data.tar.gz: e246e963aa42bcb62dc1479a076713ce4fefbcac40ca00e07b7f492a54396517
5
5
  SHA512:
6
- metadata.gz: 23a867c3eb864e2078989ac9f395d572a3679a06ad1efc20f080563d4aabd65e46e27b29118e77daa130924d00c9de4c6f7a7a4f1131d2b242099dc3a05783d6
7
- data.tar.gz: 2340a2464e1971055760d1169f05e18c40e9ef50e75610b763f6c6018fcae863a8669aa77a8c9aedaa9ed3632c8e463f0147b92a80d2a811c69d2f4b1ec47a94
6
+ metadata.gz: b2ee8e777bac9cbefe10b5497c5ec6cd48e4f7566cb07eff82bfa35a800c1fa28c99c3bfcd93c2dfa20fc63205c65142ddc4bc4e649ab1fa312565ea03bb324c
7
+ data.tar.gz: 5764cc76a32646d8162f37d76098540acfe10e10d2c27f91504cf72c3a9abc3d8802f01c9d4cd64df920a503184e605ce718c1e0229a96aad52c2fda8e29f5cc
@@ -247,6 +247,37 @@ class GdsApi::EmailAlertApi < GdsApi::Base
247
247
  )
248
248
  end
249
249
 
250
+ # Unsubscribe all users for a subscription list
251
+ # optionally send a notification email explaining the reason
252
+ #
253
+ # @param [string] slug Identifier for the subscription list
254
+ # @param [string] (optional) govuk_request_id An ID allowing us to trace requests across our infra. Required if you want to send an email.
255
+ # @param [string] (optional) body Optional email body to send to alert users they are being unsubscribed. Required if you want to send an email
256
+ # @param [string] (optional) sender_message_id A UUID to prevent multiple emails for the same event. Required if you want to send an email.
257
+ def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: nil)
258
+ post_json(
259
+ "#{endpoint}/subscriber-lists/#{slug}/bulk-unsubscribe",
260
+ {
261
+ body: body,
262
+ sender_message_id: sender_message_id,
263
+ }.compact,
264
+ {
265
+ "Govuk-Request-Id" => govuk_request_id,
266
+ }.compact,
267
+ )
268
+ end
269
+
270
+ # Update subscriber list details, such as title
271
+ # @param [Hash] params A hash of detail paramaters that can be updated. For example title.
272
+ # For allowed parameters see:
273
+ # https://github.com/alphagov/email-alert-api/blob/main/docs/api.md#patch-subscriber-listsxxx
274
+ def update_subscriber_list_details(slug:, params: {})
275
+ patch_json(
276
+ "#{endpoint}/subscriber-lists/#{slug}",
277
+ params,
278
+ )
279
+ end
280
+
250
281
  private
251
282
 
252
283
  def nested_query_string(params)
@@ -408,6 +408,91 @@ module GdsApi
408
408
  .to_return(status: 404)
409
409
  end
410
410
 
411
+ def stub_email_alert_api_bulk_unsubscribe(slug:)
412
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
413
+ .to_return(status: 202)
414
+ end
415
+
416
+ def stub_email_alert_api_bulk_unsubscribe_with_message(slug:, govuk_request_id:, body:, sender_message_id:)
417
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
418
+ .with(
419
+ body: {
420
+ body: body,
421
+ sender_message_id: sender_message_id,
422
+ }.to_json,
423
+ headers: { "Govuk-Request-Id" => govuk_request_id },
424
+ ).to_return(status: 202)
425
+ end
426
+
427
+ def stub_email_alert_api_bulk_unsubscribe_not_found(slug:)
428
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
429
+ .to_return(status: 404)
430
+ end
431
+
432
+ def stub_email_alert_api_bulk_unsubscribe_not_found_with_message(slug:, govuk_request_id:, body:, sender_message_id:)
433
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
434
+ .with(
435
+ body: {
436
+ body: body,
437
+ sender_message_id: sender_message_id,
438
+ }.to_json,
439
+ headers: { "Govuk-Request-Id" => govuk_request_id },
440
+ ).to_return(status: 404)
441
+ end
442
+
443
+ def stub_email_alert_api_bulk_unsubscribe_conflict(slug:)
444
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
445
+ .to_return(status: 409)
446
+ end
447
+
448
+ def stub_email_alert_api_bulk_unsubscribe_conflict_with_message(slug:, govuk_request_id:, body:, sender_message_id:)
449
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
450
+ .with(
451
+ body: {
452
+ body: body,
453
+ sender_message_id: sender_message_id,
454
+ }.to_json,
455
+ headers: { "Govuk-Request-Id" => govuk_request_id },
456
+ ).to_return(status: 409)
457
+ end
458
+
459
+ def stub_email_alert_api_bulk_unsubscribe_bad_request(slug:)
460
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
461
+ .to_return(status: 422)
462
+ end
463
+
464
+ def stub_email_alert_api_bulk_unsubscribe_bad_request_with_message(slug:, govuk_request_id:, body:, sender_message_id:)
465
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
466
+ .with(
467
+ body: {
468
+ body: body,
469
+ sender_message_id: sender_message_id,
470
+ }.to_json,
471
+ headers: { "Govuk-Request-Id" => govuk_request_id },
472
+ ).to_return(status: 422)
473
+ end
474
+
475
+ def stub_update_subscriber_list_details(slug:, params:)
476
+ stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
477
+ .with(body: params.to_json)
478
+ .to_return(
479
+ status: 200,
480
+ body: get_subscriber_list_response(params).to_json,
481
+ )
482
+ end
483
+
484
+ def stub_update_subscriber_list_details_not_found(slug:, params:)
485
+ stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
486
+ .with(body: params.to_json)
487
+ .to_return(status: 404)
488
+ end
489
+
490
+ def stub_update_subscriber_list_details_unprocessible_entity(slug:, params: {})
491
+ stub_request(:patch, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
492
+ .with(body: params.to_json)
493
+ .to_return(status: 422)
494
+ end
495
+
411
496
  private
412
497
 
413
498
  def get_subscriber_response(id, address, govuk_account_id)
@@ -487,6 +572,7 @@ module GdsApi
487
572
  if attributes
488
573
  tags = attributes["tags"]
489
574
  links = attributes["links"]
575
+ content_id = attributes["content_id"]
490
576
  document_type = attributes["document_type"]
491
577
  email_document_supertype = attributes["email_document_supertype"]
492
578
  government_document_supertype = attributes["government_document_supertype"]
@@ -496,6 +582,7 @@ module GdsApi
496
582
  params = {}
497
583
  params[:tags] = tags if tags
498
584
  params[:links] = links if links
585
+ params[:content_id] = content_id if content_id
499
586
  params[:document_type] = document_type if document_type
500
587
  params[:email_document_supertype] = email_document_supertype if email_document_supertype
501
588
  params[:government_document_supertype] = government_document_supertype if government_document_supertype
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "77.0.0".freeze
2
+ VERSION = "79.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: 77.0.0
4
+ version: 79.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: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2022-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable