"""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 DocumentGetRequestTypedDict(TypedDict):
    document_id: float


class DocumentGetRequest(BaseModel):
    document_id: Annotated[
        float,
        pydantic.Field(alias="documentId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]


class DocumentGetInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class DocumentGetInternalServerErrorIssue(BaseModel):
    message: str


class DocumentGetInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetInternalServerErrorIssue]] = None


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

    data: DocumentGetInternalServerErrorData = field(hash=False)

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


class DocumentGetNotFoundIssue(BaseModel):
    message: str


class DocumentGetNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetNotFoundIssue]] = None


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

    data: DocumentGetNotFoundErrorData = field(hash=False)

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


class DocumentGetForbiddenIssue(BaseModel):
    message: str


class DocumentGetForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetForbiddenIssue]] = None


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

    data: DocumentGetForbiddenErrorData = field(hash=False)

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


class DocumentGetUnauthorizedIssue(BaseModel):
    message: str


class DocumentGetUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetUnauthorizedIssue]] = None


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

    data: DocumentGetUnauthorizedErrorData = field(hash=False)

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


class DocumentGetBadRequestIssue(BaseModel):
    message: str


class DocumentGetBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetBadRequestIssue]] = None


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

    data: DocumentGetBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentGetBadRequestErrorData,
        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 DocumentGetVisibility(str, Enum):
    EVERYONE = "EVERYONE"
    MANAGER_AND_ABOVE = "MANAGER_AND_ABOVE"
    ADMIN = "ADMIN"


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


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


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


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


class DocumentGetAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[DocumentGetGlobalAccessAuth]
    global_action_auth: List[DocumentGetGlobalActionAuth]


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

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


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


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


class DocumentGetDocumentDataType(str, Enum):
    S3_PATH = "S3_PATH"
    BYTES = "BYTES"
    BYTES_64 = "BYTES_64"


class DocumentGetDocumentDataTypedDict(TypedDict):
    type: DocumentGetDocumentDataType
    id: str
    data: str
    initial_data: str
    envelope_item_id: str


class DocumentGetDocumentData(BaseModel):
    type: DocumentGetDocumentDataType

    id: str

    data: str

    initial_data: Annotated[str, pydantic.Field(alias="initialData")]

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


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


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


class DocumentGetEmailSettingsTypedDict(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 DocumentGetEmailSettings(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 DocumentGetDocumentMetaTypedDict(TypedDict):
    signing_order: DocumentGetSigningOrder
    distribution_method: DocumentGetDistributionMethod
    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[DocumentGetEmailSettingsTypedDict]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]
    password: NotRequired[Nullable[str]]
    document_id: NotRequired[float]


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

    distribution_method: Annotated[
        DocumentGetDistributionMethod, 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[DocumentGetEmailSettings], pydantic.Field(alias="emailSettings")
    ]

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

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

    password: OptionalNullable[str] = None

    document_id: Annotated[Optional[float], pydantic.Field(alias="documentId")] = -1

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["password", "documentId"]
        nullable_fields = [
            "subject",
            "message",
            "timezone",
            "dateFormat",
            "redirectUrl",
            "emailSettings",
            "emailId",
            "emailReplyTo",
            "password",
        ]
        null_default_fields = ["password"]

        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 DocumentGetEnvelopeItemTypedDict(TypedDict):
    id: str
    envelope_id: str


class DocumentGetEnvelopeItem(BaseModel):
    id: str

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


class DocumentGetFolderType(str, Enum):
    DOCUMENT = "DOCUMENT"
    TEMPLATE = "TEMPLATE"


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


class DocumentGetFolderTypedDict(TypedDict):
    id: str
    name: str
    type: DocumentGetFolderType
    visibility: DocumentGetFolderVisibility
    user_id: float
    team_id: float
    pinned: bool
    parent_id: Nullable[str]
    created_at: str
    updated_at: str


class DocumentGetFolder(BaseModel):
    id: str

    name: str

    type: DocumentGetFolderType

    visibility: DocumentGetFolderVisibility

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

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

    pinned: bool

    parent_id: Annotated[Nullable[str], pydantic.Field(alias="parentId")]

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["parentId"]
        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 DocumentGetRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


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


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


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


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


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


class DocumentGetRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[DocumentGetAccessAuth]
    action_auth: List[DocumentGetActionAuth]


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

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


class DocumentGetRecipientTypedDict(TypedDict):
    envelope_id: str
    role: DocumentGetRole
    read_status: DocumentGetReadStatus
    signing_status: DocumentGetSigningStatus
    send_status: DocumentGetSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[DocumentGetRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: DocumentGetRole

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

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

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

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

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

    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 DocumentGetFieldType(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 DocumentGetTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class DocumentGetValue3TypedDict(TypedDict):
    value: str


class DocumentGetValue3(BaseModel):
    value: str


class DocumentGetFieldMetaDropdownTypedDict(TypedDict):
    type: DocumentGetTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentGetValue3TypedDict]]
    default_value: NotRequired[str]


class DocumentGetFieldMetaDropdown(BaseModel):
    type: DocumentGetTypeDropdown

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

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


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


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


class DocumentGetValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class DocumentGetFieldMetaCheckboxTypedDict(TypedDict):
    type: DocumentGetTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentGetValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[DocumentGetDirection2]


class DocumentGetFieldMetaCheckbox(BaseModel):
    type: DocumentGetTypeCheckbox

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

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

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

    direction: Optional[DocumentGetDirection2] = DocumentGetDirection2.VERTICAL


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


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


class DocumentGetValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class DocumentGetFieldMetaRadioTypedDict(TypedDict):
    type: DocumentGetTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentGetValue1TypedDict]]
    direction: NotRequired[DocumentGetDirection1]


class DocumentGetFieldMetaRadio(BaseModel):
    type: DocumentGetTypeRadio

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

    direction: Optional[DocumentGetDirection1] = DocumentGetDirection1.VERTICAL


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


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


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


class DocumentGetFieldMetaNumberTypedDict(TypedDict):
    type: DocumentGetTypeNumber
    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[DocumentGetTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[DocumentGetVerticalAlign2]]


class DocumentGetFieldMetaNumber(BaseModel):
    type: DocumentGetTypeNumber

    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[DocumentGetTextAlign6], 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[DocumentGetVerticalAlign2],
        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 DocumentGetTypeText(str, Enum):
    TEXT = "text"


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


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


class DocumentGetFieldMetaTextTypedDict(TypedDict):
    type: DocumentGetTypeText
    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[DocumentGetTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[DocumentGetVerticalAlign1]]


class DocumentGetFieldMetaText(BaseModel):
    type: DocumentGetTypeText

    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[DocumentGetTextAlign5], 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[DocumentGetVerticalAlign1],
        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 DocumentGetTypeDate(str, Enum):
    DATE = "date"


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


class DocumentGetFieldMetaDateTypedDict(TypedDict):
    type: DocumentGetTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentGetTextAlign4]


class DocumentGetFieldMetaDate(BaseModel):
    type: DocumentGetTypeDate

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


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


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


class DocumentGetFieldMetaEmailTypedDict(TypedDict):
    type: DocumentGetTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentGetTextAlign3]


class DocumentGetFieldMetaEmail(BaseModel):
    type: DocumentGetTypeEmail

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


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


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


class DocumentGetFieldMetaNameTypedDict(TypedDict):
    type: DocumentGetTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentGetTextAlign2]


class DocumentGetFieldMetaName(BaseModel):
    type: DocumentGetTypeName

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


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


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


class DocumentGetFieldMetaInitialsTypedDict(TypedDict):
    type: DocumentGetTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentGetTextAlign1]


class DocumentGetFieldMetaInitials(BaseModel):
    type: DocumentGetTypeInitials

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


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


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


class DocumentGetFieldMetaSignature(BaseModel):
    type: DocumentGetTypeSignature

    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


DocumentGetFieldMetaUnionTypedDict = TypeAliasType(
    "DocumentGetFieldMetaUnionTypedDict",
    Union[
        DocumentGetFieldMetaSignatureTypedDict,
        DocumentGetFieldMetaInitialsTypedDict,
        DocumentGetFieldMetaNameTypedDict,
        DocumentGetFieldMetaEmailTypedDict,
        DocumentGetFieldMetaDateTypedDict,
        DocumentGetFieldMetaRadioTypedDict,
        DocumentGetFieldMetaDropdownTypedDict,
        DocumentGetFieldMetaCheckboxTypedDict,
        DocumentGetFieldMetaTextTypedDict,
        DocumentGetFieldMetaNumberTypedDict,
    ],
)


DocumentGetFieldMetaUnion = TypeAliasType(
    "DocumentGetFieldMetaUnion",
    Union[
        DocumentGetFieldMetaSignature,
        DocumentGetFieldMetaInitials,
        DocumentGetFieldMetaName,
        DocumentGetFieldMetaEmail,
        DocumentGetFieldMetaDate,
        DocumentGetFieldMetaRadio,
        DocumentGetFieldMetaDropdown,
        DocumentGetFieldMetaCheckbox,
        DocumentGetFieldMetaText,
        DocumentGetFieldMetaNumber,
    ],
)


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


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

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

    type: DocumentGetFieldType

    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[DocumentGetFieldMetaUnion], 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 DocumentGetResponseTypedDict(TypedDict):
    r"""Successful response"""

    visibility: DocumentGetVisibility
    status: DocumentGetStatus
    source: DocumentGetSource
    id: float
    external_id: Nullable[str]
    user_id: float
    auth_options: Nullable[DocumentGetAuthOptionsTypedDict]
    form_values: Nullable[Dict[str, DocumentGetFormValuesTypedDict]]
    title: str
    created_at: str
    updated_at: str
    completed_at: Nullable[str]
    deleted_at: Nullable[str]
    team_id: float
    folder_id: Nullable[str]
    envelope_id: str
    internal_version: float
    document_data: DocumentGetDocumentDataTypedDict
    document_meta: DocumentGetDocumentMetaTypedDict
    envelope_items: List[DocumentGetEnvelopeItemTypedDict]
    folder: Nullable[DocumentGetFolderTypedDict]
    recipients: List[DocumentGetRecipientTypedDict]
    fields: List[DocumentGetFieldTypedDict]
    template_id: NotRequired[Nullable[float]]
    document_data_id: NotRequired[str]


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

    visibility: DocumentGetVisibility

    status: DocumentGetStatus

    source: DocumentGetSource

    id: float

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

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

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

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

    title: str

    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")]

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

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

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

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

    document_data: Annotated[
        DocumentGetDocumentData, pydantic.Field(alias="documentData")
    ]

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

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

    folder: Nullable[DocumentGetFolder]

    recipients: List[DocumentGetRecipient]

    fields: List[DocumentGetField]

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

    document_data_id: Annotated[
        Optional[str], pydantic.Field(alias="documentDataId")
    ] = ""

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