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

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Literal, cast

from workos._types import _raise_deserialize_error

from .email_change_confirmation_user import EmailChangeConfirmationUser


@dataclass(slots=True)
class EmailChangeConfirmation:
    """Email Change Confirmation model."""

    object: Literal["email_change_confirmation"]
    """Distinguishes the email change confirmation object."""
    user: EmailChangeConfirmationUser
    """The user object."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> EmailChangeConfirmation:
        """Deserialize from a dictionary."""
        try:
            return cls(
                object=data.get("object", "email_change_confirmation"),
                user=EmailChangeConfirmationUser.from_dict(
                    cast(dict[str, Any], data["user"])
                ),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("EmailChangeConfirmation", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        result["object"] = self.object
        result["user"] = self.user.to_dict()
        return result
