gds-api-adapters 75.2.0 → 75.3.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 +13 -2
- data/lib/gds_api/email_alert_api.rb +3 -2
- data/lib/gds_api/test_helpers/account_api.rb +35 -0
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 207e19a65d19c45b030d88ccc1028e781def6a120dfedcc725615628b7d2f35d
|
4
|
+
data.tar.gz: a838e9f19dc4e7f8b45017aacd0fae259f1cb353ee44356c8c34066054fb1ea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d95b69e442c280cf3fbe5fa84dbfc1d16e9462a1c160f0678d7cd78b8a1f0426b4a5878eac6e78a5755f5eff27b293f1832b5d4a35a0958c5aed50d86bee1736
|
7
|
+
data.tar.gz: c167d604668e3685b63c6d83e7a09d6332bd40b2099fa7f4d9afd29d482aa240eef8398b67a0e8aeced29fde34847fe0a3f28d980d7da571cb63efb5b3b251c8
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
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
|
############################################
|
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: 75.
|
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-
|
11
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|