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

from __future__ import annotations

from dataclasses import dataclass
from typing import cast
from typing import Any, Dict, Literal
from workos._types import _raise_deserialize_error

from .agent_registration_claim_completed_data_claimed_by import (
    AgentRegistrationClaimCompletedDataClaimedBy,
)


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

    object: Literal["agent_registration_claim"]
    """Distinguishes the agent registration claim object."""
    id: str
    """Unique identifier of the agent registration claim."""
    agent_registration_id: str
    """The ID of the agent registration."""
    completed_by_attempt_id: str
    """The ID of the claim attempt that completed the claim."""
    claimed_by: "AgentRegistrationClaimCompletedDataClaimedBy"
    """The user who completed the claim."""
    completed_at: str
    """The timestamp when the claim was completed."""
    created_at: str
    """The timestamp when the claim was created."""
    updated_at: str
    """The timestamp when the claim was last updated."""

    @classmethod
    def from_dict(cls, data: Dict[str, Any]) -> "AgentRegistrationClaimCompletedData":
        """Deserialize from a dictionary."""
        try:
            return cls(
                object=data.get("object", "agent_registration_claim"),
                id=data["id"],
                agent_registration_id=data["agent_registration_id"],
                completed_by_attempt_id=data["completed_by_attempt_id"],
                claimed_by=AgentRegistrationClaimCompletedDataClaimedBy.from_dict(
                    cast(Dict[str, Any], data["claimed_by"])
                ),
                completed_at=data["completed_at"],
                created_at=data["created_at"],
                updated_at=data["updated_at"],
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("AgentRegistrationClaimCompletedData", e)

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["object"] = self.object
        result["id"] = self.id
        result["agent_registration_id"] = self.agent_registration_id
        result["completed_by_attempt_id"] = self.completed_by_attempt_id
        result["claimed_by"] = self.claimed_by.to_dict()
        result["completed_at"] = self.completed_at
        result["created_at"] = self.created_at
        result["updated_at"] = self.updated_at
        return result
