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

from __future__ import annotations

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


@dataclass(slots=True)
class UpdateObjectRequest:
    """Update Object Request model."""

    value: str
    """New plaintext value."""
    version_check: Optional[str] = None
    """ID of the expected current version for optimistic locking."""

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

    def to_dict(self) -> Dict[str, Any]:
        """Serialize to a dictionary."""
        result: Dict[str, Any] = {}
        result["value"] = self.value
        if self.version_check is not None:
            result["version_check"] = self.version_check
        else:
            result["version_check"] = None
        return result
