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

from __future__ import annotations

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


@dataclass(slots=True)
class ChallengeAuthenticationFactor:
    """Challenge Authentication Factor model."""

    sms_template: Optional[str] = None
    """A custom template for the SMS message. Use the {{code}} placeholder to include the verification code."""

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

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