gds-api-adapters 75.2.0 → 75.3.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: ed853f2f02ea63fdb7b79c7ef4460076b88cc32d1b3c4f6841ba5ced95d9e22e
4
- data.tar.gz: 72bc43ca960d3efece046f7faac4c3369fcaf27a4e9611ef6ca4ebcac4081a9b
3
+ metadata.gz: 207e19a65d19c45b030d88ccc1028e781def6a120dfedcc725615628b7d2f35d
4
+ data.tar.gz: a838e9f19dc4e7f8b45017aacd0fae259f1cb353ee44356c8c34066054fb1ea1
5
5
  SHA512:
6
- metadata.gz: 9ceb5f3b05c87b631691e4221ebdd7fdeeb349fa2b4a213c8407e3af113bbcaac47e6e0e41b8f31ee4370bc59c726d212d397a3a808d9fe0c692f750ea00c215
7
- data.tar.gz: d53218eba5ead7910b50e20d8dcb33787c3056e1cdd77bc92c33cb1a60eeeb15c4101e0bf4e9828fdfa32703f99d9bef5c36a67891ed0f6bc0ef175d150cc7ad
6
+ metadata.gz: d95b69e442c280cf3fbe5fa84dbfc1d16e9462a1c160f0678d7cd78b8a1f0426b4a5878eac6e78a5755f5eff27b293f1832b5d4a35a0958c5aed50d86bee1736
7
+ data.tar.gz: c167d604668e3685b63c6d83e7a09d6332bd40b2099fa7f4d9afd29d482aa240eef8398b67a0e8aeced29fde34847fe0a3f28d980d7da571cb63efb5b3b251c8
@@ -52,6 +52,17 @@ class GdsApi::AccountApi < GdsApi::Base
52
52
  get_json("#{endpoint}/api/user", auth_headers(govuk_account_session))
53
53
  end
54
54
 
55
+ # Find a user by email address, returning whether they match the given session (if any)
56
+ #
57
+ # @param [String] email The email address to search for
58
+ # @param [String, nil] govuk_account_session Value of the session header, if not given just checks if the given email address exists.
59
+ #
60
+ # @return [Hash] One field, "match", indicating whether the session matches the given email address
61
+ def match_user_by_email(email:, govuk_account_session: nil)
62
+ querystring = nested_query_string({ email: email })
63
+ get_json("#{endpoint}/api/user/match-by-email?#{querystring}", auth_headers(govuk_account_session))
64
+ end
65
+
55
66
  # Delete a users account
56
67
  #
57
68
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
@@ -62,7 +73,7 @@ class GdsApi::AccountApi < GdsApi::Base
62
73
  # Update the user record with privileged information from the auth service. Only the auth service will call this.
63
74
  #
64
75
  # @param [String] subject_identifier The identifier of the user, shared between the auth service and GOV.UK.
65
- # @param [String, nil] email The user's current
76
+ # @param [String, nil] email The user's current email address
66
77
  # @param [Boolean, nil] email_verified Whether the user's current email address is verified
67
78
  # @param [Boolean, nil] has_unconfirmed_email Whether the user has a new, pending, email address
68
79
  # @param [Boolean, nil] cookie_consent Whether the user has consented to analytics cookies
@@ -138,6 +149,6 @@ private
138
149
  end
139
150
 
140
151
  def auth_headers(govuk_account_session)
141
- { AUTH_HEADER_NAME => govuk_account_session }
152
+ { AUTH_HEADER_NAME => govuk_account_session }.compact
142
153
  end
143
154
  end
@@ -10,8 +10,9 @@ class GdsApi::EmailAlertApi < GdsApi::Base
10
10
  #
11
11
  # @param attributes [Hash] document_type, links, tags used to search existing subscriber lists
12
12
  def find_or_create_subscriber_list(attributes)
13
- if attributes["tags"] && attributes["links"]
14
- message = "please provide either tags or links (or neither), but not both"
13
+ present_fields = [attributes["content_id"], attributes["links"], attributes["tags"]].compact.count
14
+ if present_fields > 1
15
+ message = "please provide content_id, tags, or links (or none), but not more than one of them"
15
16
  raise ArgumentError, message
16
17
  end
17
18
 
@@ -102,6 +102,41 @@ module GdsApi
102
102
  )
103
103
  end
104
104
 
105
+ ##############################
106
+ # GET /api/user/match-by-email
107
+ ##############################
108
+
109
+ def stub_account_api_match_user_by_email_matches(email:, **options)
110
+ stub_account_api_request(
111
+ :get,
112
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
113
+ response_body: {
114
+ match: true,
115
+ },
116
+ **options,
117
+ )
118
+ end
119
+
120
+ def stub_account_api_match_user_by_email_does_not_match(email:, **options)
121
+ stub_account_api_request(
122
+ :get,
123
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
124
+ response_body: {
125
+ match: false,
126
+ },
127
+ **options,
128
+ )
129
+ end
130
+
131
+ def stub_account_api_match_user_by_email_does_not_exist(email:, **options)
132
+ stub_account_api_request(
133
+ :get,
134
+ "/api/user/match-by-email?#{Rack::Utils.build_nested_query({ email: email })}",
135
+ response_status: 404,
136
+ **options,
137
+ )
138
+ end
139
+
105
140
  ############################################
106
141
  # DELETE /api/oidc-users/:subject_identifier
107
142
  ############################################
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "75.2.0".freeze
2
+ VERSION = "75.3.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: 75.2.0
4
+ version: 75.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-10-15 00:00:00.000000000 Z
11
+ date: 2021-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable