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

from __future__ import annotations

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


@dataclass(slots=True)
class UpdateUserOrganizationMembership:
    """Update User Organization Membership model."""

    role_slug: Optional[str] = None
    """A single role identifier. Defaults to `member` or the explicit default role. Mutually exclusive with `role_slugs`."""
    role_slugs: Optional[List[str]] = None
    """An array of role identifiers. Limited to one role when Multiple Roles is disabled. Mutually exclusive with `role_slug`."""

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

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