gds-api-adapters 71.3.0 → 71.4.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: ea739e39026f239c010c4810ba88c6c0f8f77a0fb2375e24c9026cd2a388465e
4
- data.tar.gz: c18db19adc96aab183ab99edfc30db4691d7ab5d055def3fbcfc406f6b16c1a8
3
+ metadata.gz: d1bcd6f2192952444f80e49762cc4d1e2820c767162d194de9ce6c0f1b78ad2c
4
+ data.tar.gz: cc96d6dc6f18b3ec2a58187977147b8be0bf6025e7a47c4b55671f2ab900c78f
5
5
  SHA512:
6
- metadata.gz: 1b03304634769b69d8549664720619081836366bacb76948e19275751b0f4d2482f0adf14977b82569e4e265b081e590c338f9a2167e78170bab9af0f8c27a68
7
- data.tar.gz: b5dfc1690a1e783e67bf350d2d5fb8d66c9aa0eaaa758bdbb7be381cd34a76780de465c9bfc78b539c9712ba3e6b586788f7139edab07aa8fab7ea2d6ae974f9
6
+ metadata.gz: 2b0911632959b5c61c22ca3c5f208bd69d8cd6db5984fe83c4912251d38f1e895f8a90eda372de721a9f85a59af4931517eb468c3a23d554d9d3a9e4ecd24734
7
+ data.tar.gz: 1ed0f2a61ed3833a05283684a443ae148324ae22e92daa49e14982af4e908ea5e4f96cda2f74ad20bedae96fdad3d4641fee09c01b958fd63e53190e319b7357
@@ -54,6 +54,17 @@ class GdsApi::AccountApi < GdsApi::Base
54
54
  get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
55
55
  end
56
56
 
57
+ # Update the user record with privileged information from the auth service. Only the auth service will call this.
58
+ #
59
+ # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
60
+ # @param [String, nil] email The new email address
61
+ # @param [Boolean, nil] email_verified Whether the new email address is verified
62
+ #
63
+ # @return [Hash] The user's subject identifier and email attributes
64
+ def update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil)
65
+ patch_json("#{endpoint}/api/oidc-users/#{subject_identifier}", { email: email, email_verified: email_verified }.compact)
66
+ end
67
+
57
68
  # Check if a user has an email subscription for the Transition Checker
58
69
  #
59
70
  # @param [String] govuk_account_session Value of the session header
@@ -111,7 +122,7 @@ class GdsApi::AccountApi < GdsApi::Base
111
122
  #
112
123
  # @return [Hash] containing :saved_pages, an array of single saved page hashes def get_saved_pages(govuk_account_session:)
113
124
  def get_saved_pages(govuk_account_session:)
114
- get_json("#{endpoint}/api/saved_pages", auth_headers(govuk_account_session))
125
+ get_json("#{endpoint}/api/saved-pages", auth_headers(govuk_account_session))
115
126
  end
116
127
 
117
128
  # Return a single page by unique URL
@@ -121,7 +132,7 @@ class GdsApi::AccountApi < GdsApi::Base
121
132
  #
122
133
  # @return [Hash] containing :saved_page, a hash of a single saved page value
123
134
  def get_saved_page(page_path:, govuk_account_session:)
124
- get_json("#{endpoint}/api/saved_pages/#{CGI.escape(page_path)}", auth_headers(govuk_account_session))
135
+ get_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", auth_headers(govuk_account_session))
125
136
  end
126
137
 
127
138
  # Upsert a single saved page entry in a users account
@@ -131,7 +142,7 @@ class GdsApi::AccountApi < GdsApi::Base
131
142
  #
132
143
  # @return [Hash] A single saved page value (if sucessful)
133
144
  def save_page(page_path:, govuk_account_session:)
134
- put_json("#{endpoint}/api/saved_pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
145
+ put_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
135
146
  end
136
147
 
137
148
  # Delete a single saved page entry from a users account
@@ -142,7 +153,7 @@ class GdsApi::AccountApi < GdsApi::Base
142
153
  # @return [GdsApi::Response] A status code of 204 indicates the saved page has been successfully deleted.
143
154
  # A status code of 404 indicates there is no saved page with this path.
144
155
  def delete_saved_page(page_path:, govuk_account_session:)
145
- delete_json("#{endpoint}/api/saved_pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
156
+ delete_json("#{endpoint}/api/saved-pages/#{CGI.escape(page_path)}", {}, auth_headers(govuk_account_session))
146
157
  end
147
158
 
148
159
  private
@@ -69,6 +69,19 @@ module GdsApi
69
69
  )
70
70
  end
71
71
 
72
+ def stub_update_user_by_subject_identifier(subject_identifier:, email: nil, email_verified: nil, old_email: nil, old_email_verified: nil)
73
+ stub_account_api_request(
74
+ :patch,
75
+ "/api/oidc-users/#{subject_identifier}",
76
+ with: { body: hash_including({ email: email, email_verified: email_verified }.compact) },
77
+ response_body: {
78
+ sub: subject_identifier,
79
+ email: email || old_email,
80
+ email_verified: email_verified || old_email_verified,
81
+ },
82
+ )
83
+ end
84
+
72
85
  def stub_account_api_has_email_subscription(**options)
73
86
  stub_account_api_request(
74
87
  :get,
@@ -240,12 +253,12 @@ module GdsApi
240
253
  end
241
254
 
242
255
  ######################
243
- # GET /api/saved_pages
256
+ # GET /api/saved-pages
244
257
  ######################
245
258
  def stub_account_api_returning_saved_pages(saved_pages: [], **options)
246
259
  stub_account_api_request(
247
260
  :get,
248
- "/api/saved_pages",
261
+ "/api/saved-pages",
249
262
  response_body: { saved_pages: saved_pages },
250
263
  **options,
251
264
  )
@@ -254,7 +267,7 @@ module GdsApi
254
267
  def stub_account_api_unauthorized_get_saved_pages(**options)
255
268
  stub_account_api_request(
256
269
  :get,
257
- "/api/saved_pages",
270
+ "/api/saved-pages",
258
271
  response_status: 401,
259
272
  **options,
260
273
  )
@@ -266,7 +279,7 @@ module GdsApi
266
279
  def stub_account_api_get_saved_page(page_path:, content_id: "46163ed2-1777-4ee6-bdd4-6a2007e49d8f", title: "Ministry of Magic", **options)
267
280
  stub_account_api_request(
268
281
  :get,
269
- "/api/saved_pages/#{CGI.escape(page_path)}",
282
+ "/api/saved-pages/#{CGI.escape(page_path)}",
270
283
  response_body: {
271
284
  saved_page: {
272
285
  page_path: page_path,
@@ -281,7 +294,7 @@ module GdsApi
281
294
  def stub_account_api_does_not_have_saved_page(page_path:, **options)
282
295
  stub_account_api_request(
283
296
  :get,
284
- "/api/saved_pages/#{CGI.escape(page_path)}",
297
+ "/api/saved-pages/#{CGI.escape(page_path)}",
285
298
  response_status: 404,
286
299
  **options,
287
300
  )
@@ -290,19 +303,19 @@ module GdsApi
290
303
  def stub_account_api_unauthorized_get_saved_page(page_path:, **options)
291
304
  stub_account_api_request(
292
305
  :get,
293
- "/api/saved_pages/#{CGI.escape(page_path)}",
306
+ "/api/saved-pages/#{CGI.escape(page_path)}",
294
307
  response_status: 401,
295
308
  **options,
296
309
  )
297
310
  end
298
311
 
299
312
  #################################
300
- # PUT /api/saved_pages/:page_path
313
+ # PUT /api/saved-pages/:page_path
301
314
  #################################
302
315
  def stub_account_api_save_page(page_path:, content_id: "c840bfa2-011a-42cc-ac7a-a6da990aff0b", title: "Ministry of Magic", **options)
303
316
  stub_account_api_request(
304
317
  :put,
305
- "/api/saved_pages/#{CGI.escape(page_path)}",
318
+ "/api/saved-pages/#{CGI.escape(page_path)}",
306
319
  response_body: {
307
320
  saved_page: {
308
321
  page_path: page_path,
@@ -321,7 +334,7 @@ module GdsApi
321
334
  def stub_account_api_save_page_cannot_save_page(page_path:, **options)
322
335
  stub_account_api_request(
323
336
  :put,
324
- "/api/saved_pages/#{CGI.escape(page_path)}",
337
+ "/api/saved-pages/#{CGI.escape(page_path)}",
325
338
  response_status: 422,
326
339
  response_body: cannot_save_page_problem_detail({ page_path: page_path }),
327
340
  **options,
@@ -331,7 +344,7 @@ module GdsApi
331
344
  def stub_account_api_unauthorized_save_page(page_path:, **options)
332
345
  stub_account_api_request(
333
346
  :put,
334
- "/api/saved_pages/#{CGI.escape(page_path)}",
347
+ "/api/saved-pages/#{CGI.escape(page_path)}",
335
348
  response_status: 401,
336
349
  **options,
337
350
  )
@@ -352,7 +365,7 @@ module GdsApi
352
365
  def stub_account_api_delete_saved_page(page_path:, **options)
353
366
  stub_account_api_request(
354
367
  :delete,
355
- "/api/saved_pages/#{CGI.escape(page_path)}",
368
+ "/api/saved-pages/#{CGI.escape(page_path)}",
356
369
  response_status: 204,
357
370
  **options,
358
371
  )
@@ -361,7 +374,7 @@ module GdsApi
361
374
  def stub_account_api_delete_saved_page_does_not_exist(page_path:, **options)
362
375
  stub_account_api_request(
363
376
  :delete,
364
- "/api/saved_pages/#{CGI.escape(page_path)}",
377
+ "/api/saved-pages/#{CGI.escape(page_path)}",
365
378
  response_status: 404,
366
379
  **options,
367
380
  )
@@ -370,7 +383,7 @@ module GdsApi
370
383
  def stub_account_api_delete_saved_page_unauthorised(page_path:, **options)
371
384
  stub_account_api_request(
372
385
  :delete,
373
- "/api/saved_pages/#{CGI.escape(page_path)}",
386
+ "/api/saved-pages/#{CGI.escape(page_path)}",
374
387
  response_status: 401,
375
388
  **options,
376
389
  )
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "71.3.0".freeze
2
+ VERSION = "71.4.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: 71.3.0
4
+ version: 71.4.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-06-07 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable