gds-api-adapters 71.2.0 → 71.3.0
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/account_api.rb +9 -0
- data/lib/gds_api/json_client.rb +4 -4
- data/lib/gds_api/test_helpers/account_api.rb +48 -5
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea739e39026f239c010c4810ba88c6c0f8f77a0fb2375e24c9026cd2a388465e
|
4
|
+
data.tar.gz: c18db19adc96aab183ab99edfc30db4691d7ab5d055def3fbcfc406f6b16c1a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b03304634769b69d8549664720619081836366bacb76948e19275751b0f4d2482f0adf14977b82569e4e265b081e590c338f9a2167e78170bab9af0f8c27a68
|
7
|
+
data.tar.gz: b5dfc1690a1e783e67bf350d2d5fb8d66c9aa0eaaa758bdbb7be381cd34a76780de465c9bfc78b539c9712ba3e6b586788f7139edab07aa8fab7ea2d6ae974f9
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -45,6 +45,15 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
45
45
|
post_json("#{endpoint}/api/oauth2/state", attributes: attributes)
|
46
46
|
end
|
47
47
|
|
48
|
+
# Get all the information about a user needed to render the account home page
|
49
|
+
#
|
50
|
+
# @param [String] govuk_account_session Value of the session header
|
51
|
+
#
|
52
|
+
# @return [Hash] Information about the user and the services they've used, and a new session header
|
53
|
+
def get_user(govuk_account_session:)
|
54
|
+
get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
|
55
|
+
end
|
56
|
+
|
48
57
|
# Check if a user has an email subscription for the Transition Checker
|
49
58
|
#
|
50
59
|
# @param [String] govuk_account_session Value of the session header
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -180,10 +180,10 @@ module GdsApi
|
|
180
180
|
raise GdsApi::EndpointNotFound, "Could not connect to #{url}"
|
181
181
|
rescue RestClient::Exceptions::Timeout => e
|
182
182
|
logger.error loggable.merge(status: "timeout", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
183
|
-
raise GdsApi::TimedOutException
|
183
|
+
raise GdsApi::TimedOutException, e.message
|
184
184
|
rescue URI::InvalidURIError => e
|
185
185
|
logger.error loggable.merge(status: "invalid_uri", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
186
|
-
raise GdsApi::InvalidUrl
|
186
|
+
raise GdsApi::InvalidUrl, e.message
|
187
187
|
rescue RestClient::Exception => e
|
188
188
|
# Log the error here, since we have access to loggable, but raise the
|
189
189
|
# exception up to the calling method to deal with
|
@@ -192,10 +192,10 @@ module GdsApi
|
|
192
192
|
raise
|
193
193
|
rescue Errno::ECONNRESET => e
|
194
194
|
logger.error loggable.merge(status: "connection_reset", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
195
|
-
raise GdsApi::TimedOutException
|
195
|
+
raise GdsApi::TimedOutException, e.message
|
196
196
|
rescue SocketError => e
|
197
197
|
logger.error loggable.merge(status: "socket_error", error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
198
|
-
raise GdsApi::SocketErrorException
|
198
|
+
raise GdsApi::SocketErrorException, e.message
|
199
199
|
end
|
200
200
|
end
|
201
201
|
end
|
@@ -38,6 +38,37 @@ module GdsApi
|
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
|
+
def stub_account_api_user_info(level_of_authentication: "level0", email: "email@example.com", email_verified: true, services: {}, **options)
|
42
|
+
stub_account_api_request(
|
43
|
+
:get,
|
44
|
+
"/api/user",
|
45
|
+
response_body: {
|
46
|
+
level_of_authentication: level_of_authentication,
|
47
|
+
email: email,
|
48
|
+
email_verified: email_verified,
|
49
|
+
services: services,
|
50
|
+
},
|
51
|
+
**options,
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
def stub_account_api_user_info_service_state(service:, service_state: "yes", **options)
|
56
|
+
stub_account_api_user_info(
|
57
|
+
**options.merge(
|
58
|
+
services: options.fetch(:services, {}).merge(service => service_state),
|
59
|
+
),
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def stub_account_api_unauthorized_user_info(**options)
|
64
|
+
stub_account_api_request(
|
65
|
+
:get,
|
66
|
+
"/api/user",
|
67
|
+
response_status: 401,
|
68
|
+
**options,
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
41
72
|
def stub_account_api_has_email_subscription(**options)
|
42
73
|
stub_account_api_request(
|
43
74
|
:get,
|
@@ -232,11 +263,17 @@ module GdsApi
|
|
232
263
|
#################################
|
233
264
|
# GET /api/saved_pages/:page_path
|
234
265
|
#################################
|
235
|
-
def stub_account_api_get_saved_page(page_path:, **options)
|
266
|
+
def stub_account_api_get_saved_page(page_path:, content_id: "46163ed2-1777-4ee6-bdd4-6a2007e49d8f", title: "Ministry of Magic", **options)
|
236
267
|
stub_account_api_request(
|
237
268
|
:get,
|
238
269
|
"/api/saved_pages/#{CGI.escape(page_path)}",
|
239
|
-
response_body: {
|
270
|
+
response_body: {
|
271
|
+
saved_page: {
|
272
|
+
page_path: page_path,
|
273
|
+
content_id: content_id,
|
274
|
+
title: title,
|
275
|
+
},
|
276
|
+
},
|
240
277
|
**options,
|
241
278
|
)
|
242
279
|
end
|
@@ -262,11 +299,17 @@ module GdsApi
|
|
262
299
|
#################################
|
263
300
|
# PUT /api/saved_pages/:page_path
|
264
301
|
#################################
|
265
|
-
def stub_account_api_save_page(page_path:, **options)
|
302
|
+
def stub_account_api_save_page(page_path:, content_id: "c840bfa2-011a-42cc-ac7a-a6da990aff0b", title: "Ministry of Magic", **options)
|
266
303
|
stub_account_api_request(
|
267
304
|
:put,
|
268
305
|
"/api/saved_pages/#{CGI.escape(page_path)}",
|
269
|
-
response_body: {
|
306
|
+
response_body: {
|
307
|
+
saved_page: {
|
308
|
+
page_path: page_path,
|
309
|
+
content_id: content_id,
|
310
|
+
title: title,
|
311
|
+
},
|
312
|
+
},
|
270
313
|
**options,
|
271
314
|
)
|
272
315
|
end
|
@@ -280,7 +323,7 @@ module GdsApi
|
|
280
323
|
:put,
|
281
324
|
"/api/saved_pages/#{CGI.escape(page_path)}",
|
282
325
|
response_status: 422,
|
283
|
-
response_body:
|
326
|
+
response_body: cannot_save_page_problem_detail({ page_path: page_path }),
|
284
327
|
**options,
|
285
328
|
)
|
286
329
|
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: 71.
|
4
|
+
version: 71.3.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: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -445,7 +445,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
445
445
|
- !ruby/object:Gem::Version
|
446
446
|
version: '0'
|
447
447
|
requirements: []
|
448
|
-
rubygems_version: 3.
|
448
|
+
rubygems_version: 3.0.3
|
449
449
|
signing_key:
|
450
450
|
specification_version: 4
|
451
451
|
summary: Adapters to work with GDS APIs
|