Skip to content

Commit 3130877

Browse files
authored
Support email param in update_user (#365)
1 parent 948361c commit 3130877

File tree

7 files changed

+103
-7
lines changed

7 files changed

+103
-7
lines changed

.rubocop.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ Layout/LineLength:
1212
- '(\A|\s)/.*?/'
1313
Metrics/BlockLength:
1414
AllowedMethods: ['describe', 'context', 'before', 'it']
15+
Metrics/ClassLength:
16+
Enabled: false
17+
Metrics/CyclomaticComplexity:
18+
Enabled: false
1519
Metrics/MethodLength:
16-
Max: 30
20+
Enabled: false
1721
Metrics/ModuleLength:
18-
Max: 200
22+
Enabled: false
1923
Metrics/ParameterLists:
2024
Max: 6
2125
Naming/ConstantName:

lib/workos/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def user_agent
8686
].join('; ')
8787
end
8888

89-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity:
89+
# rubocop:disable Metrics/AbcSize:
9090
def handle_error_response(response:)
9191
http_status = response.code.to_i
9292
json = JSON.parse(response.body)

lib/workos/mfa.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def get_factor(
3232
WorkOS::Factor.new(response.body)
3333
end
3434

35-
# rubocop:disable Metrics/CyclomaticComplexity
3635
# rubocop:disable Metrics/PerceivedComplexity
3736
def validate_args(
3837
type:,

lib/workos/session.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def authenticate
6464
# @return [Hash] A hash containing a new sealed session, the authentication response,
6565
# and a reason if the refresh failed
6666
# rubocop:disable Metrics/AbcSize
67-
# rubocop:disable Metrics/CyclomaticComplexity
6867
# rubocop:disable Metrics/PerceivedComplexity
6968
def refresh(options = nil)
7069
cookie_password = options.nil? || options[:cookie_password].nil? ? @cookie_password : options[:cookie_password]

lib/workos/user_management.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
module WorkOS
77
# The UserManagement module provides convenience methods for working with the
88
# WorkOS User platform. You'll need a valid API key.
9-
10-
# rubocop:disable Metrics/ModuleLength
119
module UserManagement
1210
module Types
1311
# The ProviderEnum is a declaration of a
@@ -217,6 +215,7 @@ def create_user(
217215
# Update a user
218216
#
219217
# @param [String] id of the user.
218+
# @param [String] email of the user.
220219
# @param [String] first_name The user's first name.
221220
# @param [String] last_name The user's last name.
222221
# @param [Boolean] email_verified Whether the user's email address was previously verified.
@@ -228,6 +227,7 @@ def create_user(
228227
# @return [WorkOS::User]
229228
def update_user(
230229
id:,
230+
email: nil,
231231
first_name: nil,
232232
last_name: nil,
233233
email_verified: nil,
@@ -238,6 +238,7 @@ def update_user(
238238
request = put_request(
239239
path: "/user_management/users/#{id}",
240240
body: {
241+
email: email,
241242
first_name: first_name,
242243
last_name: last_name,
243244
email_verified: email_verified,

spec/lib/workos/user_management_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,17 @@
343343
end
344344
end
345345

346+
it 'can update email addresses' do
347+
VCR.use_cassette 'user_management/update_user/email' do
348+
user = described_class.update_user(
349+
id: 'user_01H7TVSKS45SDHN5V9XPSM6H44',
350+
351+
)
352+
expect(user.email).to eq('[email protected]')
353+
expect(user.email_verified).to eq(false)
354+
end
355+
end
356+
346357
context 'with an invalid payload' do
347358
it 'returns an error' do
348359
VCR.use_cassette 'user_management/update_user/invalid' do

spec/support/fixtures/vcr_cassettes/user_management/update_user/email.yml

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)