gds-api-adapters 100.0.0 → 101.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 +4 -4
- data/lib/gds_api/publishing_api.rb +0 -31
- data/lib/gds_api/test_helpers/publishing_api.rb +0 -13
- data/lib/gds_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0452ce585eda439e6e108d87399c57fc6735147d61e46f25aa9d2976ae2f2631
|
4
|
+
data.tar.gz: 1ee56ab8efe164f1129576143d70997d7068ca21f2d514f12df568948f01326b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae3c45e6a375f143392fbd520f4cfdd9f33e800793c13ddf6115ca1aba9fde8b4d947ff192b7e5450698b1927b2fbb64d63b92c47f662d7ec3743bc7cd9798e
|
7
|
+
data.tar.gz: e233c70c834929000f9e77c057a9383ff83b198e6712a25193f3727fff43834b53c148c581167bca0b981f8bfc8c0a503448b6b799f2315ab80c493c4979f452
|
@@ -605,37 +605,6 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
605
605
|
post_json("#{endpoint}/graphql", query:)
|
606
606
|
end
|
607
607
|
|
608
|
-
# Make a GraphQL query and return the response in the same format as a Content Store content item
|
609
|
-
#
|
610
|
-
# @param query [String]
|
611
|
-
#
|
612
|
-
# @return [GdsApi::Response] A response with the result of the GraphQL query formatted like a Content Store content item.
|
613
|
-
def graphql_content_item(query)
|
614
|
-
create_response = proc do |r|
|
615
|
-
parsed_body = JSON.parse(r.body)
|
616
|
-
|
617
|
-
updated_body = if parsed_body["errors"] && (unpublished_error = parsed_body["errors"].find { |error| error["message"] == "Edition has been unpublished" })
|
618
|
-
if unpublished_error.dig("extensions", "schema_name") == "gone" &&
|
619
|
-
(unpublished_error.dig("extensions", "details").nil? || unpublished_error.dig("extensions", "details").values.compact.reject(&:empty?).empty?)
|
620
|
-
raise GdsApi::HTTPGone.new(410, nil, unpublished_error["extensions"])
|
621
|
-
end
|
622
|
-
|
623
|
-
unpublished_error["extensions"]
|
624
|
-
else
|
625
|
-
parsed_body.dig("data", "edition")
|
626
|
-
end
|
627
|
-
|
628
|
-
updated_response = RestClient::Response.create(
|
629
|
-
updated_body.to_json,
|
630
|
-
r.net_http_res,
|
631
|
-
r.request,
|
632
|
-
)
|
633
|
-
GdsApi::Response.new(updated_response)
|
634
|
-
end
|
635
|
-
|
636
|
-
post_json("#{endpoint}/graphql", query:, &create_response)
|
637
|
-
end
|
638
|
-
|
639
608
|
# Get the live content item using GraphQL
|
640
609
|
#
|
641
610
|
# @return [GdsApi::Response] A response with the result of the GraphQL query formatted like a Content Store content item.
|
@@ -201,19 +201,6 @@ module GdsApi
|
|
201
201
|
stub_request(:post, url).with(body: { query: }).to_return(response)
|
202
202
|
end
|
203
203
|
|
204
|
-
# Stub a POST /graphql content item request
|
205
|
-
#
|
206
|
-
# @param query [String]
|
207
|
-
def stub_publishing_api_graphql_content_item(query, response_hash = {})
|
208
|
-
url = "#{PUBLISHING_API_ENDPOINT}/graphql"
|
209
|
-
response = {
|
210
|
-
status: 200,
|
211
|
-
body: response_hash.to_json,
|
212
|
-
headers: { "Content-Type" => "application/json; charset=utf-8" },
|
213
|
-
}
|
214
|
-
stub_request(:post, url).with(body: { query: }).to_return(response)
|
215
|
-
end
|
216
|
-
|
217
204
|
# Stub a GET /graphql/content/:base_path request
|
218
205
|
def stub_publishing_api_graphql_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
|
219
206
|
max_age = options.fetch(:max_age, 900)
|
data/lib/gds_api/version.rb
CHANGED