diff --git a/lib/workos/user.rb b/lib/workos/user.rb index 0840d459..6e952815 100644 --- a/lib/workos/user.rb +++ b/lib/workos/user.rb @@ -8,7 +8,7 @@ class User include HashProvider attr_accessor :id, :email, :first_name, :last_name, :email_verified, - :profile_picture_url, :external_id, :last_sign_in_at, :created_at, :updated_at + :profile_picture_url, :external_id, :locale, :last_sign_in_at, :created_at, :updated_at def initialize(json) hash = JSON.parse(json, symbolize_names: true) @@ -20,6 +20,7 @@ def initialize(json) @email_verified = hash[:email_verified] @profile_picture_url = hash[:profile_picture_url] @external_id = hash[:external_id] + @locale = hash[:locale] @last_sign_in_at = hash[:last_sign_in_at] @created_at = hash[:created_at] @updated_at = hash[:updated_at] @@ -34,6 +35,7 @@ def to_json(*) email_verified: email_verified, profile_picture_url: profile_picture_url, external_id: external_id, + locale: locale, last_sign_in_at: last_sign_in_at, created_at: created_at, updated_at: updated_at, diff --git a/lib/workos/user_management.rb b/lib/workos/user_management.rb index 8084e0e1..cc0da3fa 100644 --- a/lib/workos/user_management.rb +++ b/lib/workos/user_management.rb @@ -230,6 +230,7 @@ def create_user( # @param [String] last_name The user's last name. # @param [Boolean] email_verified Whether the user's email address was previously verified. # @param [String] external_id The users's external ID + # @param [String] locale The user's locale. # @param [String] password The user's password. # @param [String] password_hash The user's hashed password. # @option [String] password_hash_type The algorithm originally used to hash the password. @@ -243,6 +244,7 @@ def update_user( last_name: :not_set, email_verified: :not_set, external_id: :not_set, + locale: :not_set, password: :not_set, password_hash: :not_set, password_hash_type: :not_set @@ -255,6 +257,7 @@ def update_user( last_name: last_name, email_verified: email_verified, external_id: external_id, + locale: locale, password: password, password_hash: password_hash, password_hash_type: password_hash_type, diff --git a/spec/lib/workos/user_management_spec.rb b/spec/lib/workos/user_management_spec.rb index 1192e936..f4626139 100644 --- a/spec/lib/workos/user_management_spec.rb +++ b/spec/lib/workos/user_management_spec.rb @@ -442,6 +442,16 @@ end end + it 'can update user locale' do + VCR.use_cassette 'user_management/update_user/locale' do + user = described_class.update_user( + id: 'user_01K78B3ZB5B7119MYEXTQE5KNE', + locale: 'en-US', + ) + expect(user.locale).to eq('en-US') + end + end + it 'can update email addresses' do VCR.use_cassette 'user_management/update_user/email' do user = described_class.update_user( @@ -462,6 +472,7 @@ expect(body).not_to have_key(:first_name) expect(body).not_to have_key(:last_name) expect(body).not_to have_key(:email) + expect(body).not_to have_key(:locale) # Return a mock request object double('request') diff --git a/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml new file mode 100644 index 00000000..6b3177c6 --- /dev/null +++ b/spec/support/fixtures/vcr_cassettes/user_management/update_user/locale.yml @@ -0,0 +1,76 @@ +--- +http_interactions: +- request: + method: put + uri: https://api.workos.com/user_management/users/user_01K78B3ZB5B7119MYEXTQE5KNE + body: + encoding: UTF-8 + string: '{"locale":"en-US"}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - WorkOS; ruby/3.1.4; arm64-darwin23; v5.25.0 + Authorization: + - Bearer + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 11 Oct 2025 00:40:19 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cf-Ray: + - 98ca4e2ece4df13a-ORD + Cf-Cache-Status: + - DYNAMIC + Etag: + - W/"14b-avtqVpGgr9LY49Al2c3gzw62Mbc" + Strict-Transport-Security: + - max-age=15552000; includeSubDomains + Vary: + - Origin, Accept-Encoding + Access-Control-Allow-Credentials: + - 'true' + Content-Security-Policy: + - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' + https: data:;frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src + ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' + Expect-Ct: + - max-age=0 + Referrer-Policy: + - no-referrer + X-Content-Type-Options: + - nosniff + X-Dns-Prefetch-Control: + - 'off' + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - e9a5015e-44f0-4321-990a-66d2ba4a3e15 + X-Xss-Protection: + - '0' + Set-Cookie: + - _cfuvid=IZBV12JrFjDy0rHr.O3LoIyI0iKnOHdGa_R3uam5bZI-1760143219077-0.0.1.1-604800000; + path=/; domain=.workos.com; HttpOnly; Secure; SameSite=None + Server: + - cloudflare + body: + encoding: ASCII-8BIT + string: '{"object":"user","id":"user_01K78B3ZB5B7119MYEXTQE5KNE","email":"test-locale@example.com","email_verified":false,"first_name":"Jane","last_name":"Doe","profile_picture_url":null,"metadata":{},"last_sign_in_at":null,"locale":"en-US","created_at":"2025-10-11T00:35:49.727Z","updated_at":"2025-10-11T00:40:19.051Z","external_id":null}' + recorded_at: Sat, 11 Oct 2025 00:40:19 GMT +recorded_with: VCR 6.3.1