diff --git a/src/prelude_python_sdk/resources/transactional.py b/src/prelude_python_sdk/resources/transactional.py index a6c7015..5fac16f 100644 --- a/src/prelude_python_sdk/resources/transactional.py +++ b/src/prelude_python_sdk/resources/transactional.py @@ -55,6 +55,7 @@ def send( correlation_id: str | NotGiven = NOT_GIVEN, expires_at: str | NotGiven = NOT_GIVEN, from_: str | NotGiven = NOT_GIVEN, + locale: str | NotGiven = NOT_GIVEN, variables: Dict[str, str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -79,6 +80,11 @@ def send( from_: The Sender ID. + locale: A BCP-47 formatted locale string with the language the text message will be sent + to. If there's no locale set, the language will be determined by the country + code of the phone number. If the language specified doesn't exist, the default + set on the template will be used. + variables: The variables to be replaced in the template. extra_headers: Send extra headers @@ -99,6 +105,7 @@ def send( "correlation_id": correlation_id, "expires_at": expires_at, "from_": from_, + "locale": locale, "variables": variables, }, transactional_send_params.TransactionalSendParams, @@ -139,6 +146,7 @@ async def send( correlation_id: str | NotGiven = NOT_GIVEN, expires_at: str | NotGiven = NOT_GIVEN, from_: str | NotGiven = NOT_GIVEN, + locale: str | NotGiven = NOT_GIVEN, variables: Dict[str, str] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -163,6 +171,11 @@ async def send( from_: The Sender ID. + locale: A BCP-47 formatted locale string with the language the text message will be sent + to. If there's no locale set, the language will be determined by the country + code of the phone number. If the language specified doesn't exist, the default + set on the template will be used. + variables: The variables to be replaced in the template. extra_headers: Send extra headers @@ -183,6 +196,7 @@ async def send( "correlation_id": correlation_id, "expires_at": expires_at, "from_": from_, + "locale": locale, "variables": variables, }, transactional_send_params.TransactionalSendParams, diff --git a/src/prelude_python_sdk/resources/verification.py b/src/prelude_python_sdk/resources/verification.py index e6201e1..735a7cc 100644 --- a/src/prelude_python_sdk/resources/verification.py +++ b/src/prelude_python_sdk/resources/verification.py @@ -49,6 +49,7 @@ def create( self, *, target: verification_create_params.Target, + dispatch_id: str | NotGiven = NOT_GIVEN, metadata: verification_create_params.Metadata | NotGiven = NOT_GIVEN, options: verification_create_params.Options | NotGiven = NOT_GIVEN, signals: verification_create_params.Signals | NotGiven = NOT_GIVEN, @@ -68,6 +69,8 @@ def create( Args: target: The target. Currently this can only be an E.164 formatted phone number. + dispatch_id: The identifier of the dispatch that came from the front-end SDK. + metadata: The metadata for this verification. This object will be returned with every response or webhook sent that refers to this verification. @@ -88,6 +91,7 @@ def create( body=maybe_transform( { "target": target, + "dispatch_id": dispatch_id, "metadata": metadata, "options": options, "signals": signals, @@ -168,6 +172,7 @@ async def create( self, *, target: verification_create_params.Target, + dispatch_id: str | NotGiven = NOT_GIVEN, metadata: verification_create_params.Metadata | NotGiven = NOT_GIVEN, options: verification_create_params.Options | NotGiven = NOT_GIVEN, signals: verification_create_params.Signals | NotGiven = NOT_GIVEN, @@ -187,6 +192,8 @@ async def create( Args: target: The target. Currently this can only be an E.164 formatted phone number. + dispatch_id: The identifier of the dispatch that came from the front-end SDK. + metadata: The metadata for this verification. This object will be returned with every response or webhook sent that refers to this verification. @@ -207,6 +214,7 @@ async def create( body=await async_maybe_transform( { "target": target, + "dispatch_id": dispatch_id, "metadata": metadata, "options": options, "signals": signals, diff --git a/src/prelude_python_sdk/types/transactional_send_params.py b/src/prelude_python_sdk/types/transactional_send_params.py index 6aba37f..02be0af 100644 --- a/src/prelude_python_sdk/types/transactional_send_params.py +++ b/src/prelude_python_sdk/types/transactional_send_params.py @@ -29,5 +29,13 @@ class TransactionalSendParams(TypedDict, total=False): from_: Annotated[str, PropertyInfo(alias="from")] """The Sender ID.""" + locale: str + """ + A BCP-47 formatted locale string with the language the text message will be sent + to. If there's no locale set, the language will be determined by the country + code of the phone number. If the language specified doesn't exist, the default + set on the template will be used. + """ + variables: Dict[str, str] """The variables to be replaced in the template.""" diff --git a/src/prelude_python_sdk/types/verification_check_response.py b/src/prelude_python_sdk/types/verification_check_response.py index 4bcb3b4..7bca9cf 100644 --- a/src/prelude_python_sdk/types/verification_check_response.py +++ b/src/prelude_python_sdk/types/verification_check_response.py @@ -13,6 +13,9 @@ class Metadata(BaseModel): class VerificationCheckResponse(BaseModel): + status: Literal["success", "failure", "expired_or_not_found"] + """The status of the check.""" + id: Optional[str] = None """The verification identifier.""" @@ -20,6 +23,3 @@ class VerificationCheckResponse(BaseModel): """The metadata for this verification.""" request_id: Optional[str] = None - - status: Optional[Literal["success", "failure", "expired"]] = None - """The status of the check.""" diff --git a/src/prelude_python_sdk/types/verification_create_params.py b/src/prelude_python_sdk/types/verification_create_params.py index 1b59abf..9ea69a7 100644 --- a/src/prelude_python_sdk/types/verification_create_params.py +++ b/src/prelude_python_sdk/types/verification_create_params.py @@ -4,13 +4,16 @@ from typing_extensions import Literal, Required, TypedDict -__all__ = ["VerificationCreateParams", "Target", "Metadata", "Options", "Signals"] +__all__ = ["VerificationCreateParams", "Target", "Metadata", "Options", "OptionsAppRealm", "Signals"] class VerificationCreateParams(TypedDict, total=False): target: Required[Target] """The target. Currently this can only be an E.164 formatted phone number.""" + dispatch_id: str + """The identifier of the dispatch that came from the front-end SDK.""" + metadata: Metadata """The metadata for this verification. @@ -38,12 +41,37 @@ class Metadata(TypedDict, total=False): """A user-defined identifier to correlate this verification with.""" +class OptionsAppRealm(TypedDict, total=False): + platform: Required[Literal["android"]] + """The platform the SMS will be sent to. + + We are currently only supporting "android". + """ + + value: Required[str] + """The Android SMS Retriever API hash code that identifies your app.""" + + class Options(TypedDict, total=False): - app_realm: str - """The Android SMS Retriever API hash code that identifies your app. + app_realm: OptionsAppRealm + """This allows you to automatically retrieve and fill the OTP code on mobile apps. + + Currently only Android devices are supported. + """ + + code_size: int + """The size of the code generated. + + It should be between 4 and 8. Defaults to the code size specified from the + Dashboard. + """ + + custom_code: str + """The custom code to use for OTP verification. - This allows you to automatically retrieve and fill the OTP code on Android - devices. + This feature is only available for compatibility purposes and subject to + Prelude’s approval. Contact us to discuss your use case. For more details, refer + to [Multi Routing](/concepts/multi-routing). """ locale: str @@ -82,13 +110,13 @@ class Signals(TypedDict, total=False): device_model: str """The model of the user's device.""" - device_platform: Literal["android", "ios", "web"] + device_platform: Literal["android", "ios", "ipados", "tvos", "web"] """The type of the user's device.""" ip: str """The IP address of the user's device.""" - is_trusted_user: str + is_trusted_user: bool """ This signal should provide a higher level of trust, indicating that the user is genuine. For more details, refer to [Signals](/guides/prevent-fraud#signals). diff --git a/src/prelude_python_sdk/types/verification_create_response.py b/src/prelude_python_sdk/types/verification_create_response.py index f1121cb..fdc66ff 100644 --- a/src/prelude_python_sdk/types/verification_create_response.py +++ b/src/prelude_python_sdk/types/verification_create_response.py @@ -13,16 +13,16 @@ class Metadata(BaseModel): class VerificationCreateResponse(BaseModel): - id: Optional[str] = None + id: str """The verification identifier.""" + method: Literal["message"] + """The method used for verifying this phone number.""" + + status: Literal["success", "retry", "blocked"] + """The status of the verification.""" + metadata: Optional[Metadata] = None """The metadata for this verification.""" - method: Optional[Literal["message"]] = None - """The method used for verifying this phone number.""" - request_id: Optional[str] = None - - status: Optional[Literal["success", "retry", "blocked"]] = None - """The status of the verification.""" diff --git a/src/prelude_python_sdk/types/watch_feed_back_response.py b/src/prelude_python_sdk/types/watch_feed_back_response.py index aa10b12..c879860 100644 --- a/src/prelude_python_sdk/types/watch_feed_back_response.py +++ b/src/prelude_python_sdk/types/watch_feed_back_response.py @@ -1,6 +1,5 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Optional from .._models import BaseModel @@ -8,5 +7,5 @@ class WatchFeedBackResponse(BaseModel): - id: Optional[str] = None + id: str """A unique identifier for your feedback request.""" diff --git a/src/prelude_python_sdk/types/watch_predict_response.py b/src/prelude_python_sdk/types/watch_predict_response.py index d85e251..cb5a871 100644 --- a/src/prelude_python_sdk/types/watch_predict_response.py +++ b/src/prelude_python_sdk/types/watch_predict_response.py @@ -20,10 +20,10 @@ class Reasoning(BaseModel): class WatchPredictResponse(BaseModel): - id: Optional[str] = None + id: str """A unique identifier for your prediction request.""" - prediction: Optional[Literal["allow", "block"]] = None + prediction: Literal["allow", "block"] """A label indicating the trustworthiness of the phone number.""" - reasoning: Optional[Reasoning] = None + reasoning: Reasoning diff --git a/tests/api_resources/test_transactional.py b/tests/api_resources/test_transactional.py index 7a105f6..b4f77bd 100644 --- a/tests/api_resources/test_transactional.py +++ b/tests/api_resources/test_transactional.py @@ -23,8 +23,8 @@ class TestTransactional: @parametrize def test_method_send(self, client: Prelude) -> None: transactional = client.transactional.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) assert_matches_type(TransactionalSendResponse, transactional, path=["response"]) @@ -34,13 +34,14 @@ def test_method_send(self, client: Prelude) -> None: @parametrize def test_method_send_with_all_params(self, client: Prelude) -> None: transactional = client.transactional.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", callback_url="callback_url", correlation_id="correlation_id", expires_at="expires_at", from_="from", - variables={"foo": "string"}, + locale="el-GR", + variables={"foo": "bar"}, ) assert_matches_type(TransactionalSendResponse, transactional, path=["response"]) @@ -50,8 +51,8 @@ def test_method_send_with_all_params(self, client: Prelude) -> None: @parametrize def test_raw_response_send(self, client: Prelude) -> None: response = client.transactional.with_raw_response.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) assert response.is_closed is True @@ -65,8 +66,8 @@ def test_raw_response_send(self, client: Prelude) -> None: @parametrize def test_streaming_response_send(self, client: Prelude) -> None: with client.transactional.with_streaming_response.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -86,8 +87,8 @@ class TestAsyncTransactional: @parametrize async def test_method_send(self, async_client: AsyncPrelude) -> None: transactional = await async_client.transactional.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) assert_matches_type(TransactionalSendResponse, transactional, path=["response"]) @@ -97,13 +98,14 @@ async def test_method_send(self, async_client: AsyncPrelude) -> None: @parametrize async def test_method_send_with_all_params(self, async_client: AsyncPrelude) -> None: transactional = await async_client.transactional.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", callback_url="callback_url", correlation_id="correlation_id", expires_at="expires_at", from_="from", - variables={"foo": "string"}, + locale="el-GR", + variables={"foo": "bar"}, ) assert_matches_type(TransactionalSendResponse, transactional, path=["response"]) @@ -113,8 +115,8 @@ async def test_method_send_with_all_params(self, async_client: AsyncPrelude) -> @parametrize async def test_raw_response_send(self, async_client: AsyncPrelude) -> None: response = await async_client.transactional.with_raw_response.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) assert response.is_closed is True @@ -128,8 +130,8 @@ async def test_raw_response_send(self, async_client: AsyncPrelude) -> None: @parametrize async def test_streaming_response_send(self, async_client: AsyncPrelude) -> None: async with async_client.transactional.with_streaming_response.send( - template_id="template_id", - to="to", + template_id="template_01jd1xq0cffycayqtdkdbv4d61", + to="+30123456789", ) as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_verification.py b/tests/api_resources/test_verification.py index df37638..6170e67 100644 --- a/tests/api_resources/test_verification.py +++ b/tests/api_resources/test_verification.py @@ -37,21 +37,27 @@ def test_method_create_with_all_params(self, client: Prelude) -> None: "type": "phone_number", "value": "+30123456789", }, + dispatch_id="dispatch_id", metadata={"correlation_id": "correlation_id"}, options={ - "app_realm": "app_realm", + "app_realm": { + "platform": "android", + "value": "value", + }, + "code_size": 5, + "custom_code": "custom_code", "locale": "el-GR", "sender_id": "sender_id", "template_id": "template_id", }, signals={ - "app_version": "app_version", - "device_id": "device_id", - "device_model": "device_model", + "app_version": "1.2.34", + "device_id": "8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2", + "device_model": "iPhone17,2", "device_platform": "android", - "ip": "8.8.8.8", - "is_trusted_user": "is_trusted_user", - "os_version": "os_version", + "ip": "192.0.2.1", + "is_trusted_user": False, + "os_version": "18.0.1", }, ) assert_matches_type(VerificationCreateResponse, verification, path=["response"]) @@ -150,21 +156,27 @@ async def test_method_create_with_all_params(self, async_client: AsyncPrelude) - "type": "phone_number", "value": "+30123456789", }, + dispatch_id="dispatch_id", metadata={"correlation_id": "correlation_id"}, options={ - "app_realm": "app_realm", + "app_realm": { + "platform": "android", + "value": "value", + }, + "code_size": 5, + "custom_code": "custom_code", "locale": "el-GR", "sender_id": "sender_id", "template_id": "template_id", }, signals={ - "app_version": "app_version", - "device_id": "device_id", - "device_model": "device_model", + "app_version": "1.2.34", + "device_id": "8F0B8FDD-C2CB-4387-B20A-56E9B2E5A0D2", + "device_model": "iPhone17,2", "device_platform": "android", - "ip": "8.8.8.8", - "is_trusted_user": "is_trusted_user", - "os_version": "os_version", + "ip": "192.0.2.1", + "is_trusted_user": False, + "os_version": "18.0.1", }, ) assert_matches_type(VerificationCreateResponse, verification, path=["response"])