# 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 cast
from typing import Any, Dict
from workos._types import _raise_deserialize_error

from .organization_domain_verification_failed_data_organization_domain import (
    OrganizationDomainVerificationFailedDataOrganizationDomain,
)
from .organization_domain_verification_failed_data_reason import (
    OrganizationDomainVerificationFailedDataReason,
)


@dataclass(slots=True)
class OrganizationDomainVerificationFailedData:
    """The event payload."""

    reason: "OrganizationDomainVerificationFailedDataReason"
    """The reason the domain verification failed."""
    organization_domain: "OrganizationDomainVerificationFailedDataOrganizationDomain"
    """The organization domain that failed verification."""

    @classmethod
    def from_dict(
        cls, data: Dict[str, Any]
    ) -> "OrganizationDomainVerificationFailedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                reason=OrganizationDomainVerificationFailedDataReason(data["reason"]),
                organization_domain=OrganizationDomainVerificationFailedDataOrganizationDomain.from_dict(
                    cast(Dict[str, Any], data["organization_domain"])
                ),
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("OrganizationDomainVerificationFailedData", e)

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