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

from __future__ import annotations

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


@dataclass(slots=True)
class AuthenticationFactorTotp:
    """TOTP-based authentication factor details."""

    issuer: str
    """Your application or company name displayed in the user's authenticator app. Defaults to your WorkOS team name."""
    user: str
    """The user's account name displayed in their authenticator app. Defaults to the user's email."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AuthenticationFactorTotp":
        """Deserialize from a dictionary."""
        try:
            return cls(
                issuer=data["issuer"],
                user=data["user"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AuthenticationFactorTotp", e)

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