publishing_platform_api_adapters 0.11.0 → 0.12.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d98513bb44934332a9fe5a7e64933d721d2978aae2244b3f482ce8940ee81fe
|
|
4
|
+
data.tar.gz: 9472ad4033345b101e7e39291b7658f1d3c9d7abb9e436f99ad94411e4c6c651
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0eccb8a41e6b80059a13c772f9943b4a1989df6e36e4e47abfe71db925c8402758dea35db9ce35709b80de34ec29ef2ae30377a3ef2e5ecf080c4b9c36ed7d5
|
|
7
|
+
data.tar.gz: 98294ca2cf9e577ccd4a3708268d584dbdb20385eb7b8c182a31bf8ee87da7b4f1c24eddb967ce1766da847d362ba258e1ac110aa41eceadab35a3c4361baea5
|
|
@@ -29,6 +29,52 @@ class PublishingPlatformApi::PublishingApi < PublishingPlatformApi::Base
|
|
|
29
29
|
get_json(content_url(content_id, params))
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Find the content_ids for a list of base_paths.
|
|
33
|
+
#
|
|
34
|
+
# @param base_paths [Array]
|
|
35
|
+
# @param exclude_document_types [Array] (optional)
|
|
36
|
+
# @param exclude_unpublishing_types [Array] (optional)
|
|
37
|
+
# @param with_drafts [Boolean] (optional)
|
|
38
|
+
# @return [Hash] a hash, keyed by `base_path` with `content_id` as value
|
|
39
|
+
# @example
|
|
40
|
+
#
|
|
41
|
+
# publishing_api.lookup_content_ids(base_paths: ['/foo', '/bar'])
|
|
42
|
+
# # => { "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db", "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca" }
|
|
43
|
+
def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
|
44
|
+
options = { base_paths: }
|
|
45
|
+
options[:exclude_document_types] = exclude_document_types if exclude_document_types
|
|
46
|
+
options[:exclude_unpublishing_types] = exclude_unpublishing_types if exclude_unpublishing_types
|
|
47
|
+
options[:with_drafts] = with_drafts if with_drafts
|
|
48
|
+
response = post_json("#{endpoint}/lookup-by-base-path", options)
|
|
49
|
+
response.to_hash
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Find the content_id for a base_path.
|
|
53
|
+
#
|
|
54
|
+
# Convenience method if you only need to look up one content_id for a
|
|
55
|
+
# base_path. For multiple base_paths, use {PublishingPlatformApi::PublishingApi#lookup_content_ids}.
|
|
56
|
+
#
|
|
57
|
+
# @param base_path [String]
|
|
58
|
+
# @param exclude_document_types [Array] (optional)
|
|
59
|
+
# @param exclude_unpublishing_types [Array] (optional)
|
|
60
|
+
# @param with_drafts [Boolean] (optional)
|
|
61
|
+
#
|
|
62
|
+
# @return [UUID] the `content_id` for the `base_path`
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
#
|
|
66
|
+
# publishing_api.lookup_content_id(base_path: '/foo')
|
|
67
|
+
# # => "51ac4247-fd92-470a-a207-6b852a97f2db"
|
|
68
|
+
def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
|
69
|
+
lookups = lookup_content_ids(
|
|
70
|
+
base_paths: [base_path],
|
|
71
|
+
exclude_document_types:,
|
|
72
|
+
exclude_unpublishing_types:,
|
|
73
|
+
with_drafts:,
|
|
74
|
+
)
|
|
75
|
+
lookups[base_path]
|
|
76
|
+
end
|
|
77
|
+
|
|
32
78
|
# Publish a content item
|
|
33
79
|
#
|
|
34
80
|
# The publishing-api will "publish" a draft item, so that it will be visible
|
|
@@ -538,6 +538,22 @@ module PublishingPlatformApi
|
|
|
538
538
|
stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "link set").to_json, headers: {})
|
|
539
539
|
end
|
|
540
540
|
|
|
541
|
+
# Stub calls to the lookups endpoint
|
|
542
|
+
#
|
|
543
|
+
# @param lookup_hash [Hash] Hash with base_path as key, content_id as value.
|
|
544
|
+
#
|
|
545
|
+
# @example
|
|
546
|
+
#
|
|
547
|
+
# stub_publishing_api_has_lookups({
|
|
548
|
+
# "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db",
|
|
549
|
+
# "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca"
|
|
550
|
+
# })
|
|
551
|
+
#
|
|
552
|
+
def stub_publishing_api_has_lookups(lookup_hash)
|
|
553
|
+
url = "#{PUBLISHING_API_ENDPOINT}/lookup-by-base-path"
|
|
554
|
+
stub_request(:post, url).to_return(body: lookup_hash.to_json)
|
|
555
|
+
end
|
|
556
|
+
|
|
541
557
|
def stub_publishing_api_unreserve_path(base_path, publishing_app = /.*/)
|
|
542
558
|
stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 200)
|
|
543
559
|
end
|