gds-api-adapters 98.0.0 → 98.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/json_client.rb +2 -2
- data/lib/gds_api/publishing_api.rb +19 -0
- data/lib/gds_api/test_helpers/publishing_api.rb +13 -0
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b9f52394507921888ca9abe107c764de4af4da163dc2609f9909559f31e288
|
4
|
+
data.tar.gz: 94ff2e4bfb6f7a6b015e0049f82bc609cdbe416ee6355fdcc757b3d8d3177668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1cdf84bd90af029ea2c0ca24cc091cdc3b69b9c261ee6ec2632b4587e4c7db454fb56de499d0e499b110ac39567c013313f6ee6440368fe46dbf67f0ed07e74
|
7
|
+
data.tar.gz: 53ad365fffa3ac456e7e77412c986af8e6403dabb63c571a3327db5ac16fbcf573605d901c8ca29bf6cea9f1e9573320299c8e40050a0d7d9e4ea17ec2ca73b3
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -52,8 +52,8 @@ module GdsApi
|
|
52
52
|
do_json_request(:get, url, nil, additional_headers, &create_response)
|
53
53
|
end
|
54
54
|
|
55
|
-
def post_json(url, params = {}, additional_headers = {})
|
56
|
-
do_json_request(:post, url, params, additional_headers)
|
55
|
+
def post_json(url, params = {}, additional_headers = {}, &create_response)
|
56
|
+
do_json_request(:post, url, params, additional_headers, &create_response)
|
57
57
|
end
|
58
58
|
|
59
59
|
def put_json(url, params, additional_headers = {})
|
@@ -602,6 +602,25 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
602
602
|
post_json("#{endpoint}/graphql", query:)
|
603
603
|
end
|
604
604
|
|
605
|
+
# Make a GraphQL query and return the response in the same format as a Content Store content item
|
606
|
+
#
|
607
|
+
# @param query [String]
|
608
|
+
#
|
609
|
+
# @return [GdsApi::Response] A response with the result of the GraphQL query formatted like a Content Store content item.
|
610
|
+
def graphql_content_item(query)
|
611
|
+
create_response = proc do |r|
|
612
|
+
updated_body = JSON.parse(r.body).dig("data", "edition")
|
613
|
+
updated_response = RestClient::Response.create(
|
614
|
+
updated_body.to_json,
|
615
|
+
r.net_http_res,
|
616
|
+
r.request,
|
617
|
+
)
|
618
|
+
GdsApi::Response.new(updated_response)
|
619
|
+
end
|
620
|
+
|
621
|
+
post_json("#{endpoint}/graphql", query:, &create_response)
|
622
|
+
end
|
623
|
+
|
605
624
|
private
|
606
625
|
|
607
626
|
def content_url(content_id, params = {})
|
@@ -201,6 +201,19 @@ 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
|
+
|
204
217
|
# Assert that a draft was saved and published, and links were updated.
|
205
218
|
# - PUT /v2/content/:content_id
|
206
219
|
# - POST /v2/content/:content_id/publish
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 98.
|
4
|
+
version: 98.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-12-
|
10
|
+
date: 2024-12-18 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: addressable
|
@@ -398,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
398
|
- !ruby/object:Gem::Version
|
399
399
|
version: '0'
|
400
400
|
requirements: []
|
401
|
-
rubygems_version: 3.6.
|
401
|
+
rubygems_version: 3.6.1
|
402
402
|
specification_version: 4
|
403
403
|
summary: Adapters to work with GDS APIs
|
404
404
|
test_files: []
|