gds-api-adapters 79.1.2 → 79.2.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 +4 -4
- data/lib/gds_api/publishing_api.rb +22 -22
- 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: 314781375647d75f9d65da9f5cdc7eaeadefb909c9e300645f50add8a66fac77
|
4
|
+
data.tar.gz: b8c6e5a17e7c0dc2d549cc0330655fbc9e03471cbbd4a217afc508977d9a531a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 595735b215edde32f93d78ce0137e1dc9e34a87e8da3a3e9c92536c54149b39f1cfa879d872bd209ee1851e45f4ae8052bf5e83e603a96976fd1f0fc73de944c
|
7
|
+
data.tar.gz: cfedf9155d36cc2e55068722b5a01d54469f4ce8177d3147a51a308e25eb820e552d57b64cb312dab120b7ed32b29ff793ef5a3f498dde5d74d2a95a19b4435b
|
@@ -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,
|
@@ -158,7 +158,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
158
158
|
# @param content_id [UUID]
|
159
159
|
# @param content_items [Array]
|
160
160
|
#
|
161
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
161
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idimport
|
162
162
|
def import(content_id, locale, content_items)
|
163
163
|
params = {
|
164
164
|
history: content_items,
|
@@ -182,7 +182,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
182
182
|
# @param unpublished_at [Time] (optional) The time the content was withdrawn. Ignored for types other than withdrawn
|
183
183
|
# @param redirects [Array] (optional) Required if no alternative_path is given. An array of redirect values, ie: { path:, type:, destination: }
|
184
184
|
#
|
185
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
185
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idunpublish
|
186
186
|
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
187
|
params = {
|
188
188
|
type: type,
|
@@ -208,7 +208,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
208
208
|
# @option options [String] locale The language, defaults to 'en' in publishing-api.
|
209
209
|
# @option options [Integer] previous_version used to ensure the request is discarding the latest lock version of the draft
|
210
210
|
#
|
211
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
211
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_iddiscard-draft
|
212
212
|
def discard_draft(content_id, options = {})
|
213
213
|
optional_keys = %i[locale previous_version]
|
214
214
|
|
@@ -237,7 +237,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
237
237
|
# "version" => 17
|
238
238
|
# }
|
239
239
|
#
|
240
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
240
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkscontent_id
|
241
241
|
def get_links(content_id)
|
242
242
|
get_json(links_url(content_id))
|
243
243
|
end
|
@@ -288,7 +288,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
288
288
|
# }
|
289
289
|
# }
|
290
290
|
#
|
291
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
291
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2expanded-linkscontent_id
|
292
292
|
def get_expanded_links(content_id, locale: nil, with_drafts: true, generate: false)
|
293
293
|
params = {}
|
294
294
|
params[:with_drafts] = "false" unless with_drafts
|
@@ -318,7 +318,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
318
318
|
# bulk_publishing: true
|
319
319
|
# )
|
320
320
|
#
|
321
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
321
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#patch-v2linkscontent_id
|
322
322
|
def patch_links(content_id, params)
|
323
323
|
payload = {
|
324
324
|
links: params.fetch(:links),
|
@@ -348,7 +348,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
348
348
|
# order: '-public_updated_at'
|
349
349
|
# )
|
350
350
|
#
|
351
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
351
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2content
|
352
352
|
def get_content_items(params)
|
353
353
|
query = query_string(params)
|
354
354
|
get_json("#{endpoint}/v2/content#{query}")
|
@@ -361,7 +361,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
361
361
|
#
|
362
362
|
# @return [Enumerator] an enumerator of content items
|
363
363
|
#
|
364
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
364
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2content
|
365
365
|
def get_content_items_enum(params)
|
366
366
|
Enumerator.new do |yielder|
|
367
367
|
(1..Float::INFINITY).each do |index|
|
@@ -378,7 +378,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
378
378
|
|
379
379
|
# FIXME: Add documentation
|
380
380
|
#
|
381
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
381
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkables
|
382
382
|
def get_linkables(document_type: nil)
|
383
383
|
if document_type.nil?
|
384
384
|
raise ArgumentError, "Please provide a `document_type`"
|
@@ -389,7 +389,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
389
389
|
|
390
390
|
# FIXME: Add documentation
|
391
391
|
#
|
392
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
392
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2linkedcontent_id
|
393
393
|
def get_linked_items(content_id, params = {})
|
394
394
|
query = query_string(params)
|
395
395
|
validate_content_id(content_id)
|
@@ -403,7 +403,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
403
403
|
#
|
404
404
|
# @return [GdsApi::Response] a paginated list of editions
|
405
405
|
#
|
406
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
406
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2editions
|
407
407
|
def get_editions(params = {})
|
408
408
|
get_json(get_editions_url(params))
|
409
409
|
end
|
@@ -415,7 +415,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
415
415
|
#
|
416
416
|
# @return [Enumerator] an enumerator of editions responses
|
417
417
|
#
|
418
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
418
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2editions
|
419
419
|
def get_paged_editions(params = {})
|
420
420
|
Enumerator.new do |yielder|
|
421
421
|
next_link = get_editions_url(params)
|
@@ -488,7 +488,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
488
488
|
# }
|
489
489
|
# )
|
490
490
|
#
|
491
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
491
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#put-publish-intentbase_path
|
492
492
|
def put_intent(base_path, payload)
|
493
493
|
put_json(intent_url(base_path), payload)
|
494
494
|
end
|
@@ -497,7 +497,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
497
497
|
#
|
498
498
|
# @param base_path [String]
|
499
499
|
#
|
500
|
-
# @see https://github.com/alphagov/publishing-api/blob/
|
500
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#delete-publish-intentbase_path
|
501
501
|
def destroy_intent(base_path)
|
502
502
|
delete_json(intent_url(base_path))
|
503
503
|
rescue GdsApi::HTTPNotFound => e
|
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: 79.
|
4
|
+
version: 79.2.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: 2022-
|
11
|
+
date: 2022-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|