From 7a50d87b3825ff49d59e8a59cd852e1d75f18483 Mon Sep 17 00:00:00 2001 From: Asaf Shen Date: Mon, 1 Jun 2026 15:26:46 +0300 Subject: [PATCH] feat: add locale to invite and invite_batch Adds an optional `locale` parameter to `user.invite` and `user.invite_batch` to control the language of the invite message, mirroring descope/node-sdk#735. Co-Authored-By: Claude Opus 4.8 (1M context) --- descope/management/user.py | 10 ++++++++++ tests/management/test_user.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/descope/management/user.py b/descope/management/user.py index 4617bea79..780545917 100644 --- a/descope/management/user.py +++ b/descope/management/user.py @@ -244,6 +244,7 @@ def invite( sso_app_ids: Optional[List[str]] = None, template_id: str = "", test: bool = False, + locale: Optional[str] = None, # locale for the invite message ) -> dict: """ Create a new user and invite them via an email / text message. @@ -283,6 +284,7 @@ def invite( additional_login_ids, sso_app_ids, template_id, + locale, ), ) return response.json() @@ -293,6 +295,7 @@ def invite_batch( invite_url: Optional[str] = None, send_mail: Optional[bool] = None, # send invite via mail, default is according to project settings send_sms: Optional[bool] = None, # send invite via text message, default is according to project settings + locale: Optional[str] = None, # locale for the invite message ) -> dict: """ Create users in batch and invite them via an email / text message. @@ -313,6 +316,7 @@ def invite_batch( invite_url, send_mail, send_sms, + locale, ), ) return response.json() @@ -1860,6 +1864,7 @@ def _compose_create_body( additional_login_ids: Optional[List[str]], sso_app_ids: Optional[List[str]] = None, template_id: str = "", + locale: Optional[str] = None, ) -> dict: body = User._compose_update_body( login_id=login_id, @@ -1890,6 +1895,8 @@ def _compose_create_body( body["sendSMS"] = send_sms if template_id != "": body["templateId"] = template_id + if locale is not None: + body["locale"] = locale return body @staticmethod @@ -1898,6 +1905,7 @@ def _compose_create_batch_body( invite_url: Optional[str], send_mail: Optional[bool], send_sms: Optional[bool], + locale: Optional[str] = None, ) -> dict: usersBody = [] for user in users: @@ -1940,6 +1948,8 @@ def _compose_create_batch_body( body["sendMail"] = send_mail if send_sms is not None: body["sendSMS"] = send_sms + if locale is not None: + body["locale"] = locale return body @staticmethod diff --git a/tests/management/test_user.py b/tests/management/test_user.py index d835830ec..7713cac4b 100644 --- a/tests/management/test_user.py +++ b/tests/management/test_user.py @@ -241,6 +241,7 @@ def test_invite(self): send_sms=True, sso_app_ids=["app1", "app2"], template_id="tid", + locale="en", ) user = resp["user"] self.assertEqual(user["id"], "u1") @@ -271,6 +272,7 @@ def test_invite(self): "additionalLoginIds": None, "ssoAppIDs": ["app1", "app2"], "templateId": "tid", + "locale": "en", }, follow_redirects=False, verify=SSLMatcher(), @@ -320,6 +322,7 @@ def test_invite_batch(self): users=[user], invite_url="invite.me", send_sms=True, + locale="en", ) users = resp["users"] self.assertEqual(users[0]["id"], "u1") @@ -361,6 +364,7 @@ def test_invite_batch(self): "invite": True, "inviteUrl": "invite.me", "sendSMS": True, + "locale": "en", } mock_post.assert_called_with( f"{common.DEFAULT_BASE_URL}{MgmtV1.user_create_batch_path}", @@ -400,6 +404,7 @@ def test_invite_batch(self): users=[user], invite_url="invite.me", send_sms=True, + locale="en", ) del expected_users["users"][0]["hashedPassword"] @@ -423,6 +428,7 @@ def test_invite_batch(self): users=[user], invite_url="invite.me", send_sms=True, + locale="en", ) del expected_users["users"][0]["password"]