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

from __future__ import annotations

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


@dataclass(slots=True)
class FlagUpdatedContextPreviousAttributeData:
    """The previous data attributes of the flag."""

    name: Optional[str] = None
    """The previous name of the flag."""
    description: Optional[str] = None
    """The previous description of the flag."""
    tags: Optional[List[str]] = None
    """The previous tags 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]
    ) -> "FlagUpdatedContextPreviousAttributeData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                name=data.get("name"),
                description=data.get("description"),
                tags=data.get("tags"),
                enabled=data.get("enabled"),
                default_value=data.get("default_value"),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("FlagUpdatedContextPreviousAttributeData", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        if self.name is not None:
            result["name"] = self.name
        if self.description is not None:
            result["description"] = self.description
        else:
            result["description"] = None
        if self.tags is not None:
            result["tags"] = self.tags
        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
