|
| 1 | +# !!! |
| 2 | +# WARNING: This file is autogenerated |
| 3 | +# Only modify code within MANUAL() sections |
| 4 | +# or your changes may be overwritten later! |
| 5 | +# !!! |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | + |
| 9 | +from typing import Any, Dict |
| 10 | + |
| 11 | +from stytch.consumer.models.fraud_email import RiskResponse |
| 12 | +from stytch.core.api_base import ApiBase |
| 13 | +from stytch.core.http.client import AsyncClient, SyncClient |
| 14 | + |
| 15 | + |
| 16 | +class Email: |
| 17 | + def __init__( |
| 18 | + self, api_base: ApiBase, sync_client: SyncClient, async_client: AsyncClient |
| 19 | + ) -> None: |
| 20 | + self.api_base = api_base |
| 21 | + self.sync_client = sync_client |
| 22 | + self.async_client = async_client |
| 23 | + |
| 24 | + def risk( |
| 25 | + self, |
| 26 | + email_address: str, |
| 27 | + ) -> RiskResponse: |
| 28 | + """Get risk information for a specific email address. |
| 29 | + The response will contain a recommended action (`ALLOW`, `BLOCK`, or `CHALLENGE`) and a more granular `risk_score`. |
| 30 | + You can also check the `address_information` and `domain_information` fields for more information about the email address and email domain. |
| 31 | +
|
| 32 | + This feature is in beta. Reach out to us [here](mailto:fraud-team@stytch.com?subject=Email_Intelligence_Early_Access) if you'd like to request early access. |
| 33 | +
|
| 34 | + Fields: |
| 35 | + - email_address: The email address to check. |
| 36 | + """ # noqa |
| 37 | + headers: Dict[str, str] = {} |
| 38 | + data: Dict[str, Any] = { |
| 39 | + "email_address": email_address, |
| 40 | + } |
| 41 | + |
| 42 | + url = self.api_base.url_for("/v1/email/risk", data) |
| 43 | + res = self.sync_client.post(url, data, headers) |
| 44 | + return RiskResponse.from_json(res.response.status_code, res.json) |
| 45 | + |
| 46 | + async def risk_async( |
| 47 | + self, |
| 48 | + email_address: str, |
| 49 | + ) -> RiskResponse: |
| 50 | + """Get risk information for a specific email address. |
| 51 | + The response will contain a recommended action (`ALLOW`, `BLOCK`, or `CHALLENGE`) and a more granular `risk_score`. |
| 52 | + You can also check the `address_information` and `domain_information` fields for more information about the email address and email domain. |
| 53 | +
|
| 54 | + This feature is in beta. Reach out to us [here](mailto:fraud-team@stytch.com?subject=Email_Intelligence_Early_Access) if you'd like to request early access. |
| 55 | +
|
| 56 | + Fields: |
| 57 | + - email_address: The email address to check. |
| 58 | + """ # noqa |
| 59 | + headers: Dict[str, str] = {} |
| 60 | + data: Dict[str, Any] = { |
| 61 | + "email_address": email_address, |
| 62 | + } |
| 63 | + |
| 64 | + url = self.api_base.url_for("/v1/email/risk", data) |
| 65 | + res = await self.async_client.post(url, data, headers) |
| 66 | + return RiskResponse.from_json(res.response.status, res.json) |
0 commit comments