gds-api-adapters 99.2.0 → 100.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/base.rb +6 -0
- data/lib/gds_api/content_store.rb +0 -6
- data/lib/gds_api/publishing_api.rb +9 -0
- data/lib/gds_api/test_helpers/publishing_api.rb +29 -0
- data/lib/gds_api/version.rb +1 -1
- data/lib/gds_api.rb +0 -11
- metadata +4 -5
- data/lib/gds_api/maslow.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a97f28eec3d867d6b785d0f21be19bee59e5f554bdd8e8e8f560144c44adb3de
|
4
|
+
data.tar.gz: 7159ed4dcbe4373a8ff071ccfce1c48a49b701925a06b0842a8f6333529e5b4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ce95b7d3dfc469b4bb27442648e4cd38287a0ab9e8e56b202f4ffb0b99e26236f6dcef3d908a462e4d0f9d4e8a3c338fa2d4e8efba3338ae250422bfca19e2
|
7
|
+
data.tar.gz: 7c5cfb799ee20f8c632ebd508e31b28cd5a7c05233bcc661a7677b3c212741362c9607b0ae10b9f148fe16458276994d38afbfaa9c53e4f6e4e2b626e8784649
|
data/lib/gds_api/base.rb
CHANGED
@@ -8,6 +8,12 @@ class GdsApi::Base
|
|
8
8
|
class InvalidAPIURL < StandardError
|
9
9
|
end
|
10
10
|
|
11
|
+
class ItemNotFound < GdsApi::HTTPNotFound
|
12
|
+
def self.build_from(http_error)
|
13
|
+
new(http_error.code, http_error.message, http_error.error_details)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
11
17
|
extend Forwardable
|
12
18
|
|
13
19
|
def client
|
@@ -4,12 +4,6 @@ require_relative "base"
|
|
4
4
|
require_relative "exceptions"
|
5
5
|
|
6
6
|
class GdsApi::ContentStore < GdsApi::Base
|
7
|
-
class ItemNotFound < GdsApi::HTTPNotFound
|
8
|
-
def self.build_from(http_error)
|
9
|
-
new(http_error.code, http_error.message, http_error.error_details)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
7
|
def content_item(base_path)
|
14
8
|
get_json(content_item_url(base_path))
|
15
9
|
rescue GdsApi::HTTPNotFound => e
|
@@ -636,6 +636,15 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
636
636
|
post_json("#{endpoint}/graphql", query:, &create_response)
|
637
637
|
end
|
638
638
|
|
639
|
+
# Get the live content item using GraphQL
|
640
|
+
#
|
641
|
+
# @return [GdsApi::Response] A response with the result of the GraphQL query formatted like a Content Store content item.
|
642
|
+
def graphql_live_content_item(base_path)
|
643
|
+
get_json("#{endpoint}/graphql/content#{base_path}")
|
644
|
+
rescue GdsApi::HTTPNotFound => e
|
645
|
+
raise ItemNotFound.build_from(e)
|
646
|
+
end
|
647
|
+
|
639
648
|
private
|
640
649
|
|
641
650
|
def content_url(content_id, params = {})
|
@@ -214,6 +214,31 @@ module GdsApi
|
|
214
214
|
stub_request(:post, url).with(body: { query: }).to_return(response)
|
215
215
|
end
|
216
216
|
|
217
|
+
# Stub a GET /graphql/content/:base_path request
|
218
|
+
def stub_publishing_api_graphql_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
|
219
|
+
max_age = options.fetch(:max_age, 900)
|
220
|
+
body = body.to_json unless body.is_a?(String)
|
221
|
+
|
222
|
+
stub_request(:get, "#{PUBLISHING_API_ENDPOINT}/graphql/content#{base_path}").to_return(
|
223
|
+
status: 200,
|
224
|
+
body:,
|
225
|
+
headers: {
|
226
|
+
cache_control: "public, max-age=#{max_age}",
|
227
|
+
date: Time.now.httpdate,
|
228
|
+
},
|
229
|
+
)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Stub a GET /graphql/content/:base_path request returns 404 not found
|
233
|
+
def stub_publishing_api_graphql_does_not_have_item(base_path)
|
234
|
+
stub_request(:get, "#{PUBLISHING_API_ENDPOINT}/graphql/content#{base_path}").to_return(status: 404, headers: {})
|
235
|
+
end
|
236
|
+
|
237
|
+
# Stub a GET /graphql/content/:base_path request returns 410 gone
|
238
|
+
def stub_publishing_api_graphql_has_gone_item(base_path)
|
239
|
+
stub_request(:get, "#{PUBLISHING_API_ENDPOINT}/graphql/content#{base_path}").to_return(status: 410, headers: {})
|
240
|
+
end
|
241
|
+
|
217
242
|
# Assert that a draft was saved and published, and links were updated.
|
218
243
|
# - PUT /v2/content/:content_id
|
219
244
|
# - POST /v2/content/:content_id/publish
|
@@ -1048,6 +1073,10 @@ module GdsApi
|
|
1048
1073
|
def content_item_for_publishing_api(base_path, publishing_app = "publisher")
|
1049
1074
|
content_item_for_base_path(base_path).merge("publishing_app" => publishing_app)
|
1050
1075
|
end
|
1076
|
+
|
1077
|
+
def content_item_for_base_path(base_path)
|
1078
|
+
super.merge("base_path" => base_path)
|
1079
|
+
end
|
1051
1080
|
end
|
1052
1081
|
end
|
1053
1082
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/lib/gds_api.rb
CHANGED
@@ -11,7 +11,6 @@ require "gds_api/licence_application"
|
|
11
11
|
require "gds_api/link_checker_api"
|
12
12
|
require "gds_api/local_links_manager"
|
13
13
|
require "gds_api/locations_api"
|
14
|
-
require "gds_api/maslow"
|
15
14
|
require "gds_api/organisations"
|
16
15
|
require "gds_api/publishing_api"
|
17
16
|
require "gds_api/search"
|
@@ -123,16 +122,6 @@ module GdsApi
|
|
123
122
|
GdsApi::LocationsApi.new(Plek.find("locations-api"), options)
|
124
123
|
end
|
125
124
|
|
126
|
-
# Creates a GdsApi::Maslow adapter
|
127
|
-
#
|
128
|
-
# It's set to use an external url as an endpoint as the Maslow adapter is
|
129
|
-
# used to generate external links
|
130
|
-
#
|
131
|
-
# @return [GdsApi::Maslow]
|
132
|
-
def self.maslow(options = {})
|
133
|
-
GdsApi::Maslow.new(Plek.new.external_url_for("maslow"), options)
|
134
|
-
end
|
135
|
-
|
136
125
|
# Creates a GdsApi::Organisations adapter for accessing Whitehall
|
137
126
|
# APIs through the origin, where the requests will be handled by
|
138
127
|
# Collections frontend.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 100.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -267,14 +267,14 @@ dependencies:
|
|
267
267
|
requirements:
|
268
268
|
- - '='
|
269
269
|
- !ruby/object:Gem::Version
|
270
|
-
version: 5.1.
|
270
|
+
version: 5.1.19
|
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.1.
|
277
|
+
version: 5.1.19
|
278
278
|
- !ruby/object:Gem::Dependency
|
279
279
|
name: simplecov
|
280
280
|
requirement: !ruby/object:Gem::Requirement
|
@@ -342,7 +342,6 @@ files:
|
|
342
342
|
- lib/gds_api/list_response.rb
|
343
343
|
- lib/gds_api/local_links_manager.rb
|
344
344
|
- lib/gds_api/locations_api.rb
|
345
|
-
- lib/gds_api/maslow.rb
|
346
345
|
- lib/gds_api/middleware/govuk_header_sniffer.rb
|
347
346
|
- lib/gds_api/organisations.rb
|
348
347
|
- lib/gds_api/places_manager.rb
|
@@ -399,7 +398,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
399
398
|
- !ruby/object:Gem::Version
|
400
399
|
version: '0'
|
401
400
|
requirements: []
|
402
|
-
rubygems_version: 3.
|
401
|
+
rubygems_version: 3.7.1
|
403
402
|
specification_version: 4
|
404
403
|
summary: Adapters to work with GDS APIs
|
405
404
|
test_files: []
|