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

from __future__ import annotations

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


@dataclass(slots=True)
class Actor:
    """The user or API key that performed an action."""

    id: str
    """Unique identifier of the actor."""
    name: str
    """Display name of the actor."""

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

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["id"] = self.id
        result["name"] = self.name
        return result
