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

from __future__ import annotations

from dataclasses import dataclass
from typing import Any

from workos._types import _raise_deserialize_error


@dataclass(slots=True)
class AuthenticateResponseImpersonator:
    """Information about the impersonator if this session was created via impersonation."""

    email: str
    """The email address of the WorkOS Dashboard user who is impersonating the user."""
    reason: str | None
    """The justification the impersonator gave for impersonating the user."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> AuthenticateResponseImpersonator:
        """Deserialize from a dictionary."""
        try:
            return cls(
                email=data["email"],
                reason=data["reason"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AuthenticateResponseImpersonator", e)

    def to_dict(self) -> dict[str, Any]:
        """Serialize to a dictionary."""
        result: dict[str, Any] = {}
        result["email"] = self.email
        if self.reason is not None:
            result["reason"] = self.reason
        else:
            result["reason"] = None
        return result
