gds-api-adapters 97.0.0 → 97.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c352a48f1552b0934b7bdd88e8783b8c598b727353559ca6ca30a27877833a6
4
- data.tar.gz: aaba187980a1326a859de794faca1e7e836c5385a32f7d12ea3c9c13a7d5a9ec
3
+ metadata.gz: 28d51629867498d4a82ac5e2ea9a1062a016144545e905060d4dadf6a8116b1a
4
+ data.tar.gz: 5c376df981bae6c3197e3c3a98e45375d168256a3d5b6bd3700704e64ca4ee39
5
5
  SHA512:
6
- metadata.gz: d06232b4511622aa14a0d8169b338d6f12eb320d38c2c16e0796a6b476c3fc2a9fe54b779fc4f43d886b37978864e24f787c6c6c0c4453a37838f5d0545785d2
7
- data.tar.gz: f7247d52a2e02f6fca017f3b44f2aee212f63ddb3fd868862deb4b005e703bcf412cd74777b3ec1e94145eec476ff70bef7443e9e9426f4dd6f0d12a5d6beeef
6
+ metadata.gz: fb03d3158c4e924abd93cbef80c524e65b2efd190056d0fa63a296ba7a58ea5af80e98bf53d45ebef59903d02121bc1d826901c2cedc8028521ed5ede199a605
7
+ data.tar.gz: '0334915fa9576323f28f07d4bc9aa5d904ad3573078a63b9b62f6dd5fb3c63bd96f2e6f22ffab5981639bac730231719959686034f91614d111ac4de4d3e0d4a'
@@ -339,18 +339,21 @@ class GdsApi::PublishingApi < GdsApi::Base
339
339
 
340
340
  # Get content items which embed a reusable content_id
341
341
  #
342
- # No params are currently permitted.
343
- #
344
- # @example
342
+ # @param content_id [UUID]
343
+ # @param params [Hash]
345
344
  #
346
- # publishing_api.get_content_by_embedded_document("4b148ebc-b2bb-40db-8e48-dd8cff363ff7")
345
+ # publishing_api.get_content_by_embedded_document(
346
+ # "4b148ebc-b2bb-40db-8e48-dd8cff363ff7",
347
+ # { page: 1, order: '-last_edited_at' }
348
+ # )
347
349
  #
348
350
  # @return [GdsApi::Response] A response containing a summarised list of the content items which embed the target.
349
351
  # The content items returned will be in either the draft of published state.
350
352
  #
351
353
  # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_idembedded
352
- def get_content_by_embedded_document(content_id)
353
- get_json("#{endpoint}/v2/content/#{content_id}/embedded")
354
+ def get_content_by_embedded_document(content_id, params = {})
355
+ query = query_string(params)
356
+ get_json("#{endpoint}/v2/content/#{content_id}/embedded#{query}")
354
357
  end
355
358
 
356
359
  # Returns an Enumerator of content items for the provided
@@ -550,6 +553,15 @@ class GdsApi::PublishingApi < GdsApi::Base
550
553
  get_json("#{endpoint}/v2/schemas/#{schema_name}").to_hash
551
554
  end
552
555
 
556
+ # Make a GraphQL query
557
+ #
558
+ # @param query [String]
559
+ #
560
+ # @return [Hash] A response with the result of the GraphQL query.
561
+ def graphql_query(query)
562
+ post_json("#{endpoint}/graphql", query:).to_hash
563
+ end
564
+
553
565
  private
554
566
 
555
567
  def content_url(content_id, params = {})
@@ -188,6 +188,19 @@ module GdsApi
188
188
  stub_request(:any, /#{PUBLISHING_API_ENDPOINT}\/.*/).to_return(status: 503)
189
189
  end
190
190
 
191
+ # Stub a POST /graphql request
192
+ #
193
+ # @param query [String]
194
+ def stub_publishing_api_graphql_query(query, response_hash = {})
195
+ url = "#{PUBLISHING_API_ENDPOINT}/graphql"
196
+ response = {
197
+ status: 200,
198
+ body: response_hash.to_json,
199
+ headers: { "Content-Type" => "application/json; charset=utf-8" },
200
+ }
201
+ stub_request(:post, url).with(body: { query: }).to_return(response)
202
+ end
203
+
191
204
  # Assert that a draft was saved and published, and links were updated.
192
205
  # - PUT /v2/content/:content_id
193
206
  # - POST /v2/content/:content_id/publish
@@ -361,8 +374,9 @@ module GdsApi
361
374
  # )
362
375
  # @param content_id [UUID, Mocha::ParameterMatchers::Anything]
363
376
  # @param total Integer
364
- # @param params [Hash]
365
- def stub_publishing_api_has_embedded_content(content_id:, total: 0, results: [])
377
+ # @param total_pages Integer
378
+ # @param results [Hash]
379
+ def stub_publishing_api_has_embedded_content(content_id:, total: 0, total_pages: 0, results: [])
366
380
  url = if content_id.is_a?(Mocha::ParameterMatchers::Anything)
367
381
  %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded}
368
382
  else
@@ -373,6 +387,7 @@ module GdsApi
373
387
  .to_return(body: {
374
388
  "content_id" => content_id,
375
389
  "total" => total,
390
+ "total_pages" => total_pages,
376
391
  "results" => results,
377
392
  }.to_json)
378
393
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "97.0.0".freeze
2
+ VERSION = "97.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 97.0.0
4
+ version: 97.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -402,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
402
  - !ruby/object:Gem::Version
403
403
  version: '0'
404
404
  requirements: []
405
- rubygems_version: 3.5.22
405
+ rubygems_version: 3.5.23
406
406
  signing_key:
407
407
  specification_version: 4
408
408
  summary: Adapters to work with GDS APIs