Skip to content

Commit 85d8249

Browse files
mxljenicknisi
andauthored
user: allow updating external_id, add to User object (#378)
* user: support `external_id` in `#update` * spec: add `external_id` to `update_user` * update cassette --------- Co-authored-by: Nick Nisi <[email protected]>
1 parent b9d4400 commit 85d8249

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

lib/workos/user.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class User
88
include HashProvider
99

1010
attr_accessor :id, :email, :first_name, :last_name, :email_verified,
11-
:profile_picture_url, :last_sign_in_at, :created_at, :updated_at
11+
:profile_picture_url, :external_id, :last_sign_in_at, :created_at, :updated_at
1212

1313
def initialize(json)
1414
hash = JSON.parse(json, symbolize_names: true)
@@ -19,6 +19,7 @@ def initialize(json)
1919
@last_name = hash[:last_name]
2020
@email_verified = hash[:email_verified]
2121
@profile_picture_url = hash[:profile_picture_url]
22+
@external_id = hash[:external_id]
2223
@last_sign_in_at = hash[:last_sign_in_at]
2324
@created_at = hash[:created_at]
2425
@updated_at = hash[:updated_at]
@@ -32,6 +33,7 @@ def to_json(*)
3233
last_name: last_name,
3334
email_verified: email_verified,
3435
profile_picture_url: profile_picture_url,
36+
external_id: external_id,
3537
last_sign_in_at: last_sign_in_at,
3638
created_at: created_at,
3739
updated_at: updated_at,

lib/workos/user_management.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def create_user(
222222
# @param [String] first_name The user's first name.
223223
# @param [String] last_name The user's last name.
224224
# @param [Boolean] email_verified Whether the user's email address was previously verified.
225+
# @param [String] external_id The users's external ID
225226
# @param [String] password The user's password.
226227
# @param [String] password_hash The user's hashed password.
227228
# @option [String] password_hash_type The algorithm originally used to hash the password.
@@ -234,6 +235,7 @@ def update_user(
234235
first_name: nil,
235236
last_name: nil,
236237
email_verified: nil,
238+
external_id: nil,
237239
password: nil,
238240
password_hash: nil,
239241
password_hash_type: nil
@@ -245,6 +247,7 @@ def update_user(
245247
first_name: first_name,
246248
last_name: last_name,
247249
email_verified: email_verified,
250+
external_id: external_id,
248251
password: password,
249252
password_hash: password_hash,
250253
password_hash_type: password_hash_type,

spec/lib/workos/user_management_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,12 @@
362362
first_name: 'Jane',
363363
last_name: 'Doe',
364364
email_verified: false,
365+
external_id: '123',
365366
)
366367
expect(user.first_name).to eq('Jane')
367368
expect(user.last_name).to eq('Doe')
368369
expect(user.email_verified).to eq(false)
370+
expect(user.external_id).to eq('123')
369371
end
370372
end
371373

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

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

0 commit comments

Comments
 (0)