# 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 FlagRuleUpdatedContextPreviousAttributeData:
    """The previous data attributes of the flag."""

    enabled: Optional[bool] = None
    """Whether the flag was previously enabled."""
    default_value: Optional[bool] = None
    """The previous default value of the flag."""

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

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