gds-api-adapters 97.2.0 → 97.4.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: 28d51629867498d4a82ac5e2ea9a1062a016144545e905060d4dadf6a8116b1a
4
- data.tar.gz: 5c376df981bae6c3197e3c3a98e45375d168256a3d5b6bd3700704e64ca4ee39
3
+ metadata.gz: 65cb765ee9c7ec5ecc14786031a300445ebe47913fd1725dc45029544ca4bbae
4
+ data.tar.gz: e4a1d38fc0d071fb94a8c23f3ca9835a39782ff494c6ac169ff5f4a54d1aa74a
5
5
  SHA512:
6
- metadata.gz: fb03d3158c4e924abd93cbef80c524e65b2efd190056d0fa63a296ba7a58ea5af80e98bf53d45ebef59903d02121bc1d826901c2cedc8028521ed5ede199a605
7
- data.tar.gz: '0334915fa9576323f28f07d4bc9aa5d904ad3573078a63b9b62f6dd5fb3c63bd96f2e6f22ffab5981639bac730231719959686034f91614d111ac4de4d3e0d4a'
6
+ metadata.gz: 1789520088667eed07cff11b73c47b8b88f0f44a9dcfddb3ac18c876f502011d88e545bd0a3bf687f48991a64aaa39afd49e82905be68e10043964f4e5caa65a
7
+ data.tar.gz: 130e302e05e3337dc9a2a536cba8cde370c809c9efab27e9ba394ab97ed494c313cf30cf88a6206e0be29cda8855706a6300471d2f86565e337fe26b3bf73719
@@ -342,7 +342,7 @@ class GdsApi::PublishingApi < GdsApi::Base
342
342
  # @param content_id [UUID]
343
343
  # @param params [Hash]
344
344
  #
345
- # publishing_api.get_content_by_embedded_document(
345
+ # publishing_api.get_host_content_for_content_id(
346
346
  # "4b148ebc-b2bb-40db-8e48-dd8cff363ff7",
347
347
  # { page: 1, order: '-last_edited_at' }
348
348
  # )
@@ -350,10 +350,15 @@ class GdsApi::PublishingApi < GdsApi::Base
350
350
  # @return [GdsApi::Response] A response containing a summarised list of the content items which embed the target.
351
351
  # The content items returned will be in either the draft of published state.
352
352
  #
353
- # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_idembedded
354
- def get_content_by_embedded_document(content_id, params = {})
353
+ # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_idhost-content
354
+ def get_host_content_for_content_id(content_id, params = {})
355
355
  query = query_string(params)
356
- get_json("#{endpoint}/v2/content/#{content_id}/embedded#{query}")
356
+ get_json("#{endpoint}/v2/content/#{content_id}/host-content#{query}")
357
+ end
358
+
359
+ def get_content_by_embedded_document(content_id, params = {})
360
+ warn "GdsAPI::PublishingApi: #get_content_by_embedded_document deprecated (please use #get_host_content_for_content_id)"
361
+ get_host_content_for_content_id(content_id, params)
357
362
  end
358
363
 
359
364
  # 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
@@ -376,14 +376,16 @@ module GdsApi
376
376
  # @param total Integer
377
377
  # @param total_pages Integer
378
378
  # @param results [Hash]
379
- def stub_publishing_api_has_embedded_content(content_id:, total: 0, total_pages: 0, results: [])
380
- url = if content_id.is_a?(Mocha::ParameterMatchers::Anything)
381
- %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded}
382
- else
383
- "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/embedded"
384
- end
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
385
386
 
386
387
  stub_request(:get, url)
388
+ .with(query:)
387
389
  .to_return(body: {
388
390
  "content_id" => content_id,
389
391
  "total" => total,
@@ -392,6 +394,24 @@ module GdsApi
392
394
  }.to_json)
393
395
  end
394
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,
411
+ "results" => results,
412
+ }.to_json)
413
+ end
414
+
395
415
  # This method has been refactored into publishing_api_has_content (above)
396
416
  # publishing_api_has_content allows for flexible passing in of arguments, please use instead
397
417
  def stub_publishing_api_has_fields_for_document(document_type, items, fields)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "97.2.0".freeze
2
+ VERSION = "97.4.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.2.0
4
+ version: 97.4.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-11-13 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -268,14 +268,14 @@ dependencies:
268
268
  requirements:
269
269
  - - '='
270
270
  - !ruby/object:Gem::Version
271
- version: 5.0.2
271
+ version: 5.0.3
272
272
  type: :development
273
273
  prerelease: false
274
274
  version_requirements: !ruby/object:Gem::Requirement
275
275
  requirements:
276
276
  - - '='
277
277
  - !ruby/object:Gem::Version
278
- version: 5.0.2
278
+ version: 5.0.3
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: simplecov
281
281
  requirement: !ruby/object:Gem::Requirement