# This file is auto-generated by oagen. Do not edit.

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional
from workos._types import _raise_deserialize_error
from workos.common.models.radar_standalone_assess_request_action import (
    RadarStandaloneAssessRequestAction,
)
from workos.common.models.radar_standalone_assess_request_auth_method import (
    RadarStandaloneAssessRequestAuthMethod,
)


@dataclass(slots=True)
class RadarStandaloneAssessRequest:
    """Radar Standalone Assess Request model."""

    ip_address: str
    """The IP address of the request to assess."""
    user_agent: str
    """The user agent string of the request to assess."""
    email: str
    """The email address of the user making the request."""
    auth_method: "RadarStandaloneAssessRequestAuthMethod"
    """The authentication method being used."""
    action: "RadarStandaloneAssessRequestAction"
    """The action being performed."""
    signals_id: Optional[str] = None
    """An optional Radar signals ID for the request."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "RadarStandaloneAssessRequest":
        """Deserialize from a dictionary."""
        try:
            return cls(
                ip_address=data["ip_address"],
                user_agent=data["user_agent"],
                email=data["email"],
                auth_method=RadarStandaloneAssessRequestAuthMethod(data["auth_method"]),
                action=RadarStandaloneAssessRequestAction(data["action"]),
                signals_id=data.get("signals_id"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("RadarStandaloneAssessRequest", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["ip_address"] = self.ip_address
        result["user_agent"] = self.user_agent
        result["email"] = self.email
        result["auth_method"] = (
            self.auth_method.value
            if isinstance(self.auth_method, Enum)
            else self.auth_method
        )
        result["action"] = (
            self.action.value if isinstance(self.action, Enum) else self.action
        )
        if self.signals_id is not None:
            result["signals_id"] = self.signals_id
        return result
