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

from __future__ import annotations
from documenso_sdk import utils
from documenso_sdk.types import BaseModel, Nullable, UNSET_SENTINEL
from documenso_sdk.utils import FieldMetadata, PathParamMetadata
from enum import Enum
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class DocumentGetDocumentWithDetailsByIDRequestTypedDict(TypedDict):
    document_id: float


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


class DocumentGetDocumentWithDetailsByIDDocumentsResponseIssuesTypedDict(TypedDict):
    message: str


class DocumentGetDocumentWithDetailsByIDDocumentsResponseIssues(BaseModel):
    message: str


class DocumentGetDocumentWithDetailsByIDDocumentsResponse500ResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[
        List[DocumentGetDocumentWithDetailsByIDDocumentsResponseIssues]
    ] = None


class DocumentGetDocumentWithDetailsByIDDocumentsResponse500ResponseBody(Exception):
    r"""Internal server error"""

    data: DocumentGetDocumentWithDetailsByIDDocumentsResponse500ResponseBodyData

    def __init__(
        self,
        data: DocumentGetDocumentWithDetailsByIDDocumentsResponse500ResponseBodyData,
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data,
            DocumentGetDocumentWithDetailsByIDDocumentsResponse500ResponseBodyData,
        )


class DocumentGetDocumentWithDetailsByIDDocumentsIssuesTypedDict(TypedDict):
    message: str


class DocumentGetDocumentWithDetailsByIDDocumentsIssues(BaseModel):
    message: str


class DocumentGetDocumentWithDetailsByIDDocumentsResponseResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetDocumentWithDetailsByIDDocumentsIssues]] = None


class DocumentGetDocumentWithDetailsByIDDocumentsResponseResponseBody(Exception):
    r"""Not found"""

    data: DocumentGetDocumentWithDetailsByIDDocumentsResponseResponseBodyData

    def __init__(
        self, data: DocumentGetDocumentWithDetailsByIDDocumentsResponseResponseBodyData
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data,
            DocumentGetDocumentWithDetailsByIDDocumentsResponseResponseBodyData,
        )


class DocumentGetDocumentWithDetailsByIDIssuesTypedDict(TypedDict):
    message: str


class DocumentGetDocumentWithDetailsByIDIssues(BaseModel):
    message: str


class DocumentGetDocumentWithDetailsByIDDocumentsResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentGetDocumentWithDetailsByIDIssues]] = None


class DocumentGetDocumentWithDetailsByIDDocumentsResponseBody(Exception):
    r"""Invalid input data"""

    data: DocumentGetDocumentWithDetailsByIDDocumentsResponseBodyData

    def __init__(
        self, data: DocumentGetDocumentWithDetailsByIDDocumentsResponseBodyData
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data, DocumentGetDocumentWithDetailsByIDDocumentsResponseBodyData
        )


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


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


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


class DocumentGetDocumentWithDetailsByIDGlobalAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class DocumentGetDocumentWithDetailsByIDGlobalActionAuth(str, Enum):
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""

    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"


class AuthOptionsTypedDict(TypedDict):
    global_access_auth: Nullable[DocumentGetDocumentWithDetailsByIDGlobalAccessAuth]
    r"""The type of authentication required for the recipient to access the document."""
    global_action_auth: Nullable[DocumentGetDocumentWithDetailsByIDGlobalActionAuth]
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""


class AuthOptions(BaseModel):
    global_access_auth: Annotated[
        Nullable[DocumentGetDocumentWithDetailsByIDGlobalAccessAuth],
        pydantic.Field(alias="globalAccessAuth"),
    ]
    r"""The type of authentication required for the recipient to access the document."""

    global_action_auth: Annotated[
        Nullable[DocumentGetDocumentWithDetailsByIDGlobalActionAuth],
        pydantic.Field(alias="globalActionAuth"),
    ]
    r"""The type of authentication required for the recipient to sign the document. This field is restricted to Enterprise plan users only."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["globalAccessAuth", "globalActionAuth"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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


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


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


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


class DocumentDataTypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDDocumentsType
    id: str
    data: str
    initial_data: str


class DocumentData(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDDocumentsType

    id: str

    data: str

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


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


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


class DocumentGetDocumentWithDetailsByIDEmailSettingsTypedDict(TypedDict):
    recipient_signing_request: NotRequired[bool]
    r"""Whether to send an email to all recipients that the document is ready for them to sign."""
    recipient_removed: NotRequired[bool]
    r"""Whether to send an email to the recipient who was removed from a pending document."""
    recipient_signed: NotRequired[bool]
    r"""Whether to send an email to the document owner when a recipient has signed the document."""
    document_pending: NotRequired[bool]
    r"""Whether to send an email to the recipient who has just signed the document indicating that there are still other recipients who need to sign the document. This will only be sent if the document is still pending after the recipient has signed."""
    document_completed: NotRequired[bool]
    r"""Whether to send an email to all recipients when the document is complete."""
    document_deleted: NotRequired[bool]
    r"""Whether to send an email to all recipients if a pending document has been deleted."""
    owner_document_completed: NotRequired[bool]
    r"""Whether to send an email to the document owner when the document is complete."""


class DocumentGetDocumentWithDetailsByIDEmailSettings(BaseModel):
    recipient_signing_request: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigningRequest")
    ] = True
    r"""Whether to send an email to all recipients that the document is ready for them to sign."""

    recipient_removed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientRemoved")
    ] = True
    r"""Whether to send an email to the recipient who was removed from a pending document."""

    recipient_signed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigned")
    ] = True
    r"""Whether to send an email to the document owner when a recipient has signed the document."""

    document_pending: Annotated[
        Optional[bool], pydantic.Field(alias="documentPending")
    ] = True
    r"""Whether to send an email to the recipient who has just signed the document indicating that there are still other recipients who need to sign the document. This will only be sent if the document is still pending after the recipient has signed."""

    document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="documentCompleted")
    ] = True
    r"""Whether to send an email to all recipients when the document is complete."""

    document_deleted: Annotated[
        Optional[bool], pydantic.Field(alias="documentDeleted")
    ] = True
    r"""Whether to send an email to all recipients if a pending document has been deleted."""

    owner_document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="ownerDocumentCompleted")
    ] = True
    r"""Whether to send an email to the document owner when the document is complete."""


class DocumentMetaTypedDict(TypedDict):
    signing_order: DocumentGetDocumentWithDetailsByIDSigningOrder
    distribution_method: DocumentGetDocumentWithDetailsByIDDistributionMethod
    id: str
    subject: Nullable[str]
    message: Nullable[str]
    timezone: Nullable[str]
    password: Nullable[str]
    date_format: Nullable[str]
    document_id: int
    redirect_url: Nullable[str]
    typed_signature_enabled: bool
    language: str
    email_settings: Nullable[DocumentGetDocumentWithDetailsByIDEmailSettingsTypedDict]


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

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

    id: str

    subject: Nullable[str]

    message: Nullable[str]

    timezone: Nullable[str]

    password: Nullable[str]

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

    document_id: Annotated[int, pydantic.Field(alias="documentId")]

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

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

    language: str

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

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

        serialized = handler(self)

        m = {}

        for n, f in 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 DocumentGetDocumentWithDetailsByIDRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"


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


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


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


class DocumentGetDocumentWithDetailsByIDAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class DocumentGetDocumentWithDetailsByIDActionAuth(str, Enum):
    r"""The type of authentication required for the recipient to sign the document."""

    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class DocumentGetDocumentWithDetailsByIDAuthOptionsTypedDict(TypedDict):
    access_auth: Nullable[DocumentGetDocumentWithDetailsByIDAccessAuth]
    r"""The type of authentication required for the recipient to access the document."""
    action_auth: Nullable[DocumentGetDocumentWithDetailsByIDActionAuth]
    r"""The type of authentication required for the recipient to sign the document."""


class DocumentGetDocumentWithDetailsByIDAuthOptions(BaseModel):
    access_auth: Annotated[
        Nullable[DocumentGetDocumentWithDetailsByIDAccessAuth],
        pydantic.Field(alias="accessAuth"),
    ]
    r"""The type of authentication required for the recipient to access the document."""

    action_auth: Annotated[
        Nullable[DocumentGetDocumentWithDetailsByIDActionAuth],
        pydantic.Field(alias="actionAuth"),
    ]
    r"""The type of authentication required for the recipient to sign the document."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["accessAuth", "actionAuth"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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 DocumentGetDocumentWithDetailsByIDRecipientsTypedDict(TypedDict):
    role: DocumentGetDocumentWithDetailsByIDRole
    read_status: DocumentGetDocumentWithDetailsByIDReadStatus
    signing_status: DocumentGetDocumentWithDetailsByIDSigningStatus
    send_status: DocumentGetDocumentWithDetailsByIDSendStatus
    id: int
    document_id: Nullable[int]
    template_id: Nullable[int]
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[DocumentGetDocumentWithDetailsByIDAuthOptionsTypedDict]
    signing_order: Nullable[float]
    r"""The order in which the recipient should sign the document. Only works if the document is set to sequential signing."""
    rejection_reason: Nullable[str]


class DocumentGetDocumentWithDetailsByIDRecipients(BaseModel):
    role: DocumentGetDocumentWithDetailsByIDRole

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

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

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

    id: int

    document_id: Annotated[Nullable[int], pydantic.Field(alias="documentId")]

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

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

    signing_order: Annotated[Nullable[float], pydantic.Field(alias="signingOrder")]
    r"""The order in which the recipient should sign the document. Only works if the document is set to sequential signing."""

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

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

        serialized = handler(self)

        m = {}

        for n, f in 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 DocumentGetDocumentWithDetailsByIDType(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 DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFields9Type(
    str, Enum
):
    DROPDOWN = "dropdown"


class DocumentGetDocumentWithDetailsByIDFieldMetaValuesTypedDict(TypedDict):
    value: str


class DocumentGetDocumentWithDetailsByIDFieldMetaValues(BaseModel):
    value: str


class DocumentGetDocumentWithDetailsByIDFieldMeta9TypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[DocumentGetDocumentWithDetailsByIDFieldMetaValuesTypedDict]
    ]
    default_value: NotRequired[str]


class DocumentGetDocumentWithDetailsByIDFieldMeta9(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFields9Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[List[DocumentGetDocumentWithDetailsByIDFieldMetaValues]] = None

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponseValues(BaseModel):
    id: float

    checked: bool

    value: str


class DocumentGetDocumentWithDetailsByIDFieldMeta8TypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponseValuesTypedDict
        ]
    ]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class DocumentGetDocumentWithDetailsByIDFieldMeta8(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFieldsType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[
        List[DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponseValues]
    ] = None

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

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsValues(BaseModel):
    id: float

    checked: bool

    value: str


class DocumentGetDocumentWithDetailsByIDFieldMeta7TypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsValuesTypedDict]
    ]


class DocumentGetDocumentWithDetailsByIDFieldMeta7(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[
        List[DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsValues]
    ] = None


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


class DocumentGetDocumentWithDetailsByIDFieldMeta6TypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    number_format: NotRequired[str]
    value: NotRequired[str]
    min_value: NotRequired[float]
    max_value: NotRequired[float]
    font_size: NotRequired[float]


class DocumentGetDocumentWithDetailsByIDFieldMeta6(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    value: Optional[str] = None

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

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

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


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


class DocumentGetDocumentWithDetailsByIDFieldMeta5TypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    font_size: NotRequired[float]


class DocumentGetDocumentWithDetailsByIDFieldMeta5(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    text: Optional[str] = None

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

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMeta4(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponseType

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMeta3(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsType

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMeta2(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaType

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


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


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


class DocumentGetDocumentWithDetailsByIDFieldMeta1(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDFieldMetaDocumentsResponse200ApplicationJSONResponseBodyFields1Type

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


DocumentGetDocumentWithDetailsByIDFieldMetaTypedDict = TypeAliasType(
    "DocumentGetDocumentWithDetailsByIDFieldMetaTypedDict",
    Union[
        DocumentGetDocumentWithDetailsByIDFieldMeta1TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta2TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta3TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta4TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta7TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta9TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta5TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta8TypedDict,
        DocumentGetDocumentWithDetailsByIDFieldMeta6TypedDict,
    ],
)


DocumentGetDocumentWithDetailsByIDFieldMeta = TypeAliasType(
    "DocumentGetDocumentWithDetailsByIDFieldMeta",
    Union[
        DocumentGetDocumentWithDetailsByIDFieldMeta1,
        DocumentGetDocumentWithDetailsByIDFieldMeta2,
        DocumentGetDocumentWithDetailsByIDFieldMeta3,
        DocumentGetDocumentWithDetailsByIDFieldMeta4,
        DocumentGetDocumentWithDetailsByIDFieldMeta7,
        DocumentGetDocumentWithDetailsByIDFieldMeta9,
        DocumentGetDocumentWithDetailsByIDFieldMeta5,
        DocumentGetDocumentWithDetailsByIDFieldMeta8,
        DocumentGetDocumentWithDetailsByIDFieldMeta6,
    ],
)


class DocumentGetDocumentWithDetailsByIDFieldsTypedDict(TypedDict):
    type: DocumentGetDocumentWithDetailsByIDType
    id: int
    secondary_id: str
    document_id: Nullable[int]
    template_id: Nullable[int]
    recipient_id: int
    page: float
    r"""The page number of the field on the document. Starts from 1."""
    custom_text: str
    inserted: bool
    field_meta: Nullable[DocumentGetDocumentWithDetailsByIDFieldMetaTypedDict]
    position_x: NotRequired[Any]
    position_y: NotRequired[Any]
    width: NotRequired[Any]
    height: NotRequired[Any]


class DocumentGetDocumentWithDetailsByIDFields(BaseModel):
    type: DocumentGetDocumentWithDetailsByIDType

    id: int

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

    document_id: Annotated[Nullable[int], pydantic.Field(alias="documentId")]

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

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

    page: float
    r"""The page number of the field on the document. Starts from 1."""

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

    inserted: bool

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

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

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

    width: Optional[Any] = None

    height: Optional[Any] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["positionX", "positionY", "width", "height"]
        nullable_fields = ["documentId", "templateId", "fieldMeta"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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 DocumentGetDocumentWithDetailsByIDResponseBodyTypedDict(TypedDict):
    r"""Successful response"""

    visibility: DocumentGetDocumentWithDetailsByIDVisibility
    status: DocumentGetDocumentWithDetailsByIDStatus
    source: DocumentGetDocumentWithDetailsByIDSource
    id: int
    external_id: Nullable[str]
    r"""A custom external ID you can use to identify the document."""
    user_id: float
    r"""The ID of the user that created this document."""
    auth_options: Nullable[AuthOptionsTypedDict]
    form_values: Nullable[
        Dict[str, DocumentGetDocumentWithDetailsByIDFormValuesTypedDict]
    ]
    title: str
    document_data_id: str
    created_at: str
    updated_at: str
    completed_at: Nullable[str]
    deleted_at: Nullable[str]
    team_id: Nullable[int]
    template_id: Nullable[int]
    document_data: DocumentDataTypedDict
    document_meta: Nullable[DocumentMetaTypedDict]
    recipients: List[DocumentGetDocumentWithDetailsByIDRecipientsTypedDict]
    fields: List[DocumentGetDocumentWithDetailsByIDFieldsTypedDict]


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

    visibility: DocumentGetDocumentWithDetailsByIDVisibility

    status: DocumentGetDocumentWithDetailsByIDStatus

    source: DocumentGetDocumentWithDetailsByIDSource

    id: int

    external_id: Annotated[Nullable[str], pydantic.Field(alias="externalId")]
    r"""A custom external ID you can use to identify the document."""

    user_id: Annotated[float, pydantic.Field(alias="userId")]
    r"""The ID of the user that created this document."""

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

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

    title: str

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

    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[Nullable[int], pydantic.Field(alias="teamId")]

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

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

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

    recipients: List[DocumentGetDocumentWithDetailsByIDRecipients]

    fields: List[DocumentGetDocumentWithDetailsByIDFields]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "externalId",
            "authOptions",
            "formValues",
            "completedAt",
            "deletedAt",
            "teamId",
            "templateId",
            "documentMeta",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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
