gds-api-adapters 96.0.1 → 96.0.3

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: 97f27ebc485a71a0b76119ca9e0f8b4544b6da2e77f74730ac7a641c7056fa12
4
- data.tar.gz: 716e69344154e3cc0bed94ac564f9e1aa598f5b51c86873dc60d61d2449f8b23
3
+ metadata.gz: 3182c86f70e20b3d92c0cf4f28f63a487e343dff7394d41de0f0953b51fde3fa
4
+ data.tar.gz: 2e31481af69353c207b13cc4e94c6e59a7f151c94c5eda22d5b2a0d0c4ef86ef
5
5
  SHA512:
6
- metadata.gz: 3943261403391e42f4ff59e0eade97bcb45830e69bf8b267e7b9b9da73019c8344d59ddcbc3ea10e766ca299bbe0a900ba8528a60e021fa7b0cdd3c098c53e65
7
- data.tar.gz: f518c237981c112048dfc205cfe8f3cdd57c4ae3398bbb0917e1b1b4e556e4da1e99099b9f2f31cb5783c564c01b62d7ee6f2254cf76ff75c84b9a1242687e23
6
+ metadata.gz: 3b4d1743e125d8d1d8928fc7d4bc705fee3dd0eae19342d75d5c07f28dcea2590f8986efc3fd4671885ad610c311cf88deb62bccecd580cef39c3231cbe93834
7
+ data.tar.gz: a3a01fd52aa66cf83a346c90a025fa7972aee550f19f81de5ff3d033d98415101cf900a2e3e455286e245675a6aaa85ed7a3c1c93a6ac974355cb59eadac4845
@@ -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
  #
@@ -487,6 +503,53 @@ class GdsApi::PublishingApi < GdsApi::Base
487
503
  e
488
504
  end
489
505
 
506
+ # Get all schemas
507
+ #
508
+ # @return [GdsApi::Response] A map of schema names with JSON schemas.
509
+ #
510
+ # @example
511
+ #
512
+ # publishing_api.get_schemas()
513
+ # # => {
514
+ # "email_address" => {
515
+ # "type": "email_address",
516
+ # "required": ["email"],
517
+ # "properties": {
518
+ # "email": { "type" => "string" },
519
+ # },
520
+ # }
521
+ # }
522
+ #
523
+ # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2schemas
524
+ def get_schemas
525
+ get_json("#{endpoint}/v2/schemas").to_hash
526
+ end
527
+
528
+ # Get a content schema by name
529
+ #
530
+ # @param schema_name [String]
531
+ #
532
+ # @return [GdsApi::Response] A response mapping schema name with JSON schema.
533
+ #
534
+ # @example
535
+ #
536
+ # publishing_api.get_schema("email_address")
537
+ # # => {
538
+ # "email_address" => {
539
+ # "type": "email_address",
540
+ # "required": ["email"],
541
+ # "properties": {
542
+ # "email": { "type" => "string" },
543
+ # },
544
+ # }
545
+ # }
546
+ #
547
+ # @raise [HTTPNotFound] when the schema is not found
548
+ # @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2schemasschema_name
549
+ def get_schema(schema_name)
550
+ get_json("#{endpoint}/v2/schemas/#{schema_name}").to_hash
551
+ end
552
+
490
553
  private
491
554
 
492
555
  def content_url(content_id, params = {})
@@ -22,6 +22,22 @@ class GdsApi::SupportApi < GdsApi::Base
22
22
  post_json("#{endpoint}/anonymous-feedback/global-export-requests", global_export_request: request_details)
23
23
  end
24
24
 
25
+ # Raise a support ticket
26
+ # Makes a +POST+ request to support-api to create a new support ticket.
27
+ #
28
+ # @params params [Hash] Any attributes that relate to creating a new support ticket.
29
+
30
+ # @example
31
+ # SupportApi.raise_support_ticket(
32
+ # subject: "Feedback for app",
33
+ # tags: ["app_name"]
34
+ # user_agent: "Safari",
35
+ # description: "Ticket details go here.",
36
+ # )
37
+ def raise_support_ticket(params)
38
+ post_json("#{endpoint}/support-tickets", params)
39
+ end
40
+
25
41
  # Create a Page Improvement
26
42
  #
27
43
  # Makes a +POST+ request to the support api to create a Page Improvement.
@@ -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)
@@ -802,6 +839,59 @@ module GdsApi
802
839
  body: { error: }.to_json)
803
840
  end
804
841
 
842
+ # Stub a request to get a schema by schema name
843
+ #
844
+ # @param [String] schema name
845
+ #
846
+ # @example
847
+ # stub_publishing_api_has_schemas_for_schema_name(
848
+ # "email_address",
849
+ # { "email_address" => {
850
+ # "type": "email_address",
851
+ # "required": ["email"],
852
+ # "properties": {
853
+ # "email": { "type" => "string" },
854
+ # },
855
+ # },
856
+ # }
857
+ # )
858
+ def stub_publishing_api_has_schemas_for_schema_name(schema_name, schema)
859
+ url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas/#{schema_name}"
860
+ stub_request(:get, url).to_return(status: 200, body: schema.to_json, headers: {})
861
+ end
862
+
863
+ def stub_publishing_api_schema_name_path_to_return_not_found(schema_name)
864
+ url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas/#{schema_name}"
865
+ stub_request(:get, url).to_return(status: 404, headers: { "Content-Type" => "application/json; charset=utf-8" })
866
+ end
867
+
868
+ # Stub a request to get all schemas
869
+ #
870
+ #
871
+ # @example
872
+ # stub_publishing_api_has_schemas(
873
+ # {
874
+ # "email_address" => {
875
+ # "type": "email_address",
876
+ # "required": ["email"],
877
+ # "properties": {
878
+ # "email": { "type" => "string" },
879
+ # },
880
+ # },
881
+ # "tax_bracket" => {
882
+ # "type": "tax_bracket",
883
+ # "required": ["code"],
884
+ # "properties": {
885
+ # "code": { "type" => "string" },
886
+ # },
887
+ # }
888
+ # }
889
+ # )
890
+ def stub_publishing_api_has_schemas(schemas)
891
+ url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas"
892
+ stub_request(:get, url).to_return(status: 200, body: schemas.to_json, headers: {})
893
+ end
894
+
805
895
  private
806
896
 
807
897
  def stub_publishing_api_put(*args)
@@ -150,6 +150,18 @@ module GdsApi
150
150
  .to_return(status: 200, body: response_body.to_json)
151
151
  end
152
152
 
153
+ def stub_support_api_valid_raise_support_ticket(params)
154
+ post_stub = stub_http_request(:post, "#{SUPPORT_API_ENDPOINT}/support-tickets")
155
+ post_stub.with(body: params)
156
+ post_stub.to_return(status: 201, body: { status: "success" }.to_json)
157
+ end
158
+
159
+ def stub_support_api_invalid_raise_support_ticket(params)
160
+ post_stub = stub_http_request(:post, "#{SUPPORT_API_ENDPOINT}/support-tickets")
161
+ post_stub.with(body: params)
162
+ post_stub.to_return(status: 422, body: { status: "error" }.to_json)
163
+ end
164
+
153
165
  def stub_any_support_api_call
154
166
  stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
155
167
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "96.0.1".freeze
2
+ VERSION = "96.0.3".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.1
4
+ version: 96.0.3
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-05-21 00:00:00.000000000 Z
11
+ date: 2024-08-30 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.16.1
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.16.1
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.10
405
+ rubygems_version: 3.5.18
406
406
  signing_key:
407
407
  specification_version: 4
408
408
  summary: Adapters to work with GDS APIs