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

from __future__ import annotations
from dataclasses import dataclass, field
from documenso_sdk.models import DocumensoError
from documenso_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from enum import Enum
import httpx
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class TemplateCreateDocumentFromTemplateRecipientRequestTypedDict(TypedDict):
    id: float
    email: str
    name: NotRequired[str]


class TemplateCreateDocumentFromTemplateRecipientRequest(BaseModel):
    id: float

    email: str

    name: Optional[str] = None


class TemplateCreateDocumentFromTemplateCustomDocumentDatumTypedDict(TypedDict):
    document_data_id: str
    envelope_item_id: str


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

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


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


class TemplateCreateDocumentFromTemplatePrefillFieldDateTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeDate
    id: float
    value: NotRequired[str]


class TemplateCreateDocumentFromTemplatePrefillFieldDate(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeDate

    id: float

    value: Optional[str] = None


class TemplateCreateDocumentFromTemplatePrefillFieldTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class TemplateCreateDocumentFromTemplatePrefillFieldDropdownTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeDropdown
    id: float
    label: NotRequired[str]
    value: NotRequired[str]


class TemplateCreateDocumentFromTemplatePrefillFieldDropdown(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeDropdown

    id: float

    label: Optional[str] = None

    value: Optional[str] = None


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


class TemplateCreateDocumentFromTemplatePrefillFieldCheckboxTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeCheckbox
    id: float
    label: NotRequired[str]
    value: NotRequired[List[str]]


class TemplateCreateDocumentFromTemplatePrefillFieldCheckbox(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeCheckbox

    id: float

    label: Optional[str] = None

    value: Optional[List[str]] = None


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


class TemplateCreateDocumentFromTemplatePrefillFieldRadioTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeRadio
    id: float
    label: NotRequired[str]
    value: NotRequired[str]


class TemplateCreateDocumentFromTemplatePrefillFieldRadio(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeRadio

    id: float

    label: Optional[str] = None

    value: Optional[str] = None


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


class TemplateCreateDocumentFromTemplatePrefillFieldNumberTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeNumber
    id: float
    label: NotRequired[str]
    placeholder: NotRequired[str]
    value: NotRequired[str]


class TemplateCreateDocumentFromTemplatePrefillFieldNumber(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeNumber

    id: float

    label: Optional[str] = None

    placeholder: Optional[str] = None

    value: Optional[str] = None


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


class TemplateCreateDocumentFromTemplatePrefillFieldTextTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeText
    id: float
    label: NotRequired[str]
    placeholder: NotRequired[str]
    value: NotRequired[str]


class TemplateCreateDocumentFromTemplatePrefillFieldText(BaseModel):
    type: TemplateCreateDocumentFromTemplatePrefillFieldTypeText

    id: float

    label: Optional[str] = None

    placeholder: Optional[str] = None

    value: Optional[str] = None


TemplateCreateDocumentFromTemplatePrefillFieldUnionTypedDict = TypeAliasType(
    "TemplateCreateDocumentFromTemplatePrefillFieldUnionTypedDict",
    Union[
        TemplateCreateDocumentFromTemplatePrefillFieldDateTypedDict,
        TemplateCreateDocumentFromTemplatePrefillFieldRadioTypedDict,
        TemplateCreateDocumentFromTemplatePrefillFieldCheckboxTypedDict,
        TemplateCreateDocumentFromTemplatePrefillFieldDropdownTypedDict,
        TemplateCreateDocumentFromTemplatePrefillFieldTextTypedDict,
        TemplateCreateDocumentFromTemplatePrefillFieldNumberTypedDict,
    ],
)


TemplateCreateDocumentFromTemplatePrefillFieldUnion = TypeAliasType(
    "TemplateCreateDocumentFromTemplatePrefillFieldUnion",
    Union[
        TemplateCreateDocumentFromTemplatePrefillFieldDate,
        TemplateCreateDocumentFromTemplatePrefillFieldRadio,
        TemplateCreateDocumentFromTemplatePrefillFieldCheckbox,
        TemplateCreateDocumentFromTemplatePrefillFieldDropdown,
        TemplateCreateDocumentFromTemplatePrefillFieldText,
        TemplateCreateDocumentFromTemplatePrefillFieldNumber,
    ],
)


class TemplateCreateDocumentFromTemplateRequestTypedDict(TypedDict):
    template_id: float
    recipients: List[TemplateCreateDocumentFromTemplateRecipientRequestTypedDict]
    distribute_document: NotRequired[bool]
    custom_document_data_id: NotRequired[str]
    custom_document_data: NotRequired[
        List[TemplateCreateDocumentFromTemplateCustomDocumentDatumTypedDict]
    ]
    folder_id: NotRequired[str]
    prefill_fields: NotRequired[
        List[TemplateCreateDocumentFromTemplatePrefillFieldUnionTypedDict]
    ]


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

    recipients: List[TemplateCreateDocumentFromTemplateRecipientRequest]

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

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

    custom_document_data: Annotated[
        Optional[List[TemplateCreateDocumentFromTemplateCustomDocumentDatum]],
        pydantic.Field(alias="customDocumentData"),
    ] = None

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

    prefill_fields: Annotated[
        Optional[List[TemplateCreateDocumentFromTemplatePrefillFieldUnion]],
        pydantic.Field(alias="prefillFields"),
    ] = None


class TemplateCreateDocumentFromTemplateInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class TemplateCreateDocumentFromTemplateInternalServerErrorIssue(BaseModel):
    message: str


class TemplateCreateDocumentFromTemplateInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[
        List[TemplateCreateDocumentFromTemplateInternalServerErrorIssue]
    ] = None


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

    data: TemplateCreateDocumentFromTemplateInternalServerErrorData = field(hash=False)

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


class TemplateCreateDocumentFromTemplateForbiddenIssue(BaseModel):
    message: str


class TemplateCreateDocumentFromTemplateForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateDocumentFromTemplateForbiddenIssue]] = None


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

    data: TemplateCreateDocumentFromTemplateForbiddenErrorData = field(hash=False)

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


class TemplateCreateDocumentFromTemplateUnauthorizedIssue(BaseModel):
    message: str


class TemplateCreateDocumentFromTemplateUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateDocumentFromTemplateUnauthorizedIssue]] = None


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

    data: TemplateCreateDocumentFromTemplateUnauthorizedErrorData = field(hash=False)

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


class TemplateCreateDocumentFromTemplateBadRequestIssue(BaseModel):
    message: str


class TemplateCreateDocumentFromTemplateBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateDocumentFromTemplateBadRequestIssue]] = None


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

    data: TemplateCreateDocumentFromTemplateBadRequestErrorData = field(hash=False)

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


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


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


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


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


class TemplateCreateDocumentFromTemplateAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[TemplateCreateDocumentFromTemplateGlobalAccessAuth]
    global_action_auth: List[TemplateCreateDocumentFromTemplateGlobalActionAuth]


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

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


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


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


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


class TemplateCreateDocumentFromTemplateDocumentDataTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateDocumentDataType
    id: str
    data: str
    initial_data: str
    envelope_item_id: str


class TemplateCreateDocumentFromTemplateDocumentData(BaseModel):
    type: TemplateCreateDocumentFromTemplateDocumentDataType

    id: str

    data: str

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

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


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


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


class TemplateCreateDocumentFromTemplateEmailSettingsTypedDict(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 TemplateCreateDocumentFromTemplateEmailSettings(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 TemplateCreateDocumentFromTemplateDocumentMetaTypedDict(TypedDict):
    signing_order: TemplateCreateDocumentFromTemplateSigningOrder
    distribution_method: TemplateCreateDocumentFromTemplateDistributionMethod
    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[TemplateCreateDocumentFromTemplateEmailSettingsTypedDict]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]
    password: NotRequired[Nullable[str]]
    document_id: NotRequired[float]


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

    distribution_method: Annotated[
        TemplateCreateDocumentFromTemplateDistributionMethod,
        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[TemplateCreateDocumentFromTemplateEmailSettings],
        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 TemplateCreateDocumentFromTemplateEnvelopeItemTypedDict(TypedDict):
    id: str
    envelope_id: str


class TemplateCreateDocumentFromTemplateEnvelopeItem(BaseModel):
    id: str

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


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


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


class TemplateCreateDocumentFromTemplateFolderTypedDict(TypedDict):
    id: str
    name: str
    type: TemplateCreateDocumentFromTemplateFolderType
    visibility: TemplateCreateDocumentFromTemplateFolderVisibility
    user_id: float
    team_id: float
    pinned: bool
    parent_id: Nullable[str]
    created_at: str
    updated_at: str


class TemplateCreateDocumentFromTemplateFolder(BaseModel):
    id: str

    name: str

    type: TemplateCreateDocumentFromTemplateFolderType

    visibility: TemplateCreateDocumentFromTemplateFolderVisibility

    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 TemplateCreateDocumentFromTemplateRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


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


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


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


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


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


class TemplateCreateDocumentFromTemplateRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[TemplateCreateDocumentFromTemplateAccessAuth]
    action_auth: List[TemplateCreateDocumentFromTemplateActionAuth]


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

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


class TemplateCreateDocumentFromTemplateRecipientResponseTypedDict(TypedDict):
    envelope_id: str
    role: TemplateCreateDocumentFromTemplateRole
    read_status: TemplateCreateDocumentFromTemplateReadStatus
    signing_status: TemplateCreateDocumentFromTemplateSigningStatus
    send_status: TemplateCreateDocumentFromTemplateSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[
        TemplateCreateDocumentFromTemplateRecipientAuthOptionsTypedDict
    ]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: TemplateCreateDocumentFromTemplateRole

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

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

    send_status: Annotated[
        TemplateCreateDocumentFromTemplateSendStatus, 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[TemplateCreateDocumentFromTemplateRecipientAuthOptions],
        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 TemplateCreateDocumentFromTemplateFieldType(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 TemplateCreateDocumentFromTemplateFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class TemplateCreateDocumentFromTemplateValue3TypedDict(TypedDict):
    value: str


class TemplateCreateDocumentFromTemplateValue3(BaseModel):
    value: str


class TemplateCreateDocumentFromTemplateFieldMetaDropdownTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateDocumentFromTemplateValue3TypedDict]]
    default_value: NotRequired[str]


class TemplateCreateDocumentFromTemplateFieldMetaDropdown(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeDropdown

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

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


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


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


class TemplateCreateDocumentFromTemplateValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateCreateDocumentFromTemplateFieldMetaCheckboxTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateDocumentFromTemplateValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[TemplateCreateDocumentFromTemplateDirection2]


class TemplateCreateDocumentFromTemplateFieldMetaCheckbox(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeCheckbox

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

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

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

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


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


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


class TemplateCreateDocumentFromTemplateValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateCreateDocumentFromTemplateFieldMetaRadioTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateDocumentFromTemplateValue1TypedDict]]
    direction: NotRequired[TemplateCreateDocumentFromTemplateDirection1]


class TemplateCreateDocumentFromTemplateFieldMetaRadio(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeRadio

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

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


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


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


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


class TemplateCreateDocumentFromTemplateFieldMetaNumberTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeNumber
    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[TemplateCreateDocumentFromTemplateTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[TemplateCreateDocumentFromTemplateVerticalAlign2]
    ]


class TemplateCreateDocumentFromTemplateFieldMetaNumber(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeNumber

    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[TemplateCreateDocumentFromTemplateTextAlign6],
        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[TemplateCreateDocumentFromTemplateVerticalAlign2],
        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 TemplateCreateDocumentFromTemplateFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class TemplateCreateDocumentFromTemplateFieldMetaTextTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeText
    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[TemplateCreateDocumentFromTemplateTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[TemplateCreateDocumentFromTemplateVerticalAlign1]
    ]


class TemplateCreateDocumentFromTemplateFieldMetaText(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeText

    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[TemplateCreateDocumentFromTemplateTextAlign5],
        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[TemplateCreateDocumentFromTemplateVerticalAlign1],
        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 TemplateCreateDocumentFromTemplateFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class TemplateCreateDocumentFromTemplateFieldMetaDateTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateDocumentFromTemplateTextAlign4]


class TemplateCreateDocumentFromTemplateFieldMetaDate(BaseModel):
    type: TemplateCreateDocumentFromTemplateFieldMetaTypeDate

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


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


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


class TemplateCreateDocumentFromTemplateFieldMetaEmailTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateDocumentFromTemplateTextAlign3]


class TemplateCreateDocumentFromTemplateFieldMetaEmail(BaseModel):
    type: TemplateCreateDocumentFromTemplateTypeEmail

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


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


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


class TemplateCreateDocumentFromTemplateFieldMetaNameTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateDocumentFromTemplateTextAlign2]


class TemplateCreateDocumentFromTemplateFieldMetaName(BaseModel):
    type: TemplateCreateDocumentFromTemplateTypeName

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


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


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


class TemplateCreateDocumentFromTemplateFieldMetaInitialsTypedDict(TypedDict):
    type: TemplateCreateDocumentFromTemplateTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateDocumentFromTemplateTextAlign1]


class TemplateCreateDocumentFromTemplateFieldMetaInitials(BaseModel):
    type: TemplateCreateDocumentFromTemplateTypeInitials

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


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


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


class TemplateCreateDocumentFromTemplateFieldMetaSignature(BaseModel):
    type: TemplateCreateDocumentFromTemplateTypeSignature

    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


TemplateCreateDocumentFromTemplateFieldMetaUnionTypedDict = TypeAliasType(
    "TemplateCreateDocumentFromTemplateFieldMetaUnionTypedDict",
    Union[
        TemplateCreateDocumentFromTemplateFieldMetaSignatureTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaInitialsTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaNameTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaEmailTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaDateTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaRadioTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaDropdownTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaCheckboxTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaTextTypedDict,
        TemplateCreateDocumentFromTemplateFieldMetaNumberTypedDict,
    ],
)


TemplateCreateDocumentFromTemplateFieldMetaUnion = TypeAliasType(
    "TemplateCreateDocumentFromTemplateFieldMetaUnion",
    Union[
        TemplateCreateDocumentFromTemplateFieldMetaSignature,
        TemplateCreateDocumentFromTemplateFieldMetaInitials,
        TemplateCreateDocumentFromTemplateFieldMetaName,
        TemplateCreateDocumentFromTemplateFieldMetaEmail,
        TemplateCreateDocumentFromTemplateFieldMetaDate,
        TemplateCreateDocumentFromTemplateFieldMetaRadio,
        TemplateCreateDocumentFromTemplateFieldMetaDropdown,
        TemplateCreateDocumentFromTemplateFieldMetaCheckbox,
        TemplateCreateDocumentFromTemplateFieldMetaText,
        TemplateCreateDocumentFromTemplateFieldMetaNumber,
    ],
)


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


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

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

    type: TemplateCreateDocumentFromTemplateFieldType

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

    visibility: TemplateCreateDocumentFromTemplateVisibility
    status: TemplateCreateDocumentFromTemplateStatus
    source: TemplateCreateDocumentFromTemplateSource
    id: float
    external_id: Nullable[str]
    user_id: float
    auth_options: Nullable[TemplateCreateDocumentFromTemplateAuthOptionsTypedDict]
    form_values: Nullable[
        Dict[str, TemplateCreateDocumentFromTemplateFormValuesTypedDict]
    ]
    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: TemplateCreateDocumentFromTemplateDocumentDataTypedDict
    document_meta: TemplateCreateDocumentFromTemplateDocumentMetaTypedDict
    envelope_items: List[TemplateCreateDocumentFromTemplateEnvelopeItemTypedDict]
    folder: Nullable[TemplateCreateDocumentFromTemplateFolderTypedDict]
    recipients: List[TemplateCreateDocumentFromTemplateRecipientResponseTypedDict]
    fields: List[TemplateCreateDocumentFromTemplateFieldTypedDict]
    template_id: NotRequired[Nullable[float]]
    document_data_id: NotRequired[str]


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

    visibility: TemplateCreateDocumentFromTemplateVisibility

    status: TemplateCreateDocumentFromTemplateStatus

    source: TemplateCreateDocumentFromTemplateSource

    id: float

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

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

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

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

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

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

    folder: Nullable[TemplateCreateDocumentFromTemplateFolder]

    recipients: List[TemplateCreateDocumentFromTemplateRecipientResponse]

    fields: List[TemplateCreateDocumentFromTemplateField]

    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
