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

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict
from workos._types import _raise_deserialize_error
from workos.common.models.organization_domain_data_state import (
    OrganizationDomainDataState,
)


@dataclass(slots=True)
class OrganizationDomainData:
    """Organization Domain Data model."""

    domain: str
    """The domain value."""
    state: "OrganizationDomainDataState"
    """The verification state of the domain."""

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

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["domain"] = self.domain
        result["state"] = (
            self.state.value if isinstance(self.state, Enum) else self.state
        )
        return result
