gds-api-adapters 79.1.2 → 80.0.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 +4 -4
- data/lib/gds_api/email_alert_api.rb +1 -1
- data/lib/gds_api/publishing_api.rb +21 -38
- data/lib/gds_api/test_helpers/email_alert_api.rb +16 -16
- data/lib/gds_api/version.rb +1 -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: d176cb409b66bc4df5c376c244660cd23fe992e70fa982b3d3403638a97855e4
|
4
|
+
data.tar.gz: 507564fc5d9cde9f3bcb9d20ef056a273dd1ff6f7f79a7e4631141cd46ed92bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f2478cee5688ec61a3c55b4f010b6bc1dd663929b8313b17affbc4056f78825e008a448242c30668a4acd0cd6fbbc118df4eb691bfa913f5aba76461cbe017
|
7
|
+
data.tar.gz: 3ecfd09796febbb411404015894024df599b2edb733a0658d730057f5c90e9a60926fa1bfd73a9c258db0a6e24282c41e9d548ba7a04b161f1d39550f827b10b
|
@@ -252,7 +252,7 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
252
252
|
# optionally send a notification email explaining the reason
|
253
253
|
#
|
254
254
|
# @param [string] slug Identifier for the subscription list
|
255
|
-
# @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) govuk_request_id An ID allowing us to trace requests across our infra. Required if you want to send an email by running out-of-band processes via asynchronous workers.
|
256
256
|
# @param [string] (optional) body Optional email body to send to alert users they are being unsubscribed. Required if you want to send an email
|
257
257
|
# @param [string] (optional) sender_message_id A UUID to prevent multiple emails for the same event. Required if you want to send an email.
|
258
258
|
def bulk_unsubscribe(slug:, govuk_request_id: nil, body: nil, sender_message_id: nil)
|
@@ -4,8 +4,8 @@ require_relative "exceptions"
|
|
4
4
|
# Adapter for the Publishing API.
|
5
5
|
#
|
6
6
|
# @see https://github.com/alphagov/publishing-api
|
7
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
8
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
7
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/publishing-application-examples.md
|
8
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/model.md
|
9
9
|
# @api documented
|
10
10
|
class GdsApi::PublishingApi < GdsApi::Base
|
11
11
|
class NoLiveVersion < GdsApi::BaseError; end
|
@@ -15,7 +15,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
15
15
|
# @param content_id [UUID]
|
16
16
|
# @param payload [Hash] A valid content item
|
17
17
|
#
|
18
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
18
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#put-v2contentcontent_id
|
19
19
|
def put_content(content_id, payload)
|
20
20
|
put_json(content_url(content_id), payload)
|
21
21
|
end
|
@@ -31,7 +31,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
31
31
|
# @return [GdsApi::Response] a content item
|
32
32
|
#
|
33
33
|
# @raise [HTTPNotFound] when the content item is not found
|
34
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
34
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_id
|
35
35
|
def get_content(content_id, params = {})
|
36
36
|
get_json(content_url(content_id, params))
|
37
37
|
end
|
@@ -46,7 +46,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
46
46
|
# @return [GdsApi::Response] a content item
|
47
47
|
#
|
48
48
|
# @raise [NoLiveVersion] when the content item is not found
|
49
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
49
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_id
|
50
50
|
def get_live_content(content_id, locale = "en")
|
51
51
|
content_item = get_content(content_id, locale: locale)
|
52
52
|
|
@@ -71,7 +71,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
71
71
|
# publishing_api.lookup_content_ids(base_paths: ['/foo', '/bar'])
|
72
72
|
# # => { "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db", "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca" }
|
73
73
|
#
|
74
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
74
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-lookup-by-base-path
|
75
75
|
def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
76
76
|
options = { base_paths: base_paths }
|
77
77
|
options[:exclude_document_types] = exclude_document_types if exclude_document_types
|
@@ -98,7 +98,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
98
98
|
# publishing_api.lookup_content_id(base_path: '/foo')
|
99
99
|
# # => "51ac4247-fd92-470a-a207-6b852a97f2db"
|
100
100
|
#
|
101
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
101
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-lookup-by-base-path
|
102
102
|
def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
103
103
|
lookups = lookup_content_ids(
|
104
104
|
base_paths: [base_path],
|
@@ -119,7 +119,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
119
119
|
# @param options [Hash]
|
120
120
|
# @option options [String] locale The language, defaults to 'en' in publishing-api.
|
121
121
|
#
|
122
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
122
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idpublish
|
123
123
|
def publish(content_id, update_type = nil, options = {})
|
124
124
|
params = {
|
125
125
|
update_type: update_type,
|
@@ -150,23 +150,6 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
150
150
|
post_json(republish_url(content_id), params)
|
151
151
|
end
|
152
152
|
|
153
|
-
# Import content into the publishing API
|
154
|
-
#
|
155
|
-
# The publishing-api will delete any content which has the content
|
156
|
-
# id provided, and then import the data given.
|
157
|
-
#
|
158
|
-
# @param content_id [UUID]
|
159
|
-
# @param content_items [Array]
|
160
|
-
#
|
161
|
-
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idimport
|
162
|
-
def import(content_id, locale, content_items)
|
163
|
-
params = {
|
164
|
-
history: content_items,
|
165
|
-
}
|
166
|
-
|
167
|
-
post_json("#{endpoint}/v2/content/#{content_id}/import?locale=#{locale}", params)
|
168
|
-
end
|
169
|
-
|
170
153
|
# Unpublish a content item
|
171
154
|
#
|
172
155
|
# The publishing API will "unpublish" a live item, to remove it from the public
|
@@ -182,7 +165,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
182
165
|
# @param unpublished_at [Time] (optional) The time the content was withdrawn. Ignored for types other than withdrawn
|
183
166
|
# @param redirects [Array] (optional) Required if no alternative_path is given. An array of redirect values, ie: { path:, type:, destination: }
|
184
167
|
#
|
185
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
168
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idunpublish
|
186
169
|
def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil, unpublished_at: nil, redirects: nil)
|
187
170
|
params = {
|
188
171
|
type: type,
|
@@ -208,7 +191,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
208
191
|
# @option options [String] locale The language, defaults to 'en' in publishing-api.
|
209
192
|
# @option options [Integer] previous_version used to ensure the request is discarding the latest lock version of the draft
|
210
193
|
#
|
211
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
194
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_iddiscard-draft
|
212
195
|
def discard_draft(content_id, options = {})
|
213
196
|
optional_keys = %i[locale previous_version]
|
214
197
|
|
@@ -237,7 +220,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
237
220
|
# "version" => 17
|
238
221
|
# }
|
239
222
|
#
|
240
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
223
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkscontent_id
|
241
224
|
def get_links(content_id)
|
242
225
|
get_json(links_url(content_id))
|
243
226
|
end
|
@@ -288,7 +271,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
288
271
|
# }
|
289
272
|
# }
|
290
273
|
#
|
291
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
274
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2expanded-linkscontent_id
|
292
275
|
def get_expanded_links(content_id, locale: nil, with_drafts: true, generate: false)
|
293
276
|
params = {}
|
294
277
|
params[:with_drafts] = "false" unless with_drafts
|
@@ -318,7 +301,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
318
301
|
# bulk_publishing: true
|
319
302
|
# )
|
320
303
|
#
|
321
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
304
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#patch-v2linkscontent_id
|
322
305
|
def patch_links(content_id, params)
|
323
306
|
payload = {
|
324
307
|
links: params.fetch(:links),
|
@@ -348,7 +331,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
348
331
|
# order: '-public_updated_at'
|
349
332
|
# )
|
350
333
|
#
|
351
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
334
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2content
|
352
335
|
def get_content_items(params)
|
353
336
|
query = query_string(params)
|
354
337
|
get_json("#{endpoint}/v2/content#{query}")
|
@@ -361,7 +344,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
361
344
|
#
|
362
345
|
# @return [Enumerator] an enumerator of content items
|
363
346
|
#
|
364
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
347
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2content
|
365
348
|
def get_content_items_enum(params)
|
366
349
|
Enumerator.new do |yielder|
|
367
350
|
(1..Float::INFINITY).each do |index|
|
@@ -378,7 +361,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
378
361
|
|
379
362
|
# FIXME: Add documentation
|
380
363
|
#
|
381
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
364
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkables
|
382
365
|
def get_linkables(document_type: nil)
|
383
366
|
if document_type.nil?
|
384
367
|
raise ArgumentError, "Please provide a `document_type`"
|
@@ -389,7 +372,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
389
372
|
|
390
373
|
# FIXME: Add documentation
|
391
374
|
#
|
392
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
375
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkedcontent_id
|
393
376
|
def get_linked_items(content_id, params = {})
|
394
377
|
query = query_string(params)
|
395
378
|
validate_content_id(content_id)
|
@@ -403,7 +386,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
403
386
|
#
|
404
387
|
# @return [GdsApi::Response] a paginated list of editions
|
405
388
|
#
|
406
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
389
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2editions
|
407
390
|
def get_editions(params = {})
|
408
391
|
get_json(get_editions_url(params))
|
409
392
|
end
|
@@ -415,7 +398,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
415
398
|
#
|
416
399
|
# @return [Enumerator] an enumerator of editions responses
|
417
400
|
#
|
418
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
401
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2editions
|
419
402
|
def get_paged_editions(params = {})
|
420
403
|
Enumerator.new do |yielder|
|
421
404
|
next_link = get_editions_url(params)
|
@@ -488,7 +471,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
488
471
|
# }
|
489
472
|
# )
|
490
473
|
#
|
491
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
474
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#put-publish-intentbase_path
|
492
475
|
def put_intent(base_path, payload)
|
493
476
|
put_json(intent_url(base_path), payload)
|
494
477
|
end
|
@@ -497,7 +480,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
497
480
|
#
|
498
481
|
# @param base_path [String]
|
499
482
|
#
|
500
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
483
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#delete-publish-intentbase_path
|
501
484
|
def destroy_intent(base_path)
|
502
485
|
delete_json(intent_url(base_path))
|
503
486
|
rescue GdsApi::HTTPNotFound => e
|
@@ -413,15 +413,15 @@ module GdsApi
|
|
413
413
|
.to_return(status: 202)
|
414
414
|
end
|
415
415
|
|
416
|
-
def stub_email_alert_api_bulk_unsubscribe_with_message(slug:,
|
416
|
+
def stub_email_alert_api_bulk_unsubscribe_with_message(slug:, body:, sender_message_id:, govuk_request_id: nil)
|
417
417
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
418
|
-
.with(
|
418
|
+
.with({
|
419
419
|
body: {
|
420
420
|
body: body,
|
421
421
|
sender_message_id: sender_message_id,
|
422
422
|
}.to_json,
|
423
|
-
|
424
|
-
|
423
|
+
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
424
|
+
.to_return(status: 202)
|
425
425
|
end
|
426
426
|
|
427
427
|
def stub_email_alert_api_bulk_unsubscribe_not_found(slug:)
|
@@ -429,15 +429,15 @@ module GdsApi
|
|
429
429
|
.to_return(status: 404)
|
430
430
|
end
|
431
431
|
|
432
|
-
def stub_email_alert_api_bulk_unsubscribe_not_found_with_message(slug:,
|
432
|
+
def stub_email_alert_api_bulk_unsubscribe_not_found_with_message(slug:, body:, sender_message_id:, govuk_request_id: nil)
|
433
433
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
434
|
-
.with(
|
434
|
+
.with({
|
435
435
|
body: {
|
436
436
|
body: body,
|
437
437
|
sender_message_id: sender_message_id,
|
438
438
|
}.to_json,
|
439
|
-
|
440
|
-
|
439
|
+
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
440
|
+
.to_return(status: 404)
|
441
441
|
end
|
442
442
|
|
443
443
|
def stub_email_alert_api_bulk_unsubscribe_conflict(slug:)
|
@@ -445,15 +445,15 @@ module GdsApi
|
|
445
445
|
.to_return(status: 409)
|
446
446
|
end
|
447
447
|
|
448
|
-
def stub_email_alert_api_bulk_unsubscribe_conflict_with_message(slug:,
|
448
|
+
def stub_email_alert_api_bulk_unsubscribe_conflict_with_message(slug:, body:, sender_message_id:, govuk_request_id: nil)
|
449
449
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
450
|
-
.with(
|
450
|
+
.with({
|
451
451
|
body: {
|
452
452
|
body: body,
|
453
453
|
sender_message_id: sender_message_id,
|
454
454
|
}.to_json,
|
455
|
-
|
456
|
-
|
455
|
+
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
456
|
+
.to_return(status: 409)
|
457
457
|
end
|
458
458
|
|
459
459
|
def stub_email_alert_api_bulk_unsubscribe_bad_request(slug:)
|
@@ -461,15 +461,15 @@ module GdsApi
|
|
461
461
|
.to_return(status: 422)
|
462
462
|
end
|
463
463
|
|
464
|
-
def stub_email_alert_api_bulk_unsubscribe_bad_request_with_message(slug:,
|
464
|
+
def stub_email_alert_api_bulk_unsubscribe_bad_request_with_message(slug:, body:, sender_message_id:, govuk_request_id: nil)
|
465
465
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}/bulk-unsubscribe")
|
466
|
-
.with(
|
466
|
+
.with({
|
467
467
|
body: {
|
468
468
|
body: body,
|
469
469
|
sender_message_id: sender_message_id,
|
470
470
|
}.to_json,
|
471
|
-
|
472
|
-
|
471
|
+
}.tap { |attr| attr[:headers] = { "Govuk-Request-Id" => govuk_request_id } if govuk_request_id })
|
472
|
+
.to_return(status: 422)
|
473
473
|
end
|
474
474
|
|
475
475
|
def stub_update_subscriber_list_details(slug:, params:)
|
data/lib/gds_api/version.rb
CHANGED
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:
|
4
|
+
version: 80.0.1
|
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: 2022-
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|