Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/prelude_python_sdk/resources/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def create(
this endpoint will perform a retry instead.

Args:
target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

dispatch_id: The identifier of the dispatch that came from the front-end SDK.

Expand All @@ -76,7 +77,8 @@ def create(

options: Verification options

signals: The signals used for anti-fraud.
signals: The signals used for anti-fraud. For more details, refer to
[Signals](/guides/prevent-fraud#signals).

extra_headers: Send extra headers

Expand Down Expand Up @@ -122,7 +124,8 @@ def check(
Args:
code: The OTP code to validate.

target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

extra_headers: Send extra headers

Expand Down Expand Up @@ -190,7 +193,8 @@ async def create(
this endpoint will perform a retry instead.

Args:
target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

dispatch_id: The identifier of the dispatch that came from the front-end SDK.

Expand All @@ -199,7 +203,8 @@ async def create(

options: Verification options

signals: The signals used for anti-fraud.
signals: The signals used for anti-fraud. For more details, refer to
[Signals](/guides/prevent-fraud#signals).

extra_headers: Send extra headers

Expand Down Expand Up @@ -245,7 +250,8 @@ async def check(
Args:
code: The OTP code to validate.

target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

extra_headers: Send extra headers

Expand Down
12 changes: 8 additions & 4 deletions src/prelude_python_sdk/resources/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def feed_back(
feedback: You should send a feedback event back to Watch API when your user demonstrates
authentic behavior.

target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

extra_headers: Send extra headers

Expand Down Expand Up @@ -108,7 +109,8 @@ def predict(
must be implemented in conjunction with the `watch/feedback` endpoint.

Args:
target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

signals: It is highly recommended that you provide the signals to increase prediction
performance.
Expand Down Expand Up @@ -177,7 +179,8 @@ async def feed_back(
feedback: You should send a feedback event back to Watch API when your user demonstrates
authentic behavior.

target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

extra_headers: Send extra headers

Expand Down Expand Up @@ -220,7 +223,8 @@ async def predict(
must be implemented in conjunction with the `watch/feedback` endpoint.

Args:
target: The target. Currently this can only be an E.164 formatted phone number.
target: The verification target. Either a phone number or an email address. To use the
email verification feature contact us to discuss your use case.

signals: It is highly recommended that you provide the signals to increase prediction
performance.
Expand Down
12 changes: 8 additions & 4 deletions src/prelude_python_sdk/types/verification_check_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ class VerificationCheckParams(TypedDict, total=False):
"""The OTP code to validate."""

target: Required[Target]
"""The target. Currently this can only be an E.164 formatted phone number."""
"""The verification target.

Either a phone number or an email address. To use the email verification feature
contact us to discuss your use case.
"""


class Target(TypedDict, total=False):
type: Required[Literal["phone_number"]]
"""The type of the target. Currently this can only be "phone_number"."""
type: Required[Literal["phone_number", "email_address"]]
"""The type of the target. Either "phone_number" or "email_address"."""

value: Required[str]
"""An E.164 formatted phone number to verify."""
"""An E.164 formatted phone number or an email address."""
42 changes: 34 additions & 8 deletions src/prelude_python_sdk/types/verification_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

from __future__ import annotations

from typing import Dict
from typing_extensions import Literal, Required, TypedDict

__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."""
"""The verification target.

Either a phone number or an email address. To use the email verification feature
contact us to discuss your use case.
"""

dispatch_id: str
"""The identifier of the dispatch that came from the front-end SDK."""
Expand All @@ -25,15 +30,18 @@ class VerificationCreateParams(TypedDict, total=False):
"""Verification options"""

signals: Signals
"""The signals used for anti-fraud."""
"""The signals used for anti-fraud.

For more details, refer to [Signals](/guides/prevent-fraud#signals).
"""


class Target(TypedDict, total=False):
type: Required[Literal["phone_number"]]
"""The type of the target. Currently this can only be "phone_number"."""
type: Required[Literal["phone_number", "email_address"]]
"""The type of the target. Either "phone_number" or "email_address"."""

value: Required[str]
"""An E.164 formatted phone number to verify."""
"""An E.164 formatted phone number or an email address."""


class Metadata(TypedDict, total=False):
Expand All @@ -59,6 +67,13 @@ class Options(TypedDict, total=False):
Currently only Android devices are supported.
"""

callback_url: str
"""
The URL where webhooks will be sent when verification events occur, including
verification creation, attempt creation, and delivery status changes. For more
details, refer to [Webhook](/api-reference/v2/verify/webhook).
"""

code_size: int
"""The size of the code generated.

Expand Down Expand Up @@ -89,12 +104,15 @@ class Options(TypedDict, total=False):
"""

template_id: str
"""The identifier of a verification settings template.
"""The identifier of a verification template.

It is used to be able to switch behavior for specific use cases. Contact us if
you need to use this functionality.
It applies use case-specific settings, such as the message content or certain
verification parameters.
"""

variables: Dict[str, str]
"""The variables to be replaced in the template."""


class Signals(TypedDict, total=False):
app_version: str
Expand Down Expand Up @@ -124,3 +142,11 @@ class Signals(TypedDict, total=False):

os_version: str
"""The version of the user's device operating system."""

user_agent: str
"""The user agent of the user's device.

If the individual fields (os_version, device_platform, device_model) are
provided, we will prioritize those values instead of parsing them from the user
agent string.
"""
12 changes: 8 additions & 4 deletions src/prelude_python_sdk/types/watch_feed_back_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ class WatchFeedBackParams(TypedDict, total=False):
"""

target: Required[Target]
"""The target. Currently this can only be an E.164 formatted phone number."""
"""The verification target.

Either a phone number or an email address. To use the email verification feature
contact us to discuss your use case.
"""


class Feedback(TypedDict, total=False):
Expand All @@ -27,8 +31,8 @@ class Feedback(TypedDict, total=False):


class Target(TypedDict, total=False):
type: Required[Literal["phone_number"]]
"""The type of the target. Currently this can only be "phone_number"."""
type: Required[Literal["phone_number", "email_address"]]
"""The type of the target. Either "phone_number" or "email_address"."""

value: Required[str]
"""An E.164 formatted phone number to verify."""
"""An E.164 formatted phone number or an email address."""
12 changes: 8 additions & 4 deletions src/prelude_python_sdk/types/watch_predict_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

class WatchPredictParams(TypedDict, total=False):
target: Required[Target]
"""The target. Currently this can only be an E.164 formatted phone number."""
"""The verification target.

Either a phone number or an email address. To use the email verification feature
contact us to discuss your use case.
"""

signals: Signals
"""
Expand All @@ -19,11 +23,11 @@ class WatchPredictParams(TypedDict, total=False):


class Target(TypedDict, total=False):
type: Required[Literal["phone_number"]]
"""The type of the target. Currently this can only be "phone_number"."""
type: Required[Literal["phone_number", "email_address"]]
"""The type of the target. Either "phone_number" or "email_address"."""

value: Required[str]
"""An E.164 formatted phone number to verify."""
"""An E.164 formatted phone number or an email address."""


class Signals(TypedDict, total=False):
Expand Down
10 changes: 8 additions & 2 deletions tests/api_resources/test_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ def test_method_create_with_all_params(self, client: Prelude) -> None:
"platform": "android",
"value": "value",
},
"callback_url": "callback_url",
"code_size": 5,
"custom_code": "custom_code",
"locale": "el-GR",
"sender_id": "sender_id",
"template_id": "template_id",
"template_id": "prelude:psd2",
"variables": {"foo": "bar"},
},
signals={
"app_version": "1.2.34",
Expand All @@ -58,6 +60,7 @@ def test_method_create_with_all_params(self, client: Prelude) -> None:
"ip": "192.0.2.1",
"is_trusted_user": False,
"os_version": "18.0.1",
"user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1",
},
)
assert_matches_type(VerificationCreateResponse, verification, path=["response"])
Expand Down Expand Up @@ -163,11 +166,13 @@ async def test_method_create_with_all_params(self, async_client: AsyncPrelude) -
"platform": "android",
"value": "value",
},
"callback_url": "callback_url",
"code_size": 5,
"custom_code": "custom_code",
"locale": "el-GR",
"sender_id": "sender_id",
"template_id": "template_id",
"template_id": "prelude:psd2",
"variables": {"foo": "bar"},
},
signals={
"app_version": "1.2.34",
Expand All @@ -177,6 +182,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncPrelude) -
"ip": "192.0.2.1",
"is_trusted_user": False,
"os_version": "18.0.1",
"user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1",
},
)
assert_matches_type(VerificationCreateResponse, verification, path=["response"])
Expand Down