gds-api-adapters 97.1.0 → 97.3.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: c727b23d7397797f8a4dc8167fade432fd4161efcc9062942e6f942058bbdfc7
4
- data.tar.gz: d4f897215feb468597bea8d62cb87c7c92bad5859ab1a7892c010aab99087d59
3
+ metadata.gz: ff4790d228201b1c229e1e2b884a2eae62465642cfe426581b5b3c32726536b2
4
+ data.tar.gz: d25f58e557df2982e70e1e373ee4665b0984aa1068944f0f33381cf0a931cc53
5
5
  SHA512:
6
- metadata.gz: 8a2de0818203bbd9f62766cbda6cbe7cb2402f87d5123d2a26cd094997dcf9acdb6a82575379329099c9434cdc13b8461abb57036d195c13a2a7e5e01d8fe609
7
- data.tar.gz: 9663d632dce82d41aaeea134e17fe30334893084d89b0d5c8ac3ae5c8f02c3df804f4e1599fb5017110beec1363c641801ea99d66a98444ad126a9c6fd7e9007
6
+ metadata.gz: 1fde2097672b343ebad3e5f55d7a15a2b1e42415611d6a49e6d39239dd0dd31941c73000043e264cfc7292e410454bc28910fe638715b6090d34cbd3b6829871
7
+ data.tar.gz: 7dc3ec03939c0cf2e0f92174c9a4588fd2b378aa0af457a2f876b6a743b19f2903a82a63b6e5f000a51295dd80e1e6e6577daeeaa4fd117d2158a4d2c11cec3e
@@ -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
@@ -4,5 +4,11 @@ module GdsApi
4
4
  request_url = "#{endpoint}/search.json?#{Rack::Utils.build_nested_query(args)}"
5
5
  get_json(request_url, additional_headers)
6
6
  end
7
+
8
+ def autocomplete(query)
9
+ args = { q: query }
10
+ request_url = "#{endpoint}/autocomplete.json?#{Rack::Utils.build_nested_query(args)}"
11
+ get_json(request_url)
12
+ end
7
13
  end
8
14
  end
@@ -374,18 +374,40 @@ module GdsApi
374
374
  # )
375
375
  # @param content_id [UUID, Mocha::ParameterMatchers::Anything]
376
376
  # @param total Integer
377
- # @param params [Hash]
378
- def stub_publishing_api_has_embedded_content(content_id:, total: 0, results: [])
379
- url = if content_id.is_a?(Mocha::ParameterMatchers::Anything)
380
- %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded}
381
- else
382
- "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/embedded"
383
- end
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: [], page_number: nil, order: nil)
380
+ url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/embedded"
381
+
382
+ query = {
383
+ "page" => page_number,
384
+ "order" => order,
385
+ }.compact
384
386
 
385
387
  stub_request(:get, url)
388
+ .with(query:)
386
389
  .to_return(body: {
387
390
  "content_id" => content_id,
388
391
  "total" => total,
392
+ "total_pages" => total_pages,
393
+ "results" => results,
394
+ }.to_json)
395
+ end
396
+
397
+ def stub_publishing_api_has_embedded_content_for_any_content_id(total: 0, total_pages: 0, results: [], page_number: nil, order: nil)
398
+ url = %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded}
399
+
400
+ query = {
401
+ "page" => page_number,
402
+ "order" => order,
403
+ }.compact
404
+
405
+ stub_request(:get, url)
406
+ .with { |request| WebMock::Util::QueryMapper.query_to_values(request.uri.query) == query }
407
+ .to_return(body: {
408
+ "content_id" => SecureRandom.uuid,
409
+ "total" => total,
410
+ "total_pages" => total_pages,
389
411
  "results" => results,
390
412
  }.to_json)
391
413
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "97.1.0".freeze
2
+ VERSION = "97.3.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.1.0
4
+ version: 97.3.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-30 00:00:00.000000000 Z
11
+ date: 2024-11-14 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