gds-api-adapters 98.0.0 → 98.2.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/signon_api.rb +17 -0
- data/lib/gds_api/test_helpers/publishing_api.rb +13 -0
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api.rb +14 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51c7c6ffe18c5c3e712794c4d3fe5e3ae59009d4b48aa0b271ef3603aae8c12e
|
4
|
+
data.tar.gz: 18eef9cf5a8ff6a3a5f4378ae5ae312c4480c5ed959a4f482202422fe30228f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 978ddb8ee98fa3b2d077d293c35fd483e5316e3eb687f0cb7cd9f60f49687f136721b43eda266dbb963429ad1365aad7e327a744aa5d67a9beee295a525456d5
|
7
|
+
data.tar.gz: 4f6f6407912450e38293d8c9014c38898df6902701ab0319784cef83bbe8e951da77e623e345a29e12802ecb518f788a1f859945ae1d569dd5ab5c812f23a1ab
|
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 = {})
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
class GdsApi::SignonApi < GdsApi::Base
|
4
|
+
# Get users with specific UUIDs
|
5
|
+
#
|
6
|
+
# @param uuids [Array]
|
7
|
+
#
|
8
|
+
# signon_api.users(
|
9
|
+
# ["7ac47b33-c09c-4c1d-a9a7-0cfef99081ac"],
|
10
|
+
# )
|
11
|
+
#
|
12
|
+
# @return [GdsApi::Response] A response containing a list of users with the specified UUIDs
|
13
|
+
def get_users(uuids:)
|
14
|
+
query = query_string(uuids:)
|
15
|
+
get_json("#{endpoint}/api/users#{query}")
|
16
|
+
end
|
17
|
+
end
|
@@ -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
data/lib/gds_api.rb
CHANGED
@@ -16,6 +16,7 @@ require "gds_api/organisations"
|
|
16
16
|
require "gds_api/publishing_api"
|
17
17
|
require "gds_api/search"
|
18
18
|
require "gds_api/search_api_v2"
|
19
|
+
require "gds_api/signon_api"
|
19
20
|
require "gds_api/support"
|
20
21
|
require "gds_api/support_api"
|
21
22
|
require "gds_api/worldwide"
|
@@ -154,6 +155,19 @@ module GdsApi
|
|
154
155
|
)
|
155
156
|
end
|
156
157
|
|
158
|
+
# Creates a GdsApi::SignonApi adapter
|
159
|
+
#
|
160
|
+
# This will set a bearer token if a PUBLISHING_API_BEARER_TOKEN environment
|
161
|
+
# variable is set
|
162
|
+
#
|
163
|
+
# @return [GdsApi::SignonApi]
|
164
|
+
def self.signon_api(options = {})
|
165
|
+
GdsApi::SignonApi.new(
|
166
|
+
Plek.find("signon"),
|
167
|
+
{ bearer_token: ENV["SIGNON_API_BEARER_TOKEN"] }.merge(options),
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
157
171
|
# Creates a GdsApi::Search adapter to access via a search.* hostname
|
158
172
|
#
|
159
173
|
# @return [GdsApi::Search]
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: addressable
|
@@ -267,14 +267,14 @@ dependencies:
|
|
267
267
|
requirements:
|
268
268
|
- - '='
|
269
269
|
- !ruby/object:Gem::Version
|
270
|
-
version: 5.0.
|
270
|
+
version: 5.0.7
|
271
271
|
type: :development
|
272
272
|
prerelease: false
|
273
273
|
version_requirements: !ruby/object:Gem::Requirement
|
274
274
|
requirements:
|
275
275
|
- - '='
|
276
276
|
- !ruby/object:Gem::Version
|
277
|
-
version: 5.0.
|
277
|
+
version: 5.0.7
|
278
278
|
- !ruby/object:Gem::Dependency
|
279
279
|
name: simplecov
|
280
280
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,6 +352,7 @@ files:
|
|
352
352
|
- lib/gds_api/response.rb
|
353
353
|
- lib/gds_api/search.rb
|
354
354
|
- lib/gds_api/search_api_v2.rb
|
355
|
+
- lib/gds_api/signon_api.rb
|
355
356
|
- lib/gds_api/support.rb
|
356
357
|
- lib/gds_api/support_api.rb
|
357
358
|
- lib/gds_api/test_helpers/account_api.rb
|
@@ -398,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
399
|
- !ruby/object:Gem::Version
|
399
400
|
version: '0'
|
400
401
|
requirements: []
|
401
|
-
rubygems_version: 3.6.
|
402
|
+
rubygems_version: 3.6.2
|
402
403
|
specification_version: 4
|
403
404
|
summary: Adapters to work with GDS APIs
|
404
405
|
test_files: []
|