gds-api-adapters 96.0.0 → 96.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/publishing_api.rb +47 -0
- data/lib/gds_api/support_api.rb +16 -0
- data/lib/gds_api/test_helpers/publishing_api.rb +53 -0
- data/lib/gds_api/test_helpers/support_api.rb +12 -0
- data/lib/gds_api/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc4d5293f2005f19ecf4e118705f8dada987a1dcc7d6a100ee750402d5d3ca2f
|
4
|
+
data.tar.gz: 90b47aa245e497c7d652fc1b2885af98438b69b704b8f7cb229b9960492426e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2bfe2f375887428b7f29dd888bce619900f0ff8f0c3d51d37fe7771a5282492ad54f584022ac28d4a2e7901c015cb9968c00b15d611b0915302027a27cc1e96
|
7
|
+
data.tar.gz: 3c5ef5415b155090e5c763d5c9087b8b1f2e7db181d558aba488bdcb35a548113d221a6330245999c3e6ea1d2665ef675e84d9efc9924158bd044ecaf1f659f6
|
@@ -487,6 +487,53 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
487
487
|
e
|
488
488
|
end
|
489
489
|
|
490
|
+
# Get all schemas
|
491
|
+
#
|
492
|
+
# @return [GdsApi::Response] A map of schema names with JSON schemas.
|
493
|
+
#
|
494
|
+
# @example
|
495
|
+
#
|
496
|
+
# publishing_api.get_schemas()
|
497
|
+
# # => {
|
498
|
+
# "email_address" => {
|
499
|
+
# "type": "email_address",
|
500
|
+
# "required": ["email"],
|
501
|
+
# "properties": {
|
502
|
+
# "email": { "type" => "string" },
|
503
|
+
# },
|
504
|
+
# }
|
505
|
+
# }
|
506
|
+
#
|
507
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2schemas
|
508
|
+
def get_schemas
|
509
|
+
get_json("#{endpoint}/v2/schemas").to_hash
|
510
|
+
end
|
511
|
+
|
512
|
+
# Get a content schema by name
|
513
|
+
#
|
514
|
+
# @param schema_name [String]
|
515
|
+
#
|
516
|
+
# @return [GdsApi::Response] A response mapping schema name with JSON schema.
|
517
|
+
#
|
518
|
+
# @example
|
519
|
+
#
|
520
|
+
# publishing_api.get_schema("email_address")
|
521
|
+
# # => {
|
522
|
+
# "email_address" => {
|
523
|
+
# "type": "email_address",
|
524
|
+
# "required": ["email"],
|
525
|
+
# "properties": {
|
526
|
+
# "email": { "type" => "string" },
|
527
|
+
# },
|
528
|
+
# }
|
529
|
+
# }
|
530
|
+
#
|
531
|
+
# @raise [HTTPNotFound] when the schema is not found
|
532
|
+
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2schemasschema_name
|
533
|
+
def get_schema(schema_name)
|
534
|
+
get_json("#{endpoint}/v2/schemas/#{schema_name}").to_hash
|
535
|
+
end
|
536
|
+
|
490
537
|
private
|
491
538
|
|
492
539
|
def content_url(content_id, params = {})
|
data/lib/gds_api/support_api.rb
CHANGED
@@ -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.
|
@@ -802,6 +802,59 @@ module GdsApi
|
|
802
802
|
body: { error: }.to_json)
|
803
803
|
end
|
804
804
|
|
805
|
+
# Stub a request to get a schema by schema name
|
806
|
+
#
|
807
|
+
# @param [String] schema name
|
808
|
+
#
|
809
|
+
# @example
|
810
|
+
# stub_publishing_api_has_schemas_for_schema_name(
|
811
|
+
# "email_address",
|
812
|
+
# { "email_address" => {
|
813
|
+
# "type": "email_address",
|
814
|
+
# "required": ["email"],
|
815
|
+
# "properties": {
|
816
|
+
# "email": { "type" => "string" },
|
817
|
+
# },
|
818
|
+
# },
|
819
|
+
# }
|
820
|
+
# )
|
821
|
+
def stub_publishing_api_has_schemas_for_schema_name(schema_name, schema)
|
822
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas/#{schema_name}"
|
823
|
+
stub_request(:get, url).to_return(status: 200, body: schema.to_json, headers: {})
|
824
|
+
end
|
825
|
+
|
826
|
+
def stub_publishing_api_schema_name_path_to_return_not_found(schema_name)
|
827
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas/#{schema_name}"
|
828
|
+
stub_request(:get, url).to_return(status: 404, headers: { "Content-Type" => "application/json; charset=utf-8" })
|
829
|
+
end
|
830
|
+
|
831
|
+
# Stub a request to get all schemas
|
832
|
+
#
|
833
|
+
#
|
834
|
+
# @example
|
835
|
+
# stub_publishing_api_has_schemas(
|
836
|
+
# {
|
837
|
+
# "email_address" => {
|
838
|
+
# "type": "email_address",
|
839
|
+
# "required": ["email"],
|
840
|
+
# "properties": {
|
841
|
+
# "email": { "type" => "string" },
|
842
|
+
# },
|
843
|
+
# },
|
844
|
+
# "tax_bracket" => {
|
845
|
+
# "type": "tax_bracket",
|
846
|
+
# "required": ["code"],
|
847
|
+
# "properties": {
|
848
|
+
# "code": { "type" => "string" },
|
849
|
+
# },
|
850
|
+
# }
|
851
|
+
# }
|
852
|
+
# )
|
853
|
+
def stub_publishing_api_has_schemas(schemas)
|
854
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/schemas"
|
855
|
+
stub_request(:get, url).to_return(status: 200, body: schemas.to_json, headers: {})
|
856
|
+
end
|
857
|
+
|
805
858
|
private
|
806
859
|
|
807
860
|
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
|
data/lib/gds_api/version.rb
CHANGED
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.
|
4
|
+
version: 96.0.2
|
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
|
+
date: 2024-06-25 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.
|
271
|
+
version: 4.18.0
|
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.
|
278
|
+
version: 4.18.0
|
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.
|
405
|
+
rubygems_version: 3.5.14
|
406
406
|
signing_key:
|
407
407
|
specification_version: 4
|
408
408
|
summary: Adapters to work with GDS APIs
|