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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4713a40baf4587862f28d5ab412bff34567eb2be929f81bf9f9946d119a978a3
4
- data.tar.gz: 6c924fb31cdcc61d690f948b372d6c29b25cccd622431803b784755b5d89a138
3
+ metadata.gz: b2b9f52394507921888ca9abe107c764de4af4da163dc2609f9909559f31e288
4
+ data.tar.gz: 94ff2e4bfb6f7a6b015e0049f82bc609cdbe416ee6355fdcc757b3d8d3177668
5
5
  SHA512:
6
- metadata.gz: 5c40c6142acf029075d1e2fb0438a53d62bde1a6ea7f3d4ab48c1e3381b444b2448cd3929f41e090bc96b9ffae7043e65f8cdb843b232a893191076177ad084a
7
- data.tar.gz: b15571c36e56b8722eae8deb09562184b88e1b9dc626108517929d982cb91c3aaef8d75dd9a5237cddcfd8c8184994c6ef88b23c5eecbb852f0b8c5db6e833dd
6
+ metadata.gz: b1cdf84bd90af029ea2c0ca24cc091cdc3b69b9c261ee6ec2632b4587e4c7db454fb56de499d0e499b110ac39567c013313f6ee6440368fe46dbf67f0ed07e74
7
+ data.tar.gz: 53ad365fffa3ac456e7e77412c986af8e6403dabb63c571a3327db5ac16fbcf573605d901c8ca29bf6cea9f1e9573320299c8e40050a0d7d9e4ea17ec2ca73b3
@@ -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
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "98.0.0".freeze
2
+ VERSION = "98.1.0".freeze
3
3
  end
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.0.0
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-17 00:00:00.000000000 Z
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.0
401
+ rubygems_version: 3.6.1
402
402
  specification_version: 4
403
403
  summary: Adapters to work with GDS APIs
404
404
  test_files: []