# 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 Any

from workos._types import _raise_deserialize_error
from workos.common.models.resend_user_invite_options_locale import (
    ResendUserInviteOptionsLocale,
)


@dataclass(slots=True)
class ResendUserInviteOptions:
    """Resend User Invite Options model."""

    locale: ResendUserInviteOptionsLocale | None = None
    """The locale to use when rendering the invitation email. See [supported locales](https://workos.com/docs/authkit/hosted-ui/localization)."""

    @classmethod
    def from_dict(cls, data: dict[str, Any]) -> ResendUserInviteOptions:
        """Deserialize from a dictionary."""
        try:
            return cls(
                locale=ResendUserInviteOptionsLocale(_v_locale)
                if (_v_locale := data.get("locale")) is not None
                else None,
            )
        except (KeyError, ValueError) as e:
            _raise_deserialize_error("ResendUserInviteOptions", e)

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