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

from __future__ import annotations

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


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

    object: Literal["password_reset"]
    """Distinguishes the password reset object."""
    id: str
    """The unique ID of the password reset object."""
    user_id: str
    """The unique ID of the user."""
    email: str
    """The email address of the user."""
    expires_at: datetime
    """The timestamp when the password reset token expires."""
    created_at: datetime
    """The timestamp when the password reset token was created."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "PasswordResetCreatedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                object=data.get("object", "password_reset"),
                id=data["id"],
                user_id=data["user_id"],
                email=data["email"],
                expires_at=_parse_datetime(data["expires_at"]),
                created_at=_parse_datetime(data["created_at"]),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("PasswordResetCreatedData", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["object"] = self.object
        result["id"] = self.id
        result["user_id"] = self.user_id
        result["email"] = self.email
        result["expires_at"] = _format_datetime(self.expires_at)
        result["created_at"] = _format_datetime(self.created_at)
        return result
