"""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 enum import Enum
import httpx
import pydantic
from pydantic import model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


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


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


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


class RecipientUpdateDocumentRecipientsRecipientRequestTypedDict(TypedDict):
    id: float
    email: NotRequired[str]
    name: NotRequired[str]
    role: NotRequired[RecipientUpdateDocumentRecipientsRoleRequest]
    signing_order: NotRequired[float]
    access_auth: NotRequired[List[RecipientUpdateDocumentRecipientsAccessAuthRequest]]
    action_auth: NotRequired[List[RecipientUpdateDocumentRecipientsActionAuthRequest]]


class RecipientUpdateDocumentRecipientsRecipientRequest(BaseModel):
    id: float

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateDocumentRecipientsRoleRequest] = None

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

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

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


class RecipientUpdateDocumentRecipientsRequestTypedDict(TypedDict):
    document_id: float
    recipients: List[RecipientUpdateDocumentRecipientsRecipientRequestTypedDict]


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

    recipients: List[RecipientUpdateDocumentRecipientsRecipientRequest]


class RecipientUpdateDocumentRecipientsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsInternalServerErrorIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[
        List[RecipientUpdateDocumentRecipientsInternalServerErrorIssue]
    ] = None


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

    data: RecipientUpdateDocumentRecipientsInternalServerErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientsInternalServerErrorData,
        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 RecipientUpdateDocumentRecipientsForbiddenIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsForbiddenIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateDocumentRecipientsForbiddenIssue]] = None


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

    data: RecipientUpdateDocumentRecipientsForbiddenErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientsForbiddenErrorData,
        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 RecipientUpdateDocumentRecipientsUnauthorizedIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsUnauthorizedIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateDocumentRecipientsUnauthorizedIssue]] = None


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

    data: RecipientUpdateDocumentRecipientsUnauthorizedErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientsUnauthorizedErrorData,
        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 RecipientUpdateDocumentRecipientsBadRequestIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsBadRequestIssue(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateDocumentRecipientsBadRequestIssue]] = None


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

    data: RecipientUpdateDocumentRecipientsBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientUpdateDocumentRecipientsBadRequestErrorData,
        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 RecipientUpdateDocumentRecipientsRoleResponse(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


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


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


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


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


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


class RecipientUpdateDocumentRecipientsAuthOptionsTypedDict(TypedDict):
    access_auth: List[RecipientUpdateDocumentRecipientsAccessAuthResponse]
    action_auth: List[RecipientUpdateDocumentRecipientsActionAuthResponse]


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

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


class RecipientUpdateDocumentRecipientsType(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 RecipientUpdateDocumentRecipientsTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class RecipientUpdateDocumentRecipientsValue3TypedDict(TypedDict):
    value: str


class RecipientUpdateDocumentRecipientsValue3(BaseModel):
    value: str


class RecipientUpdateDocumentRecipientsFieldMetaDropdownTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientsValue3TypedDict]]
    default_value: NotRequired[str]


class RecipientUpdateDocumentRecipientsFieldMetaDropdown(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeDropdown

    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[RecipientUpdateDocumentRecipientsValue3]] = None

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


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


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


class RecipientUpdateDocumentRecipientsValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientUpdateDocumentRecipientsFieldMetaCheckboxTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientsValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[RecipientUpdateDocumentRecipientsDirection2]


class RecipientUpdateDocumentRecipientsFieldMetaCheckbox(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeCheckbox

    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[RecipientUpdateDocumentRecipientsValue2]] = None

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

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

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


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


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


class RecipientUpdateDocumentRecipientsValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientUpdateDocumentRecipientsFieldMetaRadioTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateDocumentRecipientsValue1TypedDict]]
    direction: NotRequired[RecipientUpdateDocumentRecipientsDirection1]


class RecipientUpdateDocumentRecipientsFieldMetaRadio(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeRadio

    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[RecipientUpdateDocumentRecipientsValue1]] = None

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


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


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


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


class RecipientUpdateDocumentRecipientsFieldMetaNumberTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeNumber
    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[RecipientUpdateDocumentRecipientsTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateDocumentRecipientsVerticalAlign2]
    ]


class RecipientUpdateDocumentRecipientsFieldMetaNumber(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeNumber

    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[RecipientUpdateDocumentRecipientsTextAlign6],
        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[RecipientUpdateDocumentRecipientsVerticalAlign2],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

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

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


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


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


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


class RecipientUpdateDocumentRecipientsFieldMetaTextTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeText
    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[RecipientUpdateDocumentRecipientsTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateDocumentRecipientsVerticalAlign1]
    ]


class RecipientUpdateDocumentRecipientsFieldMetaText(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeText

    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[RecipientUpdateDocumentRecipientsTextAlign5],
        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[RecipientUpdateDocumentRecipientsVerticalAlign1],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

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

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


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


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


class RecipientUpdateDocumentRecipientsFieldMetaDateTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientsTextAlign4]


class RecipientUpdateDocumentRecipientsFieldMetaDate(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeDate

    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[RecipientUpdateDocumentRecipientsTextAlign4],
        pydantic.Field(alias="textAlign"),
    ] = None


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


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


class RecipientUpdateDocumentRecipientsFieldMetaEmailTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientsTextAlign3]


class RecipientUpdateDocumentRecipientsFieldMetaEmail(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeEmail

    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[RecipientUpdateDocumentRecipientsTextAlign3],
        pydantic.Field(alias="textAlign"),
    ] = None


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


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


class RecipientUpdateDocumentRecipientsFieldMetaNameTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientsTextAlign2]


class RecipientUpdateDocumentRecipientsFieldMetaName(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeName

    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[RecipientUpdateDocumentRecipientsTextAlign2],
        pydantic.Field(alias="textAlign"),
    ] = None


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


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


class RecipientUpdateDocumentRecipientsFieldMetaInitialsTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateDocumentRecipientsTextAlign1]


class RecipientUpdateDocumentRecipientsFieldMetaInitials(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeInitials

    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[RecipientUpdateDocumentRecipientsTextAlign1],
        pydantic.Field(alias="textAlign"),
    ] = None


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


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


class RecipientUpdateDocumentRecipientsFieldMetaSignature(BaseModel):
    type: RecipientUpdateDocumentRecipientsTypeSignature

    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


RecipientUpdateDocumentRecipientsFieldMetaUnionTypedDict = TypeAliasType(
    "RecipientUpdateDocumentRecipientsFieldMetaUnionTypedDict",
    Union[
        RecipientUpdateDocumentRecipientsFieldMetaSignatureTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaInitialsTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaNameTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaEmailTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaDateTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaRadioTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaDropdownTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaCheckboxTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaTextTypedDict,
        RecipientUpdateDocumentRecipientsFieldMetaNumberTypedDict,
    ],
)


RecipientUpdateDocumentRecipientsFieldMetaUnion = TypeAliasType(
    "RecipientUpdateDocumentRecipientsFieldMetaUnion",
    Union[
        RecipientUpdateDocumentRecipientsFieldMetaSignature,
        RecipientUpdateDocumentRecipientsFieldMetaInitials,
        RecipientUpdateDocumentRecipientsFieldMetaName,
        RecipientUpdateDocumentRecipientsFieldMetaEmail,
        RecipientUpdateDocumentRecipientsFieldMetaDate,
        RecipientUpdateDocumentRecipientsFieldMetaRadio,
        RecipientUpdateDocumentRecipientsFieldMetaDropdown,
        RecipientUpdateDocumentRecipientsFieldMetaCheckbox,
        RecipientUpdateDocumentRecipientsFieldMetaText,
        RecipientUpdateDocumentRecipientsFieldMetaNumber,
    ],
)


class RecipientUpdateDocumentRecipientsFieldTypedDict(TypedDict):
    envelope_id: str
    envelope_item_id: str
    type: RecipientUpdateDocumentRecipientsType
    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[RecipientUpdateDocumentRecipientsFieldMetaUnionTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

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

    type: RecipientUpdateDocumentRecipientsType

    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[RecipientUpdateDocumentRecipientsFieldMetaUnion],
        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 = ["documentId", "templateId"]
        nullable_fields = ["fieldMeta", "documentId", "templateId"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class RecipientUpdateDocumentRecipientsRecipientResponseTypedDict(TypedDict):
    envelope_id: str
    role: RecipientUpdateDocumentRecipientsRoleResponse
    read_status: RecipientUpdateDocumentRecipientsReadStatus
    signing_status: RecipientUpdateDocumentRecipientsSigningStatus
    send_status: RecipientUpdateDocumentRecipientsSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientUpdateDocumentRecipientsAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    fields: List[RecipientUpdateDocumentRecipientsFieldTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: RecipientUpdateDocumentRecipientsRoleResponse

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

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

    send_status: Annotated[
        RecipientUpdateDocumentRecipientsSendStatus, 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[RecipientUpdateDocumentRecipientsAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

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

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

    fields: List[RecipientUpdateDocumentRecipientsField]

    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 = ["documentId", "templateId"]
        nullable_fields = [
            "documentDeletedAt",
            "expired",
            "signedAt",
            "authOptions",
            "signingOrder",
            "rejectionReason",
            "documentId",
            "templateId",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


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

    recipients: List[RecipientUpdateDocumentRecipientsRecipientResponseTypedDict]


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

    recipients: List[RecipientUpdateDocumentRecipientsRecipientResponse]
