"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from dataclasses import dataclass, field
from documenso_sdk.models import DocumensoError
from documenso_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from documenso_sdk.utils import get_discriminator
from enum import Enum
import httpx
import pydantic
from pydantic import Discriminator, Tag, model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class RecipientUpdateDocumentRecipientRoleRequest(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


class RecipientUpdateDocumentRecipientAccessAuthRequest(str, Enum):
    ACCOUNT = "ACCOUNT"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"


class RecipientUpdateDocumentRecipientActionAuthRequest(str, Enum):
    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    PASSWORD = "PASSWORD"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class RecipientUpdateDocumentRecipientRecipientTypedDict(TypedDict):
    id: float
    email: NotRequired[str]
    name: NotRequired[str]
    role: NotRequired[RecipientUpdateDocumentRecipientRoleRequest]
    signing_order: NotRequired[float]
    access_auth: NotRequired[List[RecipientUpdateDocumentRecipientAccessAuthRequest]]
    action_auth: NotRequired[List[RecipientUpdateDocumentRecipientActionAuthRequest]]


class RecipientUpdateDocumentRecipientRecipient(BaseModel):
    id: float

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateDocumentRecipientRoleRequest] = None

    signing_order: Annotated[Optional[float], pydantic.Field(alias="signingOrder")] = (
        None
    )

    access_auth: Annotated[
        Optional[List[RecipientUpdateDocumentRecipientAccessAuthRequest]],
        pydantic.Field(alias="accessAuth"),
    ] = None

    action_auth: Annotated[
        Optional[List[RecipientUpdateDocumentRecipientActionAuthRequest]],
        pydantic.Field(alias="actionAuth"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["email", "name", "role", "signingOrder", "accessAuth", "actionAuth"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientRequestTypedDict(TypedDict):
    document_id: float
    recipient: RecipientUpdateDocumentRecipientRecipientTypedDict


class RecipientUpdateDocumentRecipientRequest(BaseModel):
    document_id: Annotated[float, pydantic.Field(alias="documentId")]

    recipient: RecipientUpdateDocumentRecipientRecipient


class RecipientUpdateDocumentRecipientInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientInternalServerErrorIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientInternalServerErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[RecipientUpdateDocumentRecipientInternalServerErrorIssue]] = (
        None
    )


@dataclass(unsafe_hash=True)
class RecipientUpdateDocumentRecipientInternalServerError(DocumensoError):
    r"""Internal server error"""

    data: RecipientUpdateDocumentRecipientInternalServerErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientInternalServerErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class RecipientUpdateDocumentRecipientForbiddenIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientForbiddenIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientForbiddenErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[RecipientUpdateDocumentRecipientForbiddenIssue]] = None


@dataclass(unsafe_hash=True)
class RecipientUpdateDocumentRecipientForbiddenError(DocumensoError):
    r"""Insufficient access"""

    data: RecipientUpdateDocumentRecipientForbiddenErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientForbiddenErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class RecipientUpdateDocumentRecipientUnauthorizedIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientUnauthorizedIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientUnauthorizedErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[RecipientUpdateDocumentRecipientUnauthorizedIssue]] = None


@dataclass(unsafe_hash=True)
class RecipientUpdateDocumentRecipientUnauthorizedError(DocumensoError):
    r"""Authorization not provided"""

    data: RecipientUpdateDocumentRecipientUnauthorizedErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientUnauthorizedErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class RecipientUpdateDocumentRecipientBadRequestIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientBadRequestIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientBadRequestErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[RecipientUpdateDocumentRecipientBadRequestIssue]] = None


@dataclass(unsafe_hash=True)
class RecipientUpdateDocumentRecipientBadRequestError(DocumensoError):
    r"""Invalid input data"""

    data: RecipientUpdateDocumentRecipientBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientBadRequestErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class RecipientUpdateDocumentRecipientRoleResponse(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


class RecipientUpdateDocumentRecipientReadStatus(str, Enum):
    NOT_OPENED = "NOT_OPENED"
    OPENED = "OPENED"


class RecipientUpdateDocumentRecipientSigningStatus(str, Enum):
    NOT_SIGNED = "NOT_SIGNED"
    SIGNED = "SIGNED"
    REJECTED = "REJECTED"


class RecipientUpdateDocumentRecipientSendStatus(str, Enum):
    NOT_SENT = "NOT_SENT"
    SENT = "SENT"


class RecipientUpdateDocumentRecipientAuthOptionsAccessAuth(str, Enum):
    ACCOUNT = "ACCOUNT"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"


class RecipientUpdateDocumentRecipientAuthOptionsActionAuth(str, Enum):
    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    PASSWORD = "PASSWORD"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class RecipientUpdateDocumentRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[RecipientUpdateDocumentRecipientAuthOptionsAccessAuth]
    action_auth: List[RecipientUpdateDocumentRecipientAuthOptionsActionAuth]


class RecipientUpdateDocumentRecipientAuthOptions(BaseModel):
    access_auth: Annotated[
        List[RecipientUpdateDocumentRecipientAuthOptionsAccessAuth],
        pydantic.Field(alias="accessAuth"),
    ]

    action_auth: Annotated[
        List[RecipientUpdateDocumentRecipientAuthOptionsActionAuth],
        pydantic.Field(alias="actionAuth"),
    ]


class RecipientUpdateDocumentRecipientType(str, Enum):
    SIGNATURE = "SIGNATURE"
    FREE_SIGNATURE = "FREE_SIGNATURE"
    INITIALS = "INITIALS"
    NAME = "NAME"
    EMAIL = "EMAIL"
    DATE = "DATE"
    TEXT = "TEXT"
    NUMBER = "NUMBER"
    RADIO = "RADIO"
    CHECKBOX = "CHECKBOX"
    DROPDOWN = "DROPDOWN"


class RecipientUpdateDocumentRecipientTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class RecipientUpdateDocumentRecipientValue3TypedDict(TypedDict):
    value: str


class RecipientUpdateDocumentRecipientValue3(BaseModel):
    value: str


class RecipientUpdateDocumentRecipientFieldMetaDropdownTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientValue3TypedDict]]
    default_value: NotRequired[str]


class RecipientUpdateDocumentRecipientFieldMetaDropdown(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeDropdown

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    values: Optional[List[RecipientUpdateDocumentRecipientValue3]] = None

    default_value: Annotated[Optional[str], pydantic.Field(alias="defaultValue")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "defaultValue",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeCheckbox(str, Enum):
    CHECKBOX = "checkbox"


class RecipientUpdateDocumentRecipientValue2TypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class RecipientUpdateDocumentRecipientValue2(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateDocumentRecipientDirection2(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class RecipientUpdateDocumentRecipientFieldMetaCheckboxTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[RecipientUpdateDocumentRecipientDirection2]


class RecipientUpdateDocumentRecipientFieldMetaCheckbox(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeCheckbox

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    values: Optional[List[RecipientUpdateDocumentRecipientValue2]] = None

    validation_rule: Annotated[
        Optional[str], pydantic.Field(alias="validationRule")
    ] = None

    validation_length: Annotated[
        Optional[float], pydantic.Field(alias="validationLength")
    ] = None

    direction: Optional[RecipientUpdateDocumentRecipientDirection2] = (
        RecipientUpdateDocumentRecipientDirection2.VERTICAL
    )

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "validationRule",
                "validationLength",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeRadio(str, Enum):
    RADIO = "radio"


class RecipientUpdateDocumentRecipientValue1TypedDict(TypedDict):
    id: float
    checked: bool
    value: str


class RecipientUpdateDocumentRecipientValue1(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateDocumentRecipientDirection1(str, Enum):
    VERTICAL = "vertical"
    HORIZONTAL = "horizontal"


class RecipientUpdateDocumentRecipientFieldMetaRadioTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientValue1TypedDict]]
    direction: NotRequired[RecipientUpdateDocumentRecipientDirection1]


class RecipientUpdateDocumentRecipientFieldMetaRadio(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeRadio

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    values: Optional[List[RecipientUpdateDocumentRecipientValue1]] = None

    direction: Optional[RecipientUpdateDocumentRecipientDirection1] = (
        RecipientUpdateDocumentRecipientDirection1.VERTICAL
    )

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeNumber(str, Enum):
    NUMBER = "number"


class RecipientUpdateDocumentRecipientTextAlign6(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientVerticalAlign2(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class RecipientUpdateDocumentRecipientFieldMetaNumberTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeNumber
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    number_format: NotRequired[Nullable[str]]
    value: NotRequired[str]
    min_value: NotRequired[Nullable[float]]
    max_value: NotRequired[Nullable[float]]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateDocumentRecipientVerticalAlign2]
    ]


class RecipientUpdateDocumentRecipientFieldMetaNumber(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeNumber

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    number_format: Annotated[
        OptionalNullable[str], pydantic.Field(alias="numberFormat")
    ] = UNSET

    value: Optional[str] = None

    min_value: Annotated[OptionalNullable[float], pydantic.Field(alias="minValue")] = (
        UNSET
    )

    max_value: Annotated[OptionalNullable[float], pydantic.Field(alias="maxValue")] = (
        UNSET
    )

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign6],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[RecipientUpdateDocumentRecipientVerticalAlign2],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "numberFormat",
                "value",
                "minValue",
                "maxValue",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(
            [
                "numberFormat",
                "minValue",
                "maxValue",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeText(str, Enum):
    TEXT = "text"


class RecipientUpdateDocumentRecipientTextAlign5(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientVerticalAlign1(str, Enum):
    TOP = "top"
    MIDDLE = "middle"
    BOTTOM = "bottom"


class RecipientUpdateDocumentRecipientFieldMetaTextTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeText
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateDocumentRecipientVerticalAlign1]
    ]


class RecipientUpdateDocumentRecipientFieldMetaText(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeText

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    text: Optional[str] = None

    character_limit: Annotated[
        Optional[float], pydantic.Field(alias="characterLimit")
    ] = None

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign5],
        pydantic.Field(alias="textAlign"),
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[RecipientUpdateDocumentRecipientVerticalAlign1],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "text",
                "characterLimit",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(["lineHeight", "letterSpacing", "verticalAlign"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeDate(str, Enum):
    DATE = "date"


class RecipientUpdateDocumentRecipientTextAlign4(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientFieldMetaDateTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign4]


class RecipientUpdateDocumentRecipientFieldMetaDate(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeDate

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign4],
        pydantic.Field(alias="textAlign"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeEmail(str, Enum):
    EMAIL = "email"


class RecipientUpdateDocumentRecipientTextAlign3(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientFieldMetaEmailTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign3]


class RecipientUpdateDocumentRecipientFieldMetaEmail(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeEmail

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign3],
        pydantic.Field(alias="textAlign"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeName(str, Enum):
    NAME = "name"


class RecipientUpdateDocumentRecipientTextAlign2(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientFieldMetaNameTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign2]


class RecipientUpdateDocumentRecipientFieldMetaName(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeName

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign2],
        pydantic.Field(alias="textAlign"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeInitials(str, Enum):
    INITIALS = "initials"


class RecipientUpdateDocumentRecipientTextAlign1(str, Enum):
    LEFT = "left"
    CENTER = "center"
    RIGHT = "right"


class RecipientUpdateDocumentRecipientFieldMetaInitialsTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientTextAlign1]


class RecipientUpdateDocumentRecipientFieldMetaInitials(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeInitials

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    text_align: Annotated[
        Optional[RecipientUpdateDocumentRecipientTextAlign1],
        pydantic.Field(alias="textAlign"),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientTypeSignature(str, Enum):
    SIGNATURE = "signature"


class RecipientUpdateDocumentRecipientFieldMetaSignatureTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientTypeSignature
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]


class RecipientUpdateDocumentRecipientFieldMetaSignature(BaseModel):
    type: RecipientUpdateDocumentRecipientTypeSignature

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    font_size: Annotated[Optional[float], pydantic.Field(alias="fontSize")] = 12

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


RecipientUpdateDocumentRecipientFieldMetaUnionTypedDict = TypeAliasType(
    "RecipientUpdateDocumentRecipientFieldMetaUnionTypedDict",
    Union[
        RecipientUpdateDocumentRecipientFieldMetaSignatureTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaInitialsTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaNameTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaEmailTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaDateTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaRadioTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaDropdownTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaCheckboxTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaTextTypedDict,
        RecipientUpdateDocumentRecipientFieldMetaNumberTypedDict,
    ],
)


RecipientUpdateDocumentRecipientFieldMetaUnion = Annotated[
    Union[
        Annotated[RecipientUpdateDocumentRecipientFieldMetaSignature, Tag("signature")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaInitials, Tag("initials")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaName, Tag("name")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaEmail, Tag("email")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaDate, Tag("date")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaText, Tag("text")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaNumber, Tag("number")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaRadio, Tag("radio")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaCheckbox, Tag("checkbox")],
        Annotated[RecipientUpdateDocumentRecipientFieldMetaDropdown, Tag("dropdown")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


class RecipientUpdateDocumentRecipientFieldTypedDict(TypedDict):
    envelope_id: str
    envelope_item_id: str
    type: RecipientUpdateDocumentRecipientType
    id: float
    secondary_id: str
    recipient_id: float
    page: float
    position_x: Any
    position_y: Any
    width: Any
    height: Any
    custom_text: str
    inserted: bool
    field_meta: Nullable[RecipientUpdateDocumentRecipientFieldMetaUnionTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


class RecipientUpdateDocumentRecipientField(BaseModel):
    envelope_id: Annotated[str, pydantic.Field(alias="envelopeId")]

    envelope_item_id: Annotated[str, pydantic.Field(alias="envelopeItemId")]

    type: RecipientUpdateDocumentRecipientType

    id: float

    secondary_id: Annotated[str, pydantic.Field(alias="secondaryId")]

    recipient_id: Annotated[float, pydantic.Field(alias="recipientId")]

    page: float

    position_x: Annotated[Any, pydantic.Field(alias="positionX")]

    position_y: Annotated[Any, pydantic.Field(alias="positionY")]

    width: Any

    height: Any

    custom_text: Annotated[str, pydantic.Field(alias="customText")]

    inserted: bool

    field_meta: Annotated[
        Nullable[RecipientUpdateDocumentRecipientFieldMetaUnion],
        pydantic.Field(alias="fieldMeta"),
    ]

    document_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="documentId")
    ] = UNSET

    template_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="templateId")
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["documentId", "templateId"])
        nullable_fields = set(["fieldMeta", "documentId", "templateId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class RecipientUpdateDocumentRecipientResponseTypedDict(TypedDict):
    r"""Successful response"""

    envelope_id: str
    role: RecipientUpdateDocumentRecipientRoleResponse
    read_status: RecipientUpdateDocumentRecipientReadStatus
    signing_status: RecipientUpdateDocumentRecipientSigningStatus
    send_status: RecipientUpdateDocumentRecipientSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientUpdateDocumentRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    fields: List[RecipientUpdateDocumentRecipientFieldTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


class RecipientUpdateDocumentRecipientResponse(BaseModel):
    r"""Successful response"""

    envelope_id: Annotated[str, pydantic.Field(alias="envelopeId")]

    role: RecipientUpdateDocumentRecipientRoleResponse

    read_status: Annotated[
        RecipientUpdateDocumentRecipientReadStatus, pydantic.Field(alias="readStatus")
    ]

    signing_status: Annotated[
        RecipientUpdateDocumentRecipientSigningStatus,
        pydantic.Field(alias="signingStatus"),
    ]

    send_status: Annotated[
        RecipientUpdateDocumentRecipientSendStatus, pydantic.Field(alias="sendStatus")
    ]

    id: float

    email: str

    name: str

    token: str

    document_deleted_at: Annotated[
        Nullable[str], pydantic.Field(alias="documentDeletedAt")
    ]

    expired: Nullable[str]

    signed_at: Annotated[Nullable[str], pydantic.Field(alias="signedAt")]

    auth_options: Annotated[
        Nullable[RecipientUpdateDocumentRecipientAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

    signing_order: Annotated[Nullable[float], pydantic.Field(alias="signingOrder")]

    rejection_reason: Annotated[Nullable[str], pydantic.Field(alias="rejectionReason")]

    fields: List[RecipientUpdateDocumentRecipientField]

    document_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="documentId")
    ] = UNSET

    template_id: Annotated[
        OptionalNullable[float], pydantic.Field(alias="templateId")
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["documentId", "templateId"])
        nullable_fields = set(
            [
                "documentDeletedAt",
                "expired",
                "signedAt",
                "authOptions",
                "signingOrder",
                "rejectionReason",
                "documentId",
                "templateId",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m
