Skip to content

Commit a66c15b

Browse files
gjtorikianclaude
andauthored
fix: replace parameter-group hashes with typed variant classes (#473)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 260974f commit a66c15b

17 files changed

Lines changed: 508 additions & 265 deletions

.oagen-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": 2,
33
"language": "ruby",
4-
"generatedAt": "2026-04-27T20:55:49.741Z",
4+
"generatedAt": "2026-04-30T17:41:02.756Z",
55
"files": [
66
"lib/workos.rb",
77
"lib/workos/admin_portal.rb",

lib/workos/api_keys.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def create_validation(
2020
)
2121
body = {
2222
"value" => value
23-
}.compact
23+
}
2424
response = @client.request(
2525
method: :post,
2626
path: "/api_keys/validations",

lib/workos/audit_logs.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def update_organization_audit_logs_retention(
4141
)
4242
body = {
4343
"retention_period_in_days" => retention_period_in_days
44-
}.compact
44+
}
4545
response = @client.request(
4646
method: :put,
4747
path: "/organizations/#{WorkOS::Util.encode_path(id)}/audit_logs_retention",
@@ -189,7 +189,7 @@ def create_event(
189189
body = {
190190
"organization_id" => organization_id,
191191
"event" => event
192-
}.compact
192+
}
193193
response = @client.request(
194194
method: :post,
195195
path: "/audit_logs/events",

lib/workos/authorization.rb

Lines changed: 128 additions & 116 deletions
Large diffs are not rendered by default.

lib/workos/groups.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def create_group_organization_membership(
219219
)
220220
body = {
221221
"organization_membership_id" => organization_membership_id
222-
}.compact
222+
}
223223
response = @client.request(
224224
method: :post,
225225
path: "/organizations/#{WorkOS::Util.encode_path(organization_id)}/groups/#{WorkOS::Util.encode_path(group_id)}/organization-memberships",

lib/workos/multi_factor_auth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def verify_challenge(
2222
)
2323
body = {
2424
"code" => code
25-
}.compact
25+
}
2626
response = @client.request(
2727
method: :post,
2828
path: "/auth/challenges/#{WorkOS::Util.encode_path(id)}/verify",

lib/workos/organization_domains.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def create_organization_domain(
2323
body = {
2424
"domain" => domain,
2525
"organization_id" => organization_id
26-
}.compact
26+
}
2727
response = @client.request(
2828
method: :post,
2929
path: "/organization_domains",

lib/workos/radar.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def add_list_entry(
9191
)
9292
body = {
9393
"entry" => entry
94-
}.compact
94+
}
9595
response = @client.request(
9696
method: :post,
9797
path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}",
@@ -118,7 +118,7 @@ def remove_list_entry(
118118
)
119119
body = {
120120
"entry" => entry
121-
}.compact
121+
}
122122
@client.request(
123123
method: :delete,
124124
path: "/radar/lists/#{WorkOS::Util.encode_path(type)}/#{WorkOS::Util.encode_path(action)}",

lib/workos/sso.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def authorize_logout(
116116
)
117117
body = {
118118
"profile_id" => profile_id
119-
}.compact
119+
}
120120
response = @client.request(
121121
method: :post,
122122
path: "/sso/logout/authorize",
@@ -157,7 +157,7 @@ def get_profile_and_token(
157157
"client_id" => request_options[:client_id] || @client.client_id,
158158
"client_secret" => request_options[:api_key] || @client.api_key,
159159
"code" => code
160-
}.compact
160+
}
161161
response = @client.request(
162162
method: :post,
163163
path: "/sso/token",

lib/workos/user_management.rb

Lines changed: 74 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,32 @@
66

77
module WorkOS
88
class UserManagement
9+
# Identifies the password (plaintext variant).
10+
#
11+
# @!attribute [r] password
12+
# @return [String]
13+
PasswordPlaintext = Data.define(:password)
14+
15+
# Identifies the password (hashed variant).
16+
#
17+
# @!attribute [r] password_hash
18+
# @return [String]
19+
# @!attribute [r] password_hash_type
20+
# @return [WorkOS::Types::CreateUserPasswordHashType]
21+
PasswordHashed = Data.define(:password_hash, :password_hash_type)
22+
23+
# Identifies the role (single variant).
24+
#
25+
# @!attribute [r] role_slug
26+
# @return [String]
27+
RoleSingle = Data.define(:role_slug)
28+
29+
# Identifies the role (multiple variant).
30+
#
31+
# @!attribute [r] role_slugs
32+
# @return [Array<String>]
33+
RoleMultiple = Data.define(:role_slugs)
34+
935
def initialize(client)
1036
@client = client
1137
end
@@ -403,7 +429,7 @@ def create_device(
403429
)
404430
body = {
405431
"client_id" => client_id
406-
}.compact
432+
}
407433
response = @client.request(
408434
method: :post,
409435
path: "/user_management/authorize/device",
@@ -450,7 +476,7 @@ def create_cors_origin(
450476
)
451477
body = {
452478
"origin" => origin
453-
}.compact
479+
}
454480
response = @client.request(
455481
method: :post,
456482
path: "/user_management/cors_origins",
@@ -492,7 +518,7 @@ def reset_password(
492518
)
493519
body = {
494520
"email" => email
495-
}.compact
521+
}
496522
response = @client.request(
497523
method: :post,
498524
path: "/user_management/password_reset",
@@ -518,7 +544,7 @@ def confirm_password_reset(
518544
body = {
519545
"token" => token,
520546
"new_password" => new_password
521-
}.compact
547+
}
522548
response = @client.request(
523549
method: :post,
524550
path: "/user_management/password_reset/confirm",
@@ -613,9 +639,7 @@ def list_users(
613639
# @param email_verified [Boolean, nil] Whether the user's email has been verified.
614640
# @param metadata [Hash{String => String}, nil] Object containing metadata key/value pairs associated with the user.
615641
# @param external_id [String, nil] The external ID of the user.
616-
# @param password [String, nil] The password to set for the user. Mutually exclusive with `password_hash` and `password_hash_type`.
617-
# @param password_hash [String, nil] The hashed password to set for the user. Required with `password_hash_type`. Mutually exclusive with `password`.
618-
# @param password_hash_type [WorkOS::Types::CreateUserPasswordHashType, nil] The algorithm originally used to hash the password, used when providing a `password_hash`. Required with `password_hash`. Mutually exclusive with `password`.
642+
# @param password [WorkOS::UserManagement::PasswordPlaintext, WorkOS::UserManagement::PasswordHashed, nil] Identifies the password.
619643
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
620644
# @return [WorkOS::User]
621645
def create_user(
@@ -626,8 +650,6 @@ def create_user(
626650
metadata: nil,
627651
external_id: nil,
628652
password: nil,
629-
password_hash: nil,
630-
password_hash_type: nil,
631653
request_options: {}
632654
)
633655
body = {
@@ -636,18 +658,17 @@ def create_user(
636658
"last_name" => last_name,
637659
"email_verified" => email_verified,
638660
"metadata" => metadata,
639-
"external_id" => external_id,
640-
"password" => password,
641-
"password_hash" => password_hash,
642-
"password_hash_type" => password_hash_type
661+
"external_id" => external_id
643662
}.compact
644663
if password
645-
case password[:type]
646-
when "plaintext"
647-
body["password"] = password[:password]
648-
when "hashed"
649-
body["password_hash"] = password[:password_hash]
650-
body["password_hash_type"] = password[:password_hash_type]
664+
case password
665+
when WorkOS::UserManagement::PasswordPlaintext
666+
body["password"] = password.password
667+
when WorkOS::UserManagement::PasswordHashed
668+
body["password_hash"] = password.password_hash
669+
body["password_hash_type"] = password.password_hash_type
670+
else
671+
raise ArgumentError, "expected password to be one of: WorkOS::UserManagement::PasswordPlaintext, WorkOS::UserManagement::PasswordHashed, got #{password.class}"
651672
end
652673
end
653674
response = @client.request(
@@ -709,9 +730,7 @@ def get_user(
709730
# @param metadata [Hash{String => String}, nil] Object containing metadata key/value pairs associated with the user.
710731
# @param external_id [String, nil] The external ID of the user.
711732
# @param locale [String, nil] The user's preferred locale.
712-
# @param password [String, nil] The password to set for the user. Mutually exclusive with `password_hash` and `password_hash_type`.
713-
# @param password_hash [String, nil] The hashed password to set for the user. Required with `password_hash_type`. Mutually exclusive with `password`.
714-
# @param password_hash_type [WorkOS::Types::UpdateUserPasswordHashType, nil] The algorithm originally used to hash the password, used when providing a `password_hash`. Required with `password_hash`. Mutually exclusive with `password`.
733+
# @param password [WorkOS::UserManagement::PasswordPlaintext, WorkOS::UserManagement::PasswordHashed, nil] Identifies the password.
715734
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
716735
# @return [WorkOS::User]
717736
def update_user(
@@ -724,8 +743,6 @@ def update_user(
724743
external_id: nil,
725744
locale: nil,
726745
password: nil,
727-
password_hash: nil,
728-
password_hash_type: nil,
729746
request_options: {}
730747
)
731748
body = {
@@ -735,18 +752,17 @@ def update_user(
735752
"email_verified" => email_verified,
736753
"metadata" => metadata,
737754
"external_id" => external_id,
738-
"locale" => locale,
739-
"password" => password,
740-
"password_hash" => password_hash,
741-
"password_hash_type" => password_hash_type
755+
"locale" => locale
742756
}.compact
743757
if password
744-
case password[:type]
745-
when "plaintext"
746-
body["password"] = password[:password]
747-
when "hashed"
748-
body["password_hash"] = password[:password_hash]
749-
body["password_hash_type"] = password[:password_hash_type]
758+
case password
759+
when WorkOS::UserManagement::PasswordPlaintext
760+
body["password"] = password.password
761+
when WorkOS::UserManagement::PasswordHashed
762+
body["password_hash"] = password.password_hash
763+
body["password_hash_type"] = password.password_hash_type
764+
else
765+
raise ArgumentError, "expected password to be one of: WorkOS::UserManagement::PasswordPlaintext, WorkOS::UserManagement::PasswordHashed, got #{password.class}"
750766
end
751767
end
752768
response = @client.request(
@@ -790,7 +806,7 @@ def confirm_email_change(
790806
)
791807
body = {
792808
"code" => code
793-
}.compact
809+
}
794810
response = @client.request(
795811
method: :post,
796812
path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_change/confirm",
@@ -815,7 +831,7 @@ def send_email_change(
815831
)
816832
body = {
817833
"new_email" => new_email
818-
}.compact
834+
}
819835
response = @client.request(
820836
method: :post,
821837
path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_change/send",
@@ -840,7 +856,7 @@ def verify_email(
840856
)
841857
body = {
842858
"code" => code
843-
}.compact
859+
}
844860
response = @client.request(
845861
method: :post,
846862
path: "/user_management/users/#{WorkOS::Util.encode_path(id)}/email_verification/confirm",
@@ -1138,7 +1154,7 @@ def update_jwt_template(
11381154
)
11391155
body = {
11401156
"content" => content
1141-
}.compact
1157+
}
11421158
response = @client.request(
11431159
method: :put,
11441160
path: "/user_management/jwt_template",
@@ -1255,30 +1271,27 @@ def list_organization_memberships(
12551271
# Create an organization membership
12561272
# @param user_id [String] The ID of the [user](https://workos.com/docs/reference/authkit/user).
12571273
# @param organization_id [String] The ID of the [organization](https://workos.com/docs/reference/organization) which the user belongs to.
1258-
# @param role_slug [String, nil] A single role identifier. Defaults to `member` or the explicit default role. Mutually exclusive with `role_slugs`.
1259-
# @param role_slugs [Array<String>, nil] An array of role identifiers. Limited to one role when Multiple Roles is disabled. Mutually exclusive with `role_slug`.
1274+
# @param role [WorkOS::UserManagement::RoleSingle, WorkOS::UserManagement::RoleMultiple, nil] Identifies the role.
12601275
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
12611276
# @return [WorkOS::OrganizationMembership]
12621277
def create_organization_membership(
12631278
user_id:,
12641279
organization_id:,
1265-
role_slug: nil,
1266-
role_slugs: nil,
12671280
role: nil,
12681281
request_options: {}
12691282
)
12701283
body = {
12711284
"user_id" => user_id,
1272-
"organization_id" => organization_id,
1273-
"role_slug" => role_slug,
1274-
"role_slugs" => role_slugs
1275-
}.compact
1285+
"organization_id" => organization_id
1286+
}
12761287
if role
1277-
case role[:type]
1278-
when "single"
1279-
body["role_slug"] = role[:role_slug]
1280-
when "multiple"
1281-
body["role_slugs"] = role[:role_slugs]
1288+
case role
1289+
when WorkOS::UserManagement::RoleSingle
1290+
body["role_slug"] = role.role_slug
1291+
when WorkOS::UserManagement::RoleMultiple
1292+
body["role_slugs"] = role.role_slugs
1293+
else
1294+
raise ArgumentError, "expected role to be one of: WorkOS::UserManagement::RoleSingle, WorkOS::UserManagement::RoleMultiple, got #{role.class}"
12821295
end
12831296
end
12841297
response = @client.request(
@@ -1314,27 +1327,23 @@ def get_organization_membership(
13141327

13151328
# Update an organization membership
13161329
# @param id [String] The unique ID of the organization membership.
1317-
# @param role_slug [String, nil] A single role identifier. Defaults to `member` or the explicit default role. Mutually exclusive with `role_slugs`.
1318-
# @param role_slugs [Array<String>, nil] An array of role identifiers. Limited to one role when Multiple Roles is disabled. Mutually exclusive with `role_slug`.
1330+
# @param role [WorkOS::UserManagement::RoleSingle, WorkOS::UserManagement::RoleMultiple, nil] Identifies the role.
13191331
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
13201332
# @return [WorkOS::UserOrganizationMembership]
13211333
def update_organization_membership(
13221334
id:,
1323-
role_slug: nil,
1324-
role_slugs: nil,
13251335
role: nil,
13261336
request_options: {}
13271337
)
1328-
body = {
1329-
"role_slug" => role_slug,
1330-
"role_slugs" => role_slugs
1331-
}.compact
1338+
body = {}
13321339
if role
1333-
case role[:type]
1334-
when "single"
1335-
body["role_slug"] = role[:role_slug]
1336-
when "multiple"
1337-
body["role_slugs"] = role[:role_slugs]
1340+
case role
1341+
when WorkOS::UserManagement::RoleSingle
1342+
body["role_slug"] = role.role_slug
1343+
when WorkOS::UserManagement::RoleMultiple
1344+
body["role_slugs"] = role.role_slugs
1345+
else
1346+
raise ArgumentError, "expected role to be one of: WorkOS::UserManagement::RoleSingle, WorkOS::UserManagement::RoleMultiple, got #{role.class}"
13381347
end
13391348
end
13401349
response = @client.request(
@@ -1414,7 +1423,7 @@ def create_redirect_uri(
14141423
)
14151424
body = {
14161425
"uri" => uri
1417-
}.compact
1426+
}
14181427
response = @client.request(
14191428
method: :post,
14201429
path: "/user_management/redirect_uris",

0 commit comments

Comments
 (0)