# 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, List
from workos._types import _raise_deserialize_error

from .claim_view_response_organization import ClaimViewResponseOrganization
from workos.common.models.claim_view_response_status import ClaimViewResponseStatus


@dataclass(slots=True)
class ClaimViewResponse:
    """Claim View Response model."""

    id: str
    """The agent registration ID."""
    status: "ClaimViewResponseStatus"
    """Current status of the agent registration."""
    user_code: str
    """The user code the agent needs to complete the claim."""
    organizations: List["ClaimViewResponseOrganization"]
    """Organizations the user belongs to, offered as placement choices."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "ClaimViewResponse":
        """Deserialize from a dictionary."""
        try:
            return cls(
                id=data["id"],
                status=ClaimViewResponseStatus(data["status"]),
                user_code=data["user_code"],
                organizations=[
                    ClaimViewResponseOrganization.from_dict(cast(Dict[str, Any], item))
                    for item in cast(list[Any], data["organizations"])
                ],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("ClaimViewResponse", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["id"] = self.id
        result["status"] = (
            self.status.value if isinstance(self.status, Enum) else self.status
        )
        result["user_code"] = self.user_code
        result["organizations"] = [item.to_dict() for item in self.organizations]
        return result
