# !!!
# WARNING: This file is autogenerated
# Only modify code within MANUAL() sections
# or your changes may be overwritten later!
# !!!

from __future__ import annotations

from typing import Any, Dict

from stytch.consumer.models.fraud_email import RiskResponse
from stytch.core.api_base import ApiBase
from stytch.core.http.client import AsyncClient, SyncClient


class Email:
    def __init__(
        self, api_base: ApiBase, sync_client: SyncClient, async_client: AsyncClient
    ) -> None:
        self.api_base = api_base
        self.sync_client = sync_client
        self.async_client = async_client

    def risk(
        self,
        email_address: str,
    ) -> RiskResponse:
        """Get risk information for a specific email address.
        The response will contain a recommended action (`ALLOW`, `BLOCK`, or `CHALLENGE`) and a more granular `risk_score`.
        You can also check the `address_information` and `domain_information` fields for more information about the email address and email domain.

        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.

        Fields:
          - email_address: The email address to check.
        """  # noqa
        headers: Dict[str, str] = {}
        data: Dict[str, Any] = {
            "email_address": email_address,
        }

        url = self.api_base.url_for("/v1/email/risk", data)
        res = self.sync_client.post(url, data, headers)
        return RiskResponse.from_json(res.response.status_code, res.json)

    async def risk_async(
        self,
        email_address: str,
    ) -> RiskResponse:
        """Get risk information for a specific email address.
        The response will contain a recommended action (`ALLOW`, `BLOCK`, or `CHALLENGE`) and a more granular `risk_score`.
        You can also check the `address_information` and `domain_information` fields for more information about the email address and email domain.

        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.

        Fields:
          - email_address: The email address to check.
        """  # noqa
        headers: Dict[str, str] = {}
        data: Dict[str, Any] = {
            "email_address": email_address,
        }

        url = self.api_base.url_for("/v1/email/risk", data)
        res = await self.async_client.post(url, data, headers)
        return RiskResponse.from_json(res.response.status, res.json)
