gds-api-adapters 96.0.2 → 97.0.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: dc4d5293f2005f19ecf4e118705f8dada987a1dcc7d6a100ee750402d5d3ca2f
4
- data.tar.gz: 90b47aa245e497c7d652fc1b2885af98438b69b704b8f7cb229b9960492426e2
3
+ metadata.gz: 6c352a48f1552b0934b7bdd88e8783b8c598b727353559ca6ca30a27877833a6
4
+ data.tar.gz: aaba187980a1326a859de794faca1e7e836c5385a32f7d12ea3c9c13a7d5a9ec
5
5
  SHA512:
6
- metadata.gz: f2bfe2f375887428b7f29dd888bce619900f0ff8f0c3d51d37fe7771a5282492ad54f584022ac28d4a2e7901c015cb9968c00b15d611b0915302027a27cc1e96
7
- data.tar.gz: 3c5ef5415b155090e5c763d5c9087b8b1f2e7db181d558aba488bdcb35a548113d221a6330245999c3e6ea1d2665ef675e84d9efc9924158bd044ecaf1f659f6
6
+ metadata.gz: d06232b4511622aa14a0d8169b338d6f12eb320d38c2c16e0796a6b476c3fc2a9fe54b779fc4f43d886b37978864e24f787c6c6c0c4453a37838f5d0545785d2
7
+ data.tar.gz: f7247d52a2e02f6fca017f3b44f2aee212f63ddb3fd868862deb4b005e703bcf412cd74777b3ec1e94145eec476ff70bef7443e9e9426f4dd6f0d12a5d6beeef
data/README.md CHANGED
@@ -110,6 +110,30 @@ Then at the PSQL command line:
110
110
 
111
111
  `template1=# CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`
112
112
 
113
+ ## Releasing
114
+
115
+ 1. Read the CHANGELOG.md and decide on the new semantic version number
116
+ 1. Create a release branch, eg. `release-96.0.3`
117
+ 1. Update the CHANGELOG.md
118
+ - Declare a new version number
119
+ - Move all unreleased changes beneath it
120
+ 1. Update `lib/gds_api/version.rb` to match, eg
121
+
122
+ ```ruby
123
+ module GdsApi
124
+ VERSION = "96.0.3".freeze
125
+ end
126
+ ```
127
+
128
+ 1. Copy the lines from the CHANGELOG.md into the git commit
129
+ 1. Propose and merge the pull request into `main`
130
+
131
+ Nb:
132
+
133
+ - You do not need to set any git tags
134
+ - After merging, CI will release the new version of the gem and Dependabot will
135
+ propose the new version of the gem to help distribute the changes to consumers
136
+
113
137
  ## Licence
114
138
 
115
139
  Released under the MIT Licence, a copy of which can be found in the file
@@ -53,7 +53,7 @@ private
53
53
  "#{Plek.new.website_root}#{destination_uri}"
54
54
  end
55
55
 
56
- [url, status_code(redirect)]
56
+ [url, 301]
57
57
  end
58
58
 
59
59
  private_class_method :new
@@ -105,10 +105,6 @@ private
105
105
 
106
106
  uri.to_s
107
107
  end
108
-
109
- def status_code(redirect)
110
- redirect["redirect_type"] == "temporary" ? 302 : 301
111
- end
112
108
  end
113
109
 
114
110
  class UnresolvedRedirect < GdsApi::BaseError; end
@@ -337,6 +337,22 @@ class GdsApi::PublishingApi < GdsApi::Base
337
337
  get_json("#{endpoint}/v2/content#{query}")
338
338
  end
339
339
 
340
+ # Get content items which embed a reusable content_id
341
+ #
342
+ # No params are currently permitted.
343
+ #
344
+ # @example
345
+ #
346
+ # publishing_api.get_content_by_embedded_document("4b148ebc-b2bb-40db-8e48-dd8cff363ff7")
347
+ #
348
+ # @return [GdsApi::Response] A response containing a summarised list of the content items which embed the target.
349
+ # The content items returned will be in either the draft of published state.
350
+ #
351
+ # @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
+ end
355
+
340
356
  # Returns an Enumerator of content items for the provided
341
357
  # query string parameters.
342
358
  #
@@ -33,7 +33,7 @@ class GdsApi::Router < GdsApi::Base
33
33
  )
34
34
  end
35
35
 
36
- def add_redirect_route(path, type, destination, redirect_type = "permanent", options = {})
36
+ def add_redirect_route(path, type, destination, options = {})
37
37
  put_json(
38
38
  "#{endpoint}/routes",
39
39
  route: {
@@ -41,7 +41,6 @@ class GdsApi::Router < GdsApi::Base
41
41
  route_type: type,
42
42
  handler: "redirect",
43
43
  redirect_to: destination,
44
- redirect_type:,
45
44
  segments_mode: options[:segments_mode],
46
45
  },
47
46
  )
@@ -340,6 +340,43 @@ module GdsApi
340
340
  .to_return(status: 200, body: body.to_json, headers: {})
341
341
  end
342
342
 
343
+ # Stub GET /v2/content/:content_id/embedded to return a list of content items that embed the target content_id
344
+ #
345
+ # @example
346
+ #
347
+ # stub_publishing_api_has_content_(
348
+ # content_id: "9faacf5c-f4e6-4bf9-ba90-413e997c1f22" # this is the content_id for a reusable edition
349
+ # total: 1 # the number of results returned
350
+ # results: [{
351
+ # "title" => "foo",
352
+ # "document_type" => "document",
353
+ # "base_path" => "/foo",
354
+ # "content_id" => "e60fae2a-5490-4e2f-9e80-2093c47608d4",
355
+ # "primary_publishing_organisation" => {
356
+ # "content_id" => "7662e1e7-79f9-4d0a-b754-6232186851f6",
357
+ # "title" => "bar",
358
+ # "base_path" => "/organisation/bar",
359
+ # },
360
+ # }] # an array of content items that embed the target content_id
361
+ # )
362
+ # @param content_id [UUID, Mocha::ParameterMatchers::Anything]
363
+ # @param total Integer
364
+ # @param params [Hash]
365
+ def stub_publishing_api_has_embedded_content(content_id:, total: 0, results: [])
366
+ url = if content_id.is_a?(Mocha::ParameterMatchers::Anything)
367
+ %r{\A#{PUBLISHING_API_V2_ENDPOINT}/content/[0-9a-fA-F-]{36}/embedded}
368
+ else
369
+ "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}/embedded"
370
+ end
371
+
372
+ stub_request(:get, url)
373
+ .to_return(body: {
374
+ "content_id" => content_id,
375
+ "total" => total,
376
+ "results" => results,
377
+ }.to_json)
378
+ end
379
+
343
380
  # This method has been refactored into publishing_api_has_content (above)
344
381
  # publishing_api_has_content allows for flexible passing in of arguments, please use instead
345
382
  def stub_publishing_api_has_fields_for_document(document_type, items, fields)
@@ -21,8 +21,8 @@ module GdsApi
21
21
  stub_router_has_route(path, handler: "backend", backend_id:, disabled:, route_type:)
22
22
  end
23
23
 
24
- def stub_router_has_redirect_route(path, redirect_to:, redirect_type: "permanent", route_type: "exact", disabled: false)
25
- stub_router_has_route(path, handler: "redirect", redirect_to:, redirect_type:, disabled:, route_type:)
24
+ def stub_router_has_redirect_route(path, redirect_to:, route_type: "exact", disabled: false)
25
+ stub_router_has_route(path, handler: "redirect", redirect_to:, disabled:, route_type:)
26
26
  end
27
27
 
28
28
  def stub_router_has_gone_route(path, route_type: "exact", disabled: false)
@@ -52,14 +52,13 @@ module GdsApi
52
52
  })
53
53
  end
54
54
 
55
- def stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil)
55
+ def stub_redirect_registration(path, type, destination, segments_mode = nil)
56
56
  stub_route_put({
57
57
  route: {
58
58
  incoming_path: path,
59
59
  route_type: type,
60
60
  handler: "redirect",
61
61
  redirect_to: destination,
62
- redirect_type:,
63
62
  segments_mode:,
64
63
  },
65
64
  })
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "96.0.2".freeze
2
+ VERSION = "97.0.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: 96.0.2
4
+ version: 97.0.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-06-25 00:00:00.000000000 Z
11
+ date: 2024-10-17 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: 4.18.0
271
+ version: 5.0.2
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: 4.18.0
278
+ version: 5.0.2
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: simplecov
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -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.14
405
+ rubygems_version: 3.5.22
406
406
  signing_key:
407
407
  specification_version: 4
408
408
  summary: Adapters to work with GDS APIs