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


class EnvelopeGetRequestTypedDict(TypedDict):
    envelope_id: str


class EnvelopeGetRequest(BaseModel):
    envelope_id: Annotated[
        str,
        pydantic.Field(alias="envelopeId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]


class EnvelopeGetInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class EnvelopeGetInternalServerErrorIssue(BaseModel):
    message: str


class EnvelopeGetInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeGetInternalServerErrorIssue]] = None


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

    data: EnvelopeGetInternalServerErrorData = field(hash=False)

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


class EnvelopeGetNotFoundIssue(BaseModel):
    message: str


class EnvelopeGetNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeGetNotFoundIssue]] = None


@dataclass(unsafe_hash=True)
class EnvelopeGetNotFoundError(DocumensoError):
    r"""Not found"""

    data: EnvelopeGetNotFoundErrorData = field(hash=False)

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


class EnvelopeGetForbiddenIssue(BaseModel):
    message: str


class EnvelopeGetForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeGetForbiddenIssue]] = None


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

    data: EnvelopeGetForbiddenErrorData = field(hash=False)

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


class EnvelopeGetUnauthorizedIssue(BaseModel):
    message: str


class EnvelopeGetUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeGetUnauthorizedIssue]] = None


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

    data: EnvelopeGetUnauthorizedErrorData = field(hash=False)

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


class EnvelopeGetBadRequestIssue(BaseModel):
    message: str


class EnvelopeGetBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeGetBadRequestIssue]] = None


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

    data: EnvelopeGetBadRequestErrorData = field(hash=False)

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


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


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


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


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


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


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


class EnvelopeGetAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[EnvelopeGetGlobalAccessAuth]
    global_action_auth: List[EnvelopeGetGlobalActionAuth]


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

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


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


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


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


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


class EnvelopeGetEmailSettingsTypedDict(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 EnvelopeGetEmailSettings(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


class EnvelopeGetDocumentMetaTypedDict(TypedDict):
    signing_order: EnvelopeGetSigningOrder
    distribution_method: EnvelopeGetDistributionMethod
    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[EnvelopeGetEmailSettingsTypedDict]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]


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

    distribution_method: Annotated[
        EnvelopeGetDistributionMethod, 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[EnvelopeGetEmailSettings], 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):
        optional_fields = []
        nullable_fields = [
            "subject",
            "message",
            "timezone",
            "dateFormat",
            "redirectUrl",
            "emailSettings",
            "emailId",
            "emailReplyTo",
        ]
        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 EnvelopeGetRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


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


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


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


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


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


class EnvelopeGetRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[EnvelopeGetAccessAuth]
    action_auth: List[EnvelopeGetActionAuth]


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

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


class EnvelopeGetRecipientTypedDict(TypedDict):
    envelope_id: str
    role: EnvelopeGetRole
    read_status: EnvelopeGetReadStatus
    signing_status: EnvelopeGetSigningStatus
    send_status: EnvelopeGetSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[EnvelopeGetRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]


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

    role: EnvelopeGetRole

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

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

    send_status: Annotated[EnvelopeGetSendStatus, 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[EnvelopeGetRecipientAuthOptions], 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):
        optional_fields = []
        nullable_fields = [
            "documentDeletedAt",
            "expired",
            "signedAt",
            "authOptions",
            "signingOrder",
            "rejectionReason",
        ]
        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 EnvelopeGetFieldType(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 EnvelopeGetTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class EnvelopeGetValue3TypedDict(TypedDict):
    value: str


class EnvelopeGetValue3(BaseModel):
    value: str


class EnvelopeGetFieldMetaDropdownTypedDict(TypedDict):
    type: EnvelopeGetTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetValue3TypedDict]]
    default_value: NotRequired[str]


class EnvelopeGetFieldMetaDropdown(BaseModel):
    type: EnvelopeGetTypeDropdown

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

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


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


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


class EnvelopeGetValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeGetFieldMetaCheckboxTypedDict(TypedDict):
    type: EnvelopeGetTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[EnvelopeGetDirection2]


class EnvelopeGetFieldMetaCheckbox(BaseModel):
    type: EnvelopeGetTypeCheckbox

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

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

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

    direction: Optional[EnvelopeGetDirection2] = EnvelopeGetDirection2.VERTICAL


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


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


class EnvelopeGetValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeGetFieldMetaRadioTypedDict(TypedDict):
    type: EnvelopeGetTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeGetValue1TypedDict]]
    direction: NotRequired[EnvelopeGetDirection1]


class EnvelopeGetFieldMetaRadio(BaseModel):
    type: EnvelopeGetTypeRadio

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

    direction: Optional[EnvelopeGetDirection1] = EnvelopeGetDirection1.VERTICAL


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


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


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


class EnvelopeGetFieldMetaNumberTypedDict(TypedDict):
    type: EnvelopeGetTypeNumber
    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[EnvelopeGetTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeGetVerticalAlign2]]


class EnvelopeGetFieldMetaNumber(BaseModel):
    type: EnvelopeGetTypeNumber

    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[EnvelopeGetTextAlign6], 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[EnvelopeGetVerticalAlign2],
        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 EnvelopeGetTypeText(str, Enum):
    TEXT = "text"


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


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


class EnvelopeGetFieldMetaTextTypedDict(TypedDict):
    type: EnvelopeGetTypeText
    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[EnvelopeGetTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeGetVerticalAlign1]]


class EnvelopeGetFieldMetaText(BaseModel):
    type: EnvelopeGetTypeText

    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[EnvelopeGetTextAlign5], 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[EnvelopeGetVerticalAlign1],
        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 EnvelopeGetTypeDate(str, Enum):
    DATE = "date"


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


class EnvelopeGetFieldMetaDateTypedDict(TypedDict):
    type: EnvelopeGetTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetTextAlign4]


class EnvelopeGetFieldMetaDate(BaseModel):
    type: EnvelopeGetTypeDate

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


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


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


class EnvelopeGetFieldMetaEmailTypedDict(TypedDict):
    type: EnvelopeGetTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetTextAlign3]


class EnvelopeGetFieldMetaEmail(BaseModel):
    type: EnvelopeGetTypeEmail

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


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


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


class EnvelopeGetFieldMetaNameTypedDict(TypedDict):
    type: EnvelopeGetTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetTextAlign2]


class EnvelopeGetFieldMetaName(BaseModel):
    type: EnvelopeGetTypeName

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


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


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


class EnvelopeGetFieldMetaInitialsTypedDict(TypedDict):
    type: EnvelopeGetTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeGetTextAlign1]


class EnvelopeGetFieldMetaInitials(BaseModel):
    type: EnvelopeGetTypeInitials

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


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


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


class EnvelopeGetFieldMetaSignature(BaseModel):
    type: EnvelopeGetTypeSignature

    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


EnvelopeGetFieldMetaUnionTypedDict = TypeAliasType(
    "EnvelopeGetFieldMetaUnionTypedDict",
    Union[
        EnvelopeGetFieldMetaSignatureTypedDict,
        EnvelopeGetFieldMetaInitialsTypedDict,
        EnvelopeGetFieldMetaNameTypedDict,
        EnvelopeGetFieldMetaEmailTypedDict,
        EnvelopeGetFieldMetaDateTypedDict,
        EnvelopeGetFieldMetaRadioTypedDict,
        EnvelopeGetFieldMetaDropdownTypedDict,
        EnvelopeGetFieldMetaCheckboxTypedDict,
        EnvelopeGetFieldMetaTextTypedDict,
        EnvelopeGetFieldMetaNumberTypedDict,
    ],
)


EnvelopeGetFieldMetaUnion = TypeAliasType(
    "EnvelopeGetFieldMetaUnion",
    Union[
        EnvelopeGetFieldMetaSignature,
        EnvelopeGetFieldMetaInitials,
        EnvelopeGetFieldMetaName,
        EnvelopeGetFieldMetaEmail,
        EnvelopeGetFieldMetaDate,
        EnvelopeGetFieldMetaRadio,
        EnvelopeGetFieldMetaDropdown,
        EnvelopeGetFieldMetaCheckbox,
        EnvelopeGetFieldMetaText,
        EnvelopeGetFieldMetaNumber,
    ],
)


class EnvelopeGetFieldTypedDict(TypedDict):
    envelope_id: str
    envelope_item_id: str
    type: EnvelopeGetFieldType
    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[EnvelopeGetFieldMetaUnionTypedDict]


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

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

    type: EnvelopeGetFieldType

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["fieldMeta"]
        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 EnvelopeGetEnvelopeItemTypedDict(TypedDict):
    envelope_id: str
    id: str
    title: str
    order: float


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

    id: str

    title: str

    order: float


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


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

    enabled: bool

    id: str

    token: str


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


class EnvelopeGetTeam(BaseModel):
    id: float

    url: str


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


class EnvelopeGetUser(BaseModel):
    id: float

    name: str

    email: str


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

    internal_version: float
    type: EnvelopeGetType
    status: EnvelopeGetStatus
    source: EnvelopeGetSource
    visibility: EnvelopeGetVisibility
    template_type: EnvelopeGetTemplateType
    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[EnvelopeGetAuthOptionsTypedDict]
    form_values: Nullable[Dict[str, EnvelopeGetFormValuesTypedDict]]
    public_title: str
    public_description: str
    user_id: float
    team_id: float
    folder_id: Nullable[str]
    template_id: Nullable[float]
    document_meta: EnvelopeGetDocumentMetaTypedDict
    recipients: List[EnvelopeGetRecipientTypedDict]
    fields: List[EnvelopeGetFieldTypedDict]
    envelope_items: List[EnvelopeGetEnvelopeItemTypedDict]
    direct_link: Nullable[EnvelopeGetDirectLinkTypedDict]
    team: EnvelopeGetTeamTypedDict
    user: EnvelopeGetUserTypedDict


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

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

    type: EnvelopeGetType

    status: EnvelopeGetStatus

    source: EnvelopeGetSource

    visibility: EnvelopeGetVisibility

    template_type: Annotated[
        EnvelopeGetTemplateType, 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[EnvelopeGetAuthOptions], pydantic.Field(alias="authOptions")
    ]

    form_values: Annotated[
        Nullable[Dict[str, EnvelopeGetFormValues]], 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[
        EnvelopeGetDocumentMeta, pydantic.Field(alias="documentMeta")
    ]

    recipients: List[EnvelopeGetRecipient]

    fields: List[EnvelopeGetField]

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

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

    team: EnvelopeGetTeam

    user: EnvelopeGetUser

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "externalId",
            "completedAt",
            "deletedAt",
            "authOptions",
            "formValues",
            "folderId",
            "templateId",
            "directLink",
        ]
        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
