"""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, Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class TypeTemplateID(str, Enum):
    TEMPLATE_ID = "templateId"


class IdsTemplateIDTypedDict(TypedDict):
    type: TypeTemplateID
    ids: List[float]


class IdsTemplateID(BaseModel):
    type: TypeTemplateID

    ids: List[float]


class TypeDocumentID(str, Enum):
    DOCUMENT_ID = "documentId"


class IdsDocumentIDTypedDict(TypedDict):
    type: TypeDocumentID
    ids: List[float]


class IdsDocumentID(BaseModel):
    type: TypeDocumentID

    ids: List[float]


class TypeEnvelopeID(str, Enum):
    ENVELOPE_ID = "envelopeId"


class IdsEnvelopeIDTypedDict(TypedDict):
    type: TypeEnvelopeID
    ids: List[str]


class IdsEnvelopeID(BaseModel):
    type: TypeEnvelopeID

    ids: List[str]


IdsTypedDict = TypeAliasType(
    "IdsTypedDict",
    Union[IdsEnvelopeIDTypedDict, IdsDocumentIDTypedDict, IdsTemplateIDTypedDict],
)


Ids = Annotated[
    Union[
        Annotated[IdsEnvelopeID, Tag("envelopeId")],
        Annotated[IdsDocumentID, Tag("documentId")],
        Annotated[IdsTemplateID, Tag("templateId")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


class EnvelopeGetManyRequestTypedDict(TypedDict):
    ids: IdsTypedDict


class EnvelopeGetManyRequest(BaseModel):
    ids: Ids


class EnvelopeGetManyInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class EnvelopeGetManyInternalServerErrorIssue(BaseModel):
    message: str


class EnvelopeGetManyInternalServerErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[EnvelopeGetManyInternalServerErrorIssue]] = None


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

    data: EnvelopeGetManyInternalServerErrorData = field(hash=False)

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


class EnvelopeGetManyForbiddenIssue(BaseModel):
    message: str


class EnvelopeGetManyForbiddenErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[EnvelopeGetManyForbiddenIssue]] = None


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

    data: EnvelopeGetManyForbiddenErrorData = field(hash=False)

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


class EnvelopeGetManyUnauthorizedIssue(BaseModel):
    message: str


class EnvelopeGetManyUnauthorizedErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[EnvelopeGetManyUnauthorizedIssue]] = None


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

    data: EnvelopeGetManyUnauthorizedErrorData = field(hash=False)

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


class EnvelopeGetManyBadRequestIssue(BaseModel):
    message: str


class EnvelopeGetManyBadRequestErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[EnvelopeGetManyBadRequestIssue]] = None


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

    data: EnvelopeGetManyBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: EnvelopeGetManyBadRequestErrorData,
        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 EnvelopeGetManyDataType(str, Enum):
    DOCUMENT = "DOCUMENT"
    TEMPLATE = "TEMPLATE"


class EnvelopeGetManyStatus(str, Enum):
    DRAFT = "DRAFT"
    PENDING = "PENDING"
    COMPLETED = "COMPLETED"
    REJECTED = "REJECTED"


class EnvelopeGetManySource(str, Enum):
    DOCUMENT = "DOCUMENT"
    TEMPLATE = "TEMPLATE"
    TEMPLATE_DIRECT_LINK = "TEMPLATE_DIRECT_LINK"


class EnvelopeGetManyVisibility(str, Enum):
    EVERYONE = "EVERYONE"
    MANAGER_AND_ABOVE = "MANAGER_AND_ABOVE"
    ADMIN = "ADMIN"


class EnvelopeGetManyTemplateType(str, Enum):
    PUBLIC = "PUBLIC"
    PRIVATE = "PRIVATE"


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


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


class EnvelopeGetManyAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[EnvelopeGetManyGlobalAccessAuth]
    global_action_auth: List[EnvelopeGetManyGlobalActionAuth]


class EnvelopeGetManyAuthOptions(BaseModel):
    global_access_auth: Annotated[
        List[EnvelopeGetManyGlobalAccessAuth], pydantic.Field(alias="globalAccessAuth")
    ]

    global_action_auth: Annotated[
        List[EnvelopeGetManyGlobalActionAuth], pydantic.Field(alias="globalActionAuth")
    ]


EnvelopeGetManyFormValuesTypedDict = TypeAliasType(
    "EnvelopeGetManyFormValuesTypedDict", Union[str, bool, float]
)


EnvelopeGetManyFormValues = TypeAliasType(
    "EnvelopeGetManyFormValues", Union[str, bool, float]
)


class EnvelopeGetManySigningOrder(str, Enum):
    PARALLEL = "PARALLEL"
    SEQUENTIAL = "SEQUENTIAL"


class EnvelopeGetManyDistributionMethod(str, Enum):
    EMAIL = "EMAIL"
    NONE = "NONE"


class EnvelopeGetManyEmailSettingsTypedDict(TypedDict):
    recipient_signing_request: NotRequired[bool]
    recipient_removed: NotRequired[bool]
    recipient_signed: NotRequired[bool]
    document_pending: NotRequired[bool]
    document_completed: NotRequired[bool]
    document_deleted: NotRequired[bool]
    owner_document_completed: NotRequired[bool]


class EnvelopeGetManyEmailSettings(BaseModel):
    recipient_signing_request: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigningRequest")
    ] = True

    recipient_removed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientRemoved")
    ] = True

    recipient_signed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigned")
    ] = True

    document_pending: Annotated[
        Optional[bool], pydantic.Field(alias="documentPending")
    ] = True

    document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="documentCompleted")
    ] = True

    document_deleted: Annotated[
        Optional[bool], pydantic.Field(alias="documentDeleted")
    ] = True

    owner_document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="ownerDocumentCompleted")
    ] = True

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "recipientSigningRequest",
                "recipientRemoved",
                "recipientSigned",
                "documentPending",
                "documentCompleted",
                "documentDeleted",
                "ownerDocumentCompleted",
            ]
        )
        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 EnvelopeGetManyDocumentMetaTypedDict(TypedDict):
    signing_order: EnvelopeGetManySigningOrder
    distribution_method: EnvelopeGetManyDistributionMethod
    id: str
    subject: Nullable[str]
    message: Nullable[str]
    timezone: Nullable[str]
    date_format: Nullable[str]
    redirect_url: Nullable[str]
    typed_signature_enabled: bool
    upload_signature_enabled: bool
    draw_signature_enabled: bool
    allow_dictate_next_signer: bool
    language: str
    email_settings: Nullable[EnvelopeGetManyEmailSettingsTypedDict]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]


class EnvelopeGetManyDocumentMeta(BaseModel):
    signing_order: Annotated[
        EnvelopeGetManySigningOrder, pydantic.Field(alias="signingOrder")
    ]

    distribution_method: Annotated[
        EnvelopeGetManyDistributionMethod, pydantic.Field(alias="distributionMethod")
    ]

    id: str

    subject: Nullable[str]

    message: Nullable[str]

    timezone: Nullable[str]

    date_format: Annotated[Nullable[str], pydantic.Field(alias="dateFormat")]

    redirect_url: Annotated[Nullable[str], pydantic.Field(alias="redirectUrl")]

    typed_signature_enabled: Annotated[
        bool, pydantic.Field(alias="typedSignatureEnabled")
    ]

    upload_signature_enabled: Annotated[
        bool, pydantic.Field(alias="uploadSignatureEnabled")
    ]

    draw_signature_enabled: Annotated[
        bool, pydantic.Field(alias="drawSignatureEnabled")
    ]

    allow_dictate_next_signer: Annotated[
        bool, pydantic.Field(alias="allowDictateNextSigner")
    ]

    language: str

    email_settings: Annotated[
        Nullable[EnvelopeGetManyEmailSettings], pydantic.Field(alias="emailSettings")
    ]

    email_id: Annotated[Nullable[str], pydantic.Field(alias="emailId")]

    email_reply_to: Annotated[Nullable[str], pydantic.Field(alias="emailReplyTo")]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


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


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


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


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


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


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


class EnvelopeGetManyRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[EnvelopeGetManyAccessAuth]
    action_auth: List[EnvelopeGetManyActionAuth]


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

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


class EnvelopeGetManyRecipientTypedDict(TypedDict):
    envelope_id: str
    role: EnvelopeGetManyRole
    read_status: EnvelopeGetManyReadStatus
    signing_status: EnvelopeGetManySigningStatus
    send_status: EnvelopeGetManySendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[EnvelopeGetManyRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]


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

    role: EnvelopeGetManyRole

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

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

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

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


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


class EnvelopeGetManyValue3TypedDict(TypedDict):
    value: str


class EnvelopeGetManyValue3(BaseModel):
    value: str


class EnvelopeGetManyFieldMetaDropdownTypedDict(TypedDict):
    type: EnvelopeGetManyTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetManyValue3TypedDict]]
    default_value: NotRequired[str]


class EnvelopeGetManyFieldMetaDropdown(BaseModel):
    type: EnvelopeGetManyTypeDropdown

    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[EnvelopeGetManyValue3]] = 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 EnvelopeGetManyTypeCheckbox(str, Enum):
    CHECKBOX = "checkbox"


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


class EnvelopeGetManyValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeGetManyFieldMetaCheckboxTypedDict(TypedDict):
    type: EnvelopeGetManyTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetManyValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[EnvelopeGetManyDirection2]


class EnvelopeGetManyFieldMetaCheckbox(BaseModel):
    type: EnvelopeGetManyTypeCheckbox

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

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

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

    direction: Optional[EnvelopeGetManyDirection2] = EnvelopeGetManyDirection2.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 EnvelopeGetManyTypeRadio(str, Enum):
    RADIO = "radio"


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


class EnvelopeGetManyValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeGetManyFieldMetaRadioTypedDict(TypedDict):
    type: EnvelopeGetManyTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetManyValue1TypedDict]]
    direction: NotRequired[EnvelopeGetManyDirection1]


class EnvelopeGetManyFieldMetaRadio(BaseModel):
    type: EnvelopeGetManyTypeRadio

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

    direction: Optional[EnvelopeGetManyDirection1] = EnvelopeGetManyDirection1.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 EnvelopeGetManyTypeNumber(str, Enum):
    NUMBER = "number"


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


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


class EnvelopeGetManyFieldMetaNumberTypedDict(TypedDict):
    type: EnvelopeGetManyTypeNumber
    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[EnvelopeGetManyTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeGetManyVerticalAlign2]]


class EnvelopeGetManyFieldMetaNumber(BaseModel):
    type: EnvelopeGetManyTypeNumber

    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[EnvelopeGetManyTextAlign6], 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[EnvelopeGetManyVerticalAlign2],
        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 EnvelopeGetManyTypeText(str, Enum):
    TEXT = "text"


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


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


class EnvelopeGetManyFieldMetaTextTypedDict(TypedDict):
    type: EnvelopeGetManyTypeText
    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[EnvelopeGetManyTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeGetManyVerticalAlign1]]


class EnvelopeGetManyFieldMetaText(BaseModel):
    type: EnvelopeGetManyTypeText

    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[EnvelopeGetManyTextAlign5], 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[EnvelopeGetManyVerticalAlign1],
        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 EnvelopeGetManyTypeDate(str, Enum):
    DATE = "date"


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


class EnvelopeGetManyFieldMetaDateTypedDict(TypedDict):
    type: EnvelopeGetManyTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetManyTextAlign4]


class EnvelopeGetManyFieldMetaDate(BaseModel):
    type: EnvelopeGetManyTypeDate

    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[EnvelopeGetManyTextAlign4], 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 EnvelopeGetManyTypeEmail(str, Enum):
    EMAIL = "email"


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


class EnvelopeGetManyFieldMetaEmailTypedDict(TypedDict):
    type: EnvelopeGetManyTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetManyTextAlign3]


class EnvelopeGetManyFieldMetaEmail(BaseModel):
    type: EnvelopeGetManyTypeEmail

    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[EnvelopeGetManyTextAlign3], 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 EnvelopeGetManyTypeName(str, Enum):
    NAME = "name"


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


class EnvelopeGetManyFieldMetaNameTypedDict(TypedDict):
    type: EnvelopeGetManyTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetManyTextAlign2]


class EnvelopeGetManyFieldMetaName(BaseModel):
    type: EnvelopeGetManyTypeName

    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[EnvelopeGetManyTextAlign2], 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 EnvelopeGetManyTypeInitials(str, Enum):
    INITIALS = "initials"


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


class EnvelopeGetManyFieldMetaInitialsTypedDict(TypedDict):
    type: EnvelopeGetManyTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetManyTextAlign1]


class EnvelopeGetManyFieldMetaInitials(BaseModel):
    type: EnvelopeGetManyTypeInitials

    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[EnvelopeGetManyTextAlign1], 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 EnvelopeGetManyTypeSignature(str, Enum):
    SIGNATURE = "signature"


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


class EnvelopeGetManyFieldMetaSignature(BaseModel):
    type: EnvelopeGetManyTypeSignature

    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


EnvelopeGetManyFieldMetaUnionTypedDict = TypeAliasType(
    "EnvelopeGetManyFieldMetaUnionTypedDict",
    Union[
        EnvelopeGetManyFieldMetaSignatureTypedDict,
        EnvelopeGetManyFieldMetaInitialsTypedDict,
        EnvelopeGetManyFieldMetaNameTypedDict,
        EnvelopeGetManyFieldMetaEmailTypedDict,
        EnvelopeGetManyFieldMetaDateTypedDict,
        EnvelopeGetManyFieldMetaRadioTypedDict,
        EnvelopeGetManyFieldMetaDropdownTypedDict,
        EnvelopeGetManyFieldMetaCheckboxTypedDict,
        EnvelopeGetManyFieldMetaTextTypedDict,
        EnvelopeGetManyFieldMetaNumberTypedDict,
    ],
)


EnvelopeGetManyFieldMetaUnion = Annotated[
    Union[
        Annotated[EnvelopeGetManyFieldMetaSignature, Tag("signature")],
        Annotated[EnvelopeGetManyFieldMetaInitials, Tag("initials")],
        Annotated[EnvelopeGetManyFieldMetaName, Tag("name")],
        Annotated[EnvelopeGetManyFieldMetaEmail, Tag("email")],
        Annotated[EnvelopeGetManyFieldMetaDate, Tag("date")],
        Annotated[EnvelopeGetManyFieldMetaText, Tag("text")],
        Annotated[EnvelopeGetManyFieldMetaNumber, Tag("number")],
        Annotated[EnvelopeGetManyFieldMetaRadio, Tag("radio")],
        Annotated[EnvelopeGetManyFieldMetaCheckbox, Tag("checkbox")],
        Annotated[EnvelopeGetManyFieldMetaDropdown, Tag("dropdown")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


class EnvelopeGetManyFieldTypedDict(TypedDict):
    envelope_id: str
    envelope_item_id: str
    type: EnvelopeGetManyFieldType
    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[EnvelopeGetManyFieldMetaUnionTypedDict]


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

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

    type: EnvelopeGetManyFieldType

    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[EnvelopeGetManyFieldMetaUnion], pydantic.Field(alias="fieldMeta")
    ]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


class EnvelopeGetManyEnvelopeItemTypedDict(TypedDict):
    envelope_id: str
    id: str
    title: str
    order: float


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

    id: str

    title: str

    order: float


class EnvelopeGetManyDirectLinkTypedDict(TypedDict):
    direct_template_recipient_id: float
    enabled: bool
    id: str
    token: str


class EnvelopeGetManyDirectLink(BaseModel):
    direct_template_recipient_id: Annotated[
        float, pydantic.Field(alias="directTemplateRecipientId")
    ]

    enabled: bool

    id: str

    token: str


class EnvelopeGetManyTeamTypedDict(TypedDict):
    id: float
    url: str


class EnvelopeGetManyTeam(BaseModel):
    id: float

    url: str


class EnvelopeGetManyUserTypedDict(TypedDict):
    id: float
    name: str
    email: str


class EnvelopeGetManyUser(BaseModel):
    id: float

    name: str

    email: str


class EnvelopeGetManyDataTypedDict(TypedDict):
    internal_version: float
    type: EnvelopeGetManyDataType
    status: EnvelopeGetManyStatus
    source: EnvelopeGetManySource
    visibility: EnvelopeGetManyVisibility
    template_type: EnvelopeGetManyTemplateType
    id: str
    secondary_id: str
    external_id: Nullable[str]
    created_at: str
    updated_at: str
    completed_at: Nullable[str]
    deleted_at: Nullable[str]
    title: str
    auth_options: Nullable[EnvelopeGetManyAuthOptionsTypedDict]
    form_values: Nullable[Dict[str, EnvelopeGetManyFormValuesTypedDict]]
    public_title: str
    public_description: str
    user_id: float
    team_id: float
    folder_id: Nullable[str]
    template_id: Nullable[float]
    document_meta: EnvelopeGetManyDocumentMetaTypedDict
    recipients: List[EnvelopeGetManyRecipientTypedDict]
    fields: List[EnvelopeGetManyFieldTypedDict]
    envelope_items: List[EnvelopeGetManyEnvelopeItemTypedDict]
    direct_link: Nullable[EnvelopeGetManyDirectLinkTypedDict]
    team: EnvelopeGetManyTeamTypedDict
    user: EnvelopeGetManyUserTypedDict


class EnvelopeGetManyData(BaseModel):
    internal_version: Annotated[float, pydantic.Field(alias="internalVersion")]

    type: EnvelopeGetManyDataType

    status: EnvelopeGetManyStatus

    source: EnvelopeGetManySource

    visibility: EnvelopeGetManyVisibility

    template_type: Annotated[
        EnvelopeGetManyTemplateType, pydantic.Field(alias="templateType")
    ]

    id: str

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

    external_id: Annotated[Nullable[str], pydantic.Field(alias="externalId")]

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]

    updated_at: Annotated[str, pydantic.Field(alias="updatedAt")]

    completed_at: Annotated[Nullable[str], pydantic.Field(alias="completedAt")]

    deleted_at: Annotated[Nullable[str], pydantic.Field(alias="deletedAt")]

    title: str

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

    form_values: Annotated[
        Nullable[Dict[str, EnvelopeGetManyFormValues]],
        pydantic.Field(alias="formValues"),
    ]

    public_title: Annotated[str, pydantic.Field(alias="publicTitle")]

    public_description: Annotated[str, pydantic.Field(alias="publicDescription")]

    user_id: Annotated[float, pydantic.Field(alias="userId")]

    team_id: Annotated[float, pydantic.Field(alias="teamId")]

    folder_id: Annotated[Nullable[str], pydantic.Field(alias="folderId")]

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

    document_meta: Annotated[
        EnvelopeGetManyDocumentMeta, pydantic.Field(alias="documentMeta")
    ]

    recipients: List[EnvelopeGetManyRecipient]

    fields: List[EnvelopeGetManyField]

    envelope_items: Annotated[
        List[EnvelopeGetManyEnvelopeItem], pydantic.Field(alias="envelopeItems")
    ]

    direct_link: Annotated[
        Nullable[EnvelopeGetManyDirectLink], pydantic.Field(alias="directLink")
    ]

    team: EnvelopeGetManyTeam

    user: EnvelopeGetManyUser

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


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

    data: List[EnvelopeGetManyDataTypedDict]


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

    data: List[EnvelopeGetManyData]
