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

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Dict, Literal
from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class RadarChallengeCreatedData:
    """The event payload."""

    type: Literal["email"]
    """The type of the Radar challenge."""
    radar_challenge_id: str
    """The ID of the Radar challenge."""
    user_id: str
    """The ID of the user."""
    email: str
    """The email address of the user."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "RadarChallengeCreatedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                type=data.get("type", "email"),
                radar_challenge_id=data["radar_challenge_id"],
                user_id=data["user_id"],
                email=data["email"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("RadarChallengeCreatedData", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["type"] = self.type
        result["radar_challenge_id"] = self.radar_challenge_id
        result["user_id"] = self.user_id
        result["email"] = self.email
        return result
