gds-api-adapters 93.0.0 → 94.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gds_api/account_api.rb +8 -8
- data/lib/gds_api/asset_manager.rb +2 -2
- data/lib/gds_api/email_alert_api.rb +17 -17
- data/lib/gds_api/imminence.rb +3 -3
- data/lib/gds_api/json_client.rb +2 -2
- data/lib/gds_api/link_checker_api.rb +7 -7
- data/lib/gds_api/publishing_api/special_route_publisher.rb +3 -3
- data/lib/gds_api/publishing_api.rb +10 -10
- data/lib/gds_api/router.rb +2 -2
- data/lib/gds_api/test_helpers/account_api.rb +23 -23
- data/lib/gds_api/test_helpers/asset_manager.rb +1 -1
- data/lib/gds_api/test_helpers/calendars.rb +7 -7
- data/lib/gds_api/test_helpers/content_store.rb +3 -3
- data/lib/gds_api/test_helpers/email_alert_api.rb +40 -40
- data/lib/gds_api/test_helpers/imminence.rb +3 -3
- data/lib/gds_api/test_helpers/link_checker_api.rb +24 -24
- data/lib/gds_api/test_helpers/local_links_manager.rb +13 -13
- data/lib/gds_api/test_helpers/publishing_api.rb +17 -17
- data/lib/gds_api/test_helpers/router.rb +6 -6
- data/lib/gds_api/test_helpers/support_api.rb +1 -1
- data/lib/gds_api/version.rb +1 -1
- metadata +8 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c105d7b4ef8f10b6b76c82cc200ae304d442f492aaa493323a81dcb0f3f13d1
|
4
|
+
data.tar.gz: 9525d505b85b746b4d8cc975d027554b3bdb49280b7b2b0c53aa4b8de5baa80a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca2a25845234ab89b38b772044e03fe5ae468db150c1e40ac3a89ccd493c6c3cc00b28957a81a0ccea2dc4e4ef9a12479cd95aac53324668342f4075ab6f6c40
|
7
|
+
data.tar.gz: 26faeb12f452e79321c3601b277c550bb6cc3b822a3718734bbea8e64e18241d182169b27a6d2059304e4d47d2f84e08f4d7235c86b8c24a65ccb27a86924576
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -17,8 +17,8 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
17
17
|
def get_sign_in_url(redirect_path: nil, mfa: false)
|
18
18
|
querystring = nested_query_string(
|
19
19
|
{
|
20
|
-
redirect_path
|
21
|
-
mfa
|
20
|
+
redirect_path:,
|
21
|
+
mfa:,
|
22
22
|
}.compact,
|
23
23
|
)
|
24
24
|
get_json("#{endpoint}/api/oauth2/sign-in?#{querystring}")
|
@@ -31,7 +31,7 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
31
31
|
#
|
32
32
|
# @return [Hash] The value for the govuk_account_session header, the path to redirect the user to, and the GA client ID (if there is one)
|
33
33
|
def validate_auth_response(code:, state:)
|
34
|
-
post_json("#{endpoint}/api/oauth2/callback", code
|
34
|
+
post_json("#{endpoint}/api/oauth2/callback", code:, state:)
|
35
35
|
end
|
36
36
|
|
37
37
|
# Get an OIDC end-session URL to redirect the user to
|
@@ -59,7 +59,7 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
59
59
|
#
|
60
60
|
# @return [Hash] One field, "match", indicating whether the session matches the given email address
|
61
61
|
def match_user_by_email(email:, govuk_account_session: nil)
|
62
|
-
querystring = nested_query_string({ email:
|
62
|
+
querystring = nested_query_string({ email: })
|
63
63
|
get_json("#{endpoint}/api/user/match-by-email?#{querystring}", auth_headers(govuk_account_session))
|
64
64
|
end
|
65
65
|
|
@@ -79,8 +79,8 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
79
79
|
# @return [Hash] The user's subject identifier and email attributes
|
80
80
|
def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil)
|
81
81
|
params = {
|
82
|
-
email
|
83
|
-
email_verified
|
82
|
+
email:,
|
83
|
+
email_verified:,
|
84
84
|
}.compact
|
85
85
|
|
86
86
|
patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", params)
|
@@ -93,7 +93,7 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
93
93
|
#
|
94
94
|
# @return [Hash] The attribute values (if present), and a new session header
|
95
95
|
def get_attributes(attributes:, govuk_account_session:)
|
96
|
-
querystring = nested_query_string({ attributes:
|
96
|
+
querystring = nested_query_string({ attributes: }.compact)
|
97
97
|
get_json("#{endpoint}/api/attributes?#{querystring}", auth_headers(govuk_account_session))
|
98
98
|
end
|
99
99
|
|
@@ -104,7 +104,7 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
104
104
|
#
|
105
105
|
# @return [Hash] A new session header
|
106
106
|
def set_attributes(attributes:, govuk_account_session:)
|
107
|
-
patch_json("#{endpoint}/api/attributes", { attributes:
|
107
|
+
patch_json("#{endpoint}/api/attributes", { attributes: }, auth_headers(govuk_account_session))
|
108
108
|
end
|
109
109
|
|
110
110
|
private
|
@@ -45,7 +45,7 @@ class GdsApi::AssetManager < GdsApi::Base
|
|
45
45
|
# response = asset_manager.create_asset(file: params[:file])
|
46
46
|
# response['content_type'] #=> "image/jpeg"
|
47
47
|
def create_asset(asset)
|
48
|
-
post_multipart("#{base_url}/assets", asset:
|
48
|
+
post_multipart("#{base_url}/assets", asset:)
|
49
49
|
end
|
50
50
|
|
51
51
|
# Updates an asset given a hash with one +file+ attribute
|
@@ -76,7 +76,7 @@ class GdsApi::AssetManager < GdsApi::Base
|
|
76
76
|
# uuid = '594602dd-75b3-4e6f-b5d1-cacf8c4d4164'
|
77
77
|
# asset_manager.update_asset(uuid, file: File.new('image.jpg', 'r'))
|
78
78
|
def update_asset(id, asset)
|
79
|
-
put_multipart("#{base_url}/assets/#{id}", asset:
|
79
|
+
put_multipart("#{base_url}/assets/#{id}", asset:)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Fetches an asset's metadata given the id
|
@@ -69,10 +69,10 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
69
69
|
def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false)
|
70
70
|
post_json(
|
71
71
|
"#{endpoint}/subscriptions",
|
72
|
-
subscriber_list_id
|
73
|
-
address
|
74
|
-
frequency
|
75
|
-
skip_confirmation_email
|
72
|
+
subscriber_list_id:,
|
73
|
+
address:,
|
74
|
+
frequency:,
|
75
|
+
skip_confirmation_email:,
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
@@ -166,7 +166,7 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
166
166
|
def change_subscriber(id:, new_address:, on_conflict: nil)
|
167
167
|
patch_json(
|
168
168
|
"#{endpoint}/subscribers/#{uri_encode(id)}",
|
169
|
-
{ new_address
|
169
|
+
{ new_address:, on_conflict: }.compact,
|
170
170
|
)
|
171
171
|
end
|
172
172
|
|
@@ -179,7 +179,7 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
179
179
|
def change_subscription(id:, frequency:)
|
180
180
|
patch_json(
|
181
181
|
"#{endpoint}/subscriptions/#{uri_encode(id)}",
|
182
|
-
frequency
|
182
|
+
frequency:,
|
183
183
|
)
|
184
184
|
end
|
185
185
|
|
@@ -191,7 +191,7 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
191
191
|
def authenticate_subscriber_by_govuk_account(govuk_account_session:)
|
192
192
|
post_json(
|
193
193
|
"#{endpoint}/subscribers/govuk-account",
|
194
|
-
govuk_account_session
|
194
|
+
govuk_account_session:,
|
195
195
|
)
|
196
196
|
end
|
197
197
|
|
@@ -206,7 +206,7 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
206
206
|
def link_subscriber_to_govuk_account(govuk_account_session:)
|
207
207
|
post_json(
|
208
208
|
"#{endpoint}/subscribers/govuk-account/link",
|
209
|
-
govuk_account_session
|
209
|
+
govuk_account_session:,
|
210
210
|
)
|
211
211
|
end
|
212
212
|
|
@@ -231,8 +231,8 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
231
231
|
def send_subscriber_verification_email(address:, destination:)
|
232
232
|
post_json(
|
233
233
|
"#{endpoint}/subscribers/auth-token",
|
234
|
-
address
|
235
|
-
destination
|
234
|
+
address:,
|
235
|
+
destination:,
|
236
236
|
)
|
237
237
|
end
|
238
238
|
|
@@ -247,9 +247,9 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
247
247
|
def send_subscription_verification_email(address:, frequency:, topic_id:)
|
248
248
|
post_json(
|
249
249
|
"#{endpoint}/subscriptions/auth-token",
|
250
|
-
address
|
251
|
-
frequency
|
252
|
-
topic_id
|
250
|
+
address:,
|
251
|
+
frequency:,
|
252
|
+
topic_id:,
|
253
253
|
)
|
254
254
|
end
|
255
255
|
|
@@ -264,8 +264,8 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
264
264
|
post_json(
|
265
265
|
"#{endpoint}/subscriber-lists/#{slug}/bulk-unsubscribe",
|
266
266
|
{
|
267
|
-
body
|
268
|
-
sender_message_id
|
267
|
+
body:,
|
268
|
+
sender_message_id:,
|
269
269
|
}.compact,
|
270
270
|
{
|
271
271
|
"Govuk-Request-Id" => govuk_request_id,
|
@@ -281,8 +281,8 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
281
281
|
def bulk_migrate(from_slug:, to_slug:)
|
282
282
|
post_json(
|
283
283
|
"#{endpoint}/subscriber-lists/bulk-migrate",
|
284
|
-
from_slug
|
285
|
-
to_slug
|
284
|
+
from_slug:,
|
285
|
+
to_slug:,
|
286
286
|
)
|
287
287
|
end
|
288
288
|
|
data/lib/gds_api/imminence.rb
CHANGED
@@ -8,13 +8,13 @@ class GdsApi::Imminence < GdsApi::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def places(type, lat, lon, limit = 5)
|
11
|
-
url = api_url(type, lat
|
11
|
+
url = api_url(type, lat:, lng: lon, limit:)
|
12
12
|
get_json(url)
|
13
13
|
end
|
14
14
|
|
15
15
|
def places_for_postcode(type, postcode, limit = 5, local_authority_slug = nil)
|
16
|
-
options = { postcode
|
17
|
-
options.merge!(local_authority_slug:
|
16
|
+
options = { postcode:, limit: }
|
17
|
+
options.merge!(local_authority_slug:) if local_authority_slug
|
18
18
|
url = api_url(type, options)
|
19
19
|
get_json(url) || []
|
20
20
|
end
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -22,9 +22,9 @@ class GdsApi::LinkCheckerApi < GdsApi::Base
|
|
22
22
|
# @raise [HTTPErrorResponse] if the request returns an error
|
23
23
|
def check(uri, synchronous: nil, checked_within: nil)
|
24
24
|
params = {
|
25
|
-
uri
|
26
|
-
synchronous
|
27
|
-
checked_within
|
25
|
+
uri:,
|
26
|
+
synchronous:,
|
27
|
+
checked_within:,
|
28
28
|
}
|
29
29
|
|
30
30
|
response = get_json(
|
@@ -54,10 +54,10 @@ class GdsApi::LinkCheckerApi < GdsApi::Base
|
|
54
54
|
# @raise [HTTPErrorResponse] if the request returns an error
|
55
55
|
def create_batch(uris, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil)
|
56
56
|
payload = {
|
57
|
-
uris
|
58
|
-
checked_within
|
59
|
-
webhook_uri
|
60
|
-
webhook_secret_token
|
57
|
+
uris:,
|
58
|
+
checked_within:,
|
59
|
+
webhook_uri:,
|
60
|
+
webhook_secret_token:,
|
61
61
|
}
|
62
62
|
|
63
63
|
response = post_json(
|
@@ -22,7 +22,7 @@ module GdsApi
|
|
22
22
|
schema_name: options.fetch(:schema_name, "special_route"),
|
23
23
|
title: options.fetch(:title),
|
24
24
|
description: options.fetch(:description, ""),
|
25
|
-
locale
|
25
|
+
locale:,
|
26
26
|
details: {},
|
27
27
|
routes: [
|
28
28
|
{
|
@@ -33,11 +33,11 @@ module GdsApi
|
|
33
33
|
publishing_app: options.fetch(:publishing_app),
|
34
34
|
rendering_app: options.fetch(:rendering_app),
|
35
35
|
public_updated_at: time.now.iso8601,
|
36
|
-
update_type
|
36
|
+
update_type:,
|
37
37
|
)
|
38
38
|
|
39
39
|
publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links]
|
40
|
-
publishing_api.publish(options.fetch(:content_id), update_type, locale:
|
40
|
+
publishing_api.publish(options.fetch(:content_id), update_type, locale:)
|
41
41
|
put_content_response
|
42
42
|
end
|
43
43
|
|
@@ -48,7 +48,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
48
48
|
# @raise [NoLiveVersion] when the content item is not found
|
49
49
|
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#get-v2contentcontent_id
|
50
50
|
def get_live_content(content_id, locale = "en")
|
51
|
-
content_item = get_content(content_id, locale:
|
51
|
+
content_item = get_content(content_id, locale:)
|
52
52
|
|
53
53
|
live_states = %w[published unpublished]
|
54
54
|
return content_item if live_states.include?(content_item.to_h["publication_state"])
|
@@ -56,7 +56,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
56
56
|
live_version_number = content_item["state_history"].find { |_, v| live_states.include?(v) }&.first
|
57
57
|
raise NoLiveVersion, "No live version exists for content_id: #{content_id}" unless live_version_number
|
58
58
|
|
59
|
-
get_content(content_id, locale
|
59
|
+
get_content(content_id, locale:, version: live_version_number)
|
60
60
|
end
|
61
61
|
|
62
62
|
# Find the content_ids for a list of base_paths.
|
@@ -73,7 +73,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
73
73
|
#
|
74
74
|
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-lookup-by-base-path
|
75
75
|
def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
76
|
-
options = { base_paths:
|
76
|
+
options = { base_paths: }
|
77
77
|
options[:exclude_document_types] = exclude_document_types if exclude_document_types
|
78
78
|
options[:exclude_unpublishing_types] = exclude_unpublishing_types if exclude_unpublishing_types
|
79
79
|
options[:with_drafts] = with_drafts if with_drafts
|
@@ -102,9 +102,9 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
102
102
|
def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
|
103
103
|
lookups = lookup_content_ids(
|
104
104
|
base_paths: [base_path],
|
105
|
-
exclude_document_types
|
106
|
-
exclude_unpublishing_types
|
107
|
-
with_drafts
|
105
|
+
exclude_document_types:,
|
106
|
+
exclude_unpublishing_types:,
|
107
|
+
with_drafts:,
|
108
108
|
)
|
109
109
|
lookups[base_path]
|
110
110
|
end
|
@@ -122,7 +122,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
122
122
|
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idpublish
|
123
123
|
def publish(content_id, update_type = nil, options = {})
|
124
124
|
params = {
|
125
|
-
update_type
|
125
|
+
update_type:,
|
126
126
|
}
|
127
127
|
|
128
128
|
optional_keys = %i[locale previous_version]
|
@@ -168,7 +168,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
168
168
|
# @see https://github.com/alphagov/publishing-api/blob/main/docs/api.md#post-v2contentcontent_idunpublish
|
169
169
|
def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil, unpublished_at: nil, redirects: nil)
|
170
170
|
params = {
|
171
|
-
type
|
171
|
+
type:,
|
172
172
|
}
|
173
173
|
|
174
174
|
params[:explanation] = explanation if explanation
|
@@ -435,7 +435,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
435
435
|
# }
|
436
436
|
#
|
437
437
|
def get_links_for_content_ids(content_ids)
|
438
|
-
post_json("#{endpoint}/v2/links/by-content-id", content_ids:
|
438
|
+
post_json("#{endpoint}/v2/links/by-content-id", content_ids:).to_hash
|
439
439
|
end
|
440
440
|
|
441
441
|
# Reserves a path for a publishing application
|
@@ -452,7 +452,7 @@ class GdsApi::PublishingApi < GdsApi::Base
|
|
452
452
|
end
|
453
453
|
|
454
454
|
def unreserve_path(base_path, publishing_app)
|
455
|
-
payload = { publishing_app:
|
455
|
+
payload = { publishing_app: }
|
456
456
|
delete_json(unreserve_url(base_path), payload)
|
457
457
|
end
|
458
458
|
|
data/lib/gds_api/router.rb
CHANGED
@@ -28,7 +28,7 @@ class GdsApi::Router < GdsApi::Base
|
|
28
28
|
incoming_path: path,
|
29
29
|
route_type: type,
|
30
30
|
handler: "backend",
|
31
|
-
backend_id
|
31
|
+
backend_id:,
|
32
32
|
},
|
33
33
|
)
|
34
34
|
end
|
@@ -41,7 +41,7 @@ class GdsApi::Router < GdsApi::Base
|
|
41
41
|
route_type: type,
|
42
42
|
handler: "redirect",
|
43
43
|
redirect_to: destination,
|
44
|
-
redirect_type
|
44
|
+
redirect_type:,
|
45
45
|
segments_mode: options[:segments_mode],
|
46
46
|
},
|
47
47
|
)
|
@@ -20,11 +20,11 @@ module GdsApi
|
|
20
20
|
# GET /api/oauth2/sign-in
|
21
21
|
#########################
|
22
22
|
def stub_account_api_get_sign_in_url(redirect_path: nil, mfa: false, auth_uri: "http://auth/provider", state: "state")
|
23
|
-
querystring = Rack::Utils.build_nested_query({ redirect_path
|
23
|
+
querystring = Rack::Utils.build_nested_query({ redirect_path:, mfa: }.compact)
|
24
24
|
stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/sign-in?#{querystring}")
|
25
25
|
.to_return(
|
26
26
|
status: 200,
|
27
|
-
body: { auth_uri
|
27
|
+
body: { auth_uri:, state: }.to_json,
|
28
28
|
)
|
29
29
|
end
|
30
30
|
|
@@ -33,16 +33,16 @@ module GdsApi
|
|
33
33
|
###########################
|
34
34
|
def stub_account_api_validates_auth_response(code: nil, state: nil, govuk_account_session: "govuk-account-session", redirect_path: "/", ga_client_id: "ga-client-id", cookie_consent: false, feedback_consent: false)
|
35
35
|
stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/callback")
|
36
|
-
.with(body: hash_including({ code
|
36
|
+
.with(body: hash_including({ code:, state: }.compact))
|
37
37
|
.to_return(
|
38
38
|
status: 200,
|
39
|
-
body: { govuk_account_session
|
39
|
+
body: { govuk_account_session:, redirect_path:, ga_client_id:, cookie_consent:, feedback_consent: }.to_json,
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
43
43
|
def stub_account_api_rejects_auth_response(code: nil, state: nil)
|
44
44
|
stub_request(:post, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/callback")
|
45
|
-
.with(body: hash_including({ code
|
45
|
+
.with(body: hash_including({ code:, state: }.compact))
|
46
46
|
.to_return(status: 401)
|
47
47
|
end
|
48
48
|
|
@@ -55,13 +55,13 @@ module GdsApi
|
|
55
55
|
.with(headers: { GdsApi::AccountApi::AUTH_HEADER_NAME => govuk_account_session })
|
56
56
|
.to_return(
|
57
57
|
status: 200,
|
58
|
-
body: { end_session_uri:
|
58
|
+
body: { end_session_uri: }.to_json,
|
59
59
|
)
|
60
60
|
else
|
61
61
|
stub_request(:get, "#{ACCOUNT_API_ENDPOINT}/api/oauth2/end-session")
|
62
62
|
.to_return(
|
63
63
|
status: 200,
|
64
|
-
body: { end_session_uri:
|
64
|
+
body: { end_session_uri: }.to_json,
|
65
65
|
)
|
66
66
|
end
|
67
67
|
end
|
@@ -74,11 +74,11 @@ module GdsApi
|
|
74
74
|
:get,
|
75
75
|
"/api/user",
|
76
76
|
response_body: {
|
77
|
-
id
|
78
|
-
mfa
|
79
|
-
email
|
80
|
-
email_verified
|
81
|
-
services
|
77
|
+
id:,
|
78
|
+
mfa:,
|
79
|
+
email:,
|
80
|
+
email_verified:,
|
81
|
+
services:,
|
82
82
|
},
|
83
83
|
**options,
|
84
84
|
)
|
@@ -108,7 +108,7 @@ module GdsApi
|
|
108
108
|
def stub_account_api_match_user_by_email_matches(email:, **options)
|
109
109
|
stub_account_api_request(
|
110
110
|
:get,
|
111
|
-
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email:
|
111
|
+
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}",
|
112
112
|
response_body: {
|
113
113
|
match: true,
|
114
114
|
},
|
@@ -119,7 +119,7 @@ module GdsApi
|
|
119
119
|
def stub_account_api_match_user_by_email_does_not_match(email:, **options)
|
120
120
|
stub_account_api_request(
|
121
121
|
:get,
|
122
|
-
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email:
|
122
|
+
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}",
|
123
123
|
response_body: {
|
124
124
|
match: false,
|
125
125
|
},
|
@@ -130,7 +130,7 @@ module GdsApi
|
|
130
130
|
def stub_account_api_match_user_by_email_does_not_exist(email:, **options)
|
131
131
|
stub_account_api_request(
|
132
132
|
:get,
|
133
|
-
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email:
|
133
|
+
"/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: })}",
|
134
134
|
response_status: 404,
|
135
135
|
**options,
|
136
136
|
)
|
@@ -163,7 +163,7 @@ module GdsApi
|
|
163
163
|
stub_account_api_request(
|
164
164
|
:patch,
|
165
165
|
"/api/oidc-users/#{subject_identifier}",
|
166
|
-
with: { body: hash_including({ email
|
166
|
+
with: { body: hash_including({ email:, email_verified: }.compact) },
|
167
167
|
response_body: {
|
168
168
|
sub: subject_identifier,
|
169
169
|
email: email || old_email,
|
@@ -176,17 +176,17 @@ module GdsApi
|
|
176
176
|
# GET /api/attributes
|
177
177
|
#####################
|
178
178
|
def stub_account_api_has_attributes(attributes: [], values: {}, **options)
|
179
|
-
querystring = Rack::Utils.build_nested_query({ attributes:
|
179
|
+
querystring = Rack::Utils.build_nested_query({ attributes: }.compact)
|
180
180
|
stub_account_api_request(
|
181
181
|
:get,
|
182
182
|
"/api/attributes?#{querystring}",
|
183
|
-
response_body: { values:
|
183
|
+
response_body: { values: },
|
184
184
|
**options,
|
185
185
|
)
|
186
186
|
end
|
187
187
|
|
188
188
|
def stub_account_api_unauthorized_has_attributes(attributes: [], **options)
|
189
|
-
querystring = Rack::Utils.build_nested_query({ attributes:
|
189
|
+
querystring = Rack::Utils.build_nested_query({ attributes: }.compact)
|
190
190
|
stub_account_api_request(
|
191
191
|
:get,
|
192
192
|
"/api/attributes?#{querystring}",
|
@@ -196,7 +196,7 @@ module GdsApi
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def stub_account_api_forbidden_has_attributes(attributes: [], **options)
|
199
|
-
querystring = Rack::Utils.build_nested_query({ attributes:
|
199
|
+
querystring = Rack::Utils.build_nested_query({ attributes: }.compact)
|
200
200
|
stub_account_api_request(
|
201
201
|
:get,
|
202
202
|
"/api/attributes?#{querystring}",
|
@@ -212,7 +212,7 @@ module GdsApi
|
|
212
212
|
stub_account_api_request(
|
213
213
|
:patch,
|
214
214
|
"/api/attributes",
|
215
|
-
with: { body: hash_including({ attributes:
|
215
|
+
with: { body: hash_including({ attributes: }.compact) },
|
216
216
|
**options,
|
217
217
|
)
|
218
218
|
end
|
@@ -221,7 +221,7 @@ module GdsApi
|
|
221
221
|
stub_account_api_request(
|
222
222
|
:patch,
|
223
223
|
"/api/attributes",
|
224
|
-
with: { body: hash_including({ attributes:
|
224
|
+
with: { body: hash_including({ attributes: }.compact) },
|
225
225
|
response_status: 401,
|
226
226
|
**options,
|
227
227
|
)
|
@@ -231,7 +231,7 @@ module GdsApi
|
|
231
231
|
stub_account_api_request(
|
232
232
|
:patch,
|
233
233
|
"/api/attributes",
|
234
|
-
with: { body: hash_including({ attributes:
|
234
|
+
with: { body: hash_including({ attributes: }.compact) },
|
235
235
|
response_status: 403,
|
236
236
|
**options,
|
237
237
|
)
|
@@ -8,7 +8,7 @@ module GdsApi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def stub_calendars_has_no_bank_holidays(in_division: nil)
|
11
|
-
stub_calendars_has_bank_holidays_on([], in_division:
|
11
|
+
stub_calendars_has_bank_holidays_on([], in_division:)
|
12
12
|
end
|
13
13
|
|
14
14
|
def stub_calendars_has_bank_holidays_on(dates, in_division: nil)
|
@@ -26,30 +26,30 @@ module GdsApi
|
|
26
26
|
{
|
27
27
|
"england-and-wales" => {
|
28
28
|
division: "england-and-wales",
|
29
|
-
events
|
29
|
+
events:,
|
30
30
|
},
|
31
31
|
"scotland" => {
|
32
32
|
division: "scotland",
|
33
|
-
events
|
33
|
+
events:,
|
34
34
|
},
|
35
35
|
"northern-ireland" => {
|
36
36
|
division: "northern-ireland",
|
37
|
-
events
|
37
|
+
events:,
|
38
38
|
},
|
39
39
|
}
|
40
40
|
else
|
41
41
|
{
|
42
42
|
division: in_division,
|
43
|
-
events
|
43
|
+
events:,
|
44
44
|
}
|
45
45
|
end
|
46
46
|
|
47
|
-
stub_request(:get, calendars_endpoint(in_division:
|
47
|
+
stub_request(:get, calendars_endpoint(in_division:))
|
48
48
|
.to_return(body: response.to_json, status: 200)
|
49
49
|
end
|
50
50
|
|
51
51
|
def stub_calendars_has_a_bank_holiday_on(date, in_division: nil)
|
52
|
-
stub_calendars_has_bank_holidays_on([date], in_division:
|
52
|
+
stub_calendars_has_bank_holidays_on([date], in_division:)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -26,7 +26,7 @@ module GdsApi
|
|
26
26
|
endpoint = content_store_endpoint(draft: options[:draft])
|
27
27
|
stub_request(:get, "#{endpoint}/content#{base_path}").to_return(
|
28
28
|
status: 200,
|
29
|
-
body
|
29
|
+
body:,
|
30
30
|
headers: {
|
31
31
|
cache_control: "#{visibility}, max-age=#{max_age}",
|
32
32
|
date: Time.now.httpdate,
|
@@ -69,7 +69,7 @@ module GdsApi
|
|
69
69
|
endpoint = content_store_endpoint(draft: options[:draft])
|
70
70
|
stub_request(:get, "#{endpoint}/content#{base_path}").to_return(
|
71
71
|
status: 410,
|
72
|
-
body
|
72
|
+
body:,
|
73
73
|
headers: {},
|
74
74
|
)
|
75
75
|
end
|
@@ -86,7 +86,7 @@ module GdsApi
|
|
86
86
|
url = "#{content_store_endpoint}/incoming-links#{base_path}"
|
87
87
|
body = links.to_json
|
88
88
|
|
89
|
-
stub_request(:get, url).to_return(body:
|
89
|
+
stub_request(:get, url).to_return(body:)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|