Skip to content

Commit 5601943

Browse files
committed
Allow passing of nil for external_id
External IDs can actually be set to null. On create this isn't an issue, not sending it will result in it being null. But on update if a user passes nil we want to be sure a null value goes to the API. Since organizations and user update methods are different I opted for a slightly difference solution in each place.
1 parent 8003c5b commit 5601943

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/workos/organizations.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,13 @@ def update_organization(
139139
domain_data: nil,
140140
domains: nil,
141141
name: nil,
142-
external_id: nil,
142+
external_id: :not_set,
143143
allow_profiles_outside_organization: nil
144144
)
145-
body = {
146-
name: name,
147-
external_id: external_id,
148-
}
145+
body = { name: name }
149146
body[:domain_data] = domain_data if domain_data
150147
body[:stripe_customer_id] = stripe_customer_id if stripe_customer_id
148+
body[:external_id] = external_id if external_id != :not_set
151149

152150
if domains
153151
warn_deprecation '`domains` is deprecated. Use `domain_data` instead.'

lib/workos/user_management.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ def create_user(
234234
# @return [WorkOS::User]
235235
def update_user(
236236
id:,
237-
email: nil,
238-
first_name: nil,
239-
last_name: nil,
240-
email_verified: nil,
241-
external_id: nil,
242-
password: nil,
243-
password_hash: nil,
244-
password_hash_type: nil
237+
email: :not_set,
238+
first_name: :not_set,
239+
last_name: :not_set,
240+
email_verified: :not_set,
241+
external_id: :not_set,
242+
password: :not_set,
243+
password_hash: :not_set,
244+
password_hash_type: :not_set
245245
)
246246
request = put_request(
247247
path: "/user_management/users/#{id}",
@@ -254,7 +254,7 @@ def update_user(
254254
password: password,
255255
password_hash: password_hash,
256256
password_hash_type: password_hash_type,
257-
}.compact,
257+
}.reject { |_, v| v == :not_set },
258258
auth: true,
259259
)
260260

0 commit comments

Comments
 (0)