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


class TemplateGetTemplateByIDRequestTypedDict(TypedDict):
    template_id: float


class TemplateGetTemplateByIDRequest(BaseModel):
    template_id: Annotated[
        float,
        pydantic.Field(alias="templateId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]


class TemplateGetTemplateByIDInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class TemplateGetTemplateByIDInternalServerErrorIssue(BaseModel):
    message: str


class TemplateGetTemplateByIDInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateGetTemplateByIDInternalServerErrorIssue]] = None


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

    data: TemplateGetTemplateByIDInternalServerErrorData = field(hash=False)

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


class TemplateGetTemplateByIDNotFoundIssue(BaseModel):
    message: str


class TemplateGetTemplateByIDNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateGetTemplateByIDNotFoundIssue]] = None


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

    data: TemplateGetTemplateByIDNotFoundErrorData = field(hash=False)

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


class TemplateGetTemplateByIDForbiddenIssue(BaseModel):
    message: str


class TemplateGetTemplateByIDForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateGetTemplateByIDForbiddenIssue]] = None


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

    data: TemplateGetTemplateByIDForbiddenErrorData = field(hash=False)

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


class TemplateGetTemplateByIDUnauthorizedIssue(BaseModel):
    message: str


class TemplateGetTemplateByIDUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateGetTemplateByIDUnauthorizedIssue]] = None


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

    data: TemplateGetTemplateByIDUnauthorizedErrorData = field(hash=False)

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


class TemplateGetTemplateByIDBadRequestIssue(BaseModel):
    message: str


class TemplateGetTemplateByIDBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateGetTemplateByIDBadRequestIssue]] = None


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

    data: TemplateGetTemplateByIDBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: TemplateGetTemplateByIDBadRequestErrorData,
        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 TemplateGetTemplateByIDType(str, Enum):
    PUBLIC = "PUBLIC"
    PRIVATE = "PRIVATE"


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


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


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


class TemplateGetTemplateByIDAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[TemplateGetTemplateByIDGlobalAccessAuth]
    global_action_auth: List[TemplateGetTemplateByIDGlobalActionAuth]


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

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


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


class TemplateGetTemplateByIDTemplateDocumentDataTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTemplateDocumentDataType
    id: str
    data: str
    initial_data: str
    envelope_item_id: str


class TemplateGetTemplateByIDTemplateDocumentData(BaseModel):
    type: TemplateGetTemplateByIDTemplateDocumentDataType

    id: str

    data: str

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

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


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


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


class TemplateGetTemplateByIDEmailSettingsTypedDict(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 TemplateGetTemplateByIDEmailSettings(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 TemplateGetTemplateByIDTemplateMetaTypedDict(TypedDict):
    id: str
    subject: Nullable[str]
    message: Nullable[str]
    timezone: Nullable[str]
    date_format: Nullable[str]
    signing_order: TemplateGetTemplateByIDSigningOrder
    typed_signature_enabled: bool
    upload_signature_enabled: bool
    draw_signature_enabled: bool
    allow_dictate_next_signer: bool
    distribution_method: TemplateGetTemplateByIDDistributionMethod
    redirect_url: Nullable[str]
    language: str
    email_settings: Nullable[TemplateGetTemplateByIDEmailSettingsTypedDict]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]
    template_id: Nullable[float]


class TemplateGetTemplateByIDTemplateMeta(BaseModel):
    id: str

    subject: Nullable[str]

    message: Nullable[str]

    timezone: Nullable[str]

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

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

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

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

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

    language: str

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

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

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "subject",
            "message",
            "timezone",
            "dateFormat",
            "redirectUrl",
            "emailSettings",
            "emailId",
            "emailReplyTo",
            "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 TemplateGetTemplateByIDDirectLinkTypedDict(TypedDict):
    id: str
    envelope_id: str
    token: str
    created_at: str
    enabled: bool
    direct_template_recipient_id: float
    template_id: float


class TemplateGetTemplateByIDDirectLink(BaseModel):
    id: str

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

    token: str

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

    enabled: bool

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

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


class TemplateGetTemplateByIDUserTypedDict(TypedDict):
    id: float
    name: Nullable[str]
    email: str


class TemplateGetTemplateByIDUser(BaseModel):
    id: float

    name: Nullable[str]

    email: str

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


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


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


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


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


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


class TemplateGetTemplateByIDRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[TemplateGetTemplateByIDAccessAuth]
    action_auth: List[TemplateGetTemplateByIDActionAuth]


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

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


class TemplateGetTemplateByIDRecipientTypedDict(TypedDict):
    envelope_id: str
    role: TemplateGetTemplateByIDRole
    read_status: TemplateGetTemplateByIDReadStatus
    signing_status: TemplateGetTemplateByIDSigningStatus
    send_status: TemplateGetTemplateByIDSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[TemplateGetTemplateByIDRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: TemplateGetTemplateByIDRole

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

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

    send_status: Annotated[
        TemplateGetTemplateByIDSendStatus, 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[TemplateGetTemplateByIDRecipientAuthOptions],
        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 TemplateGetTemplateByIDFieldType(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 TemplateGetTemplateByIDTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class TemplateGetTemplateByIDValue3TypedDict(TypedDict):
    value: str


class TemplateGetTemplateByIDValue3(BaseModel):
    value: str


class TemplateGetTemplateByIDFieldMetaDropdownTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetTemplateByIDValue3TypedDict]]
    default_value: NotRequired[str]


class TemplateGetTemplateByIDFieldMetaDropdown(BaseModel):
    type: TemplateGetTemplateByIDTypeDropdown

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

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


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


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


class TemplateGetTemplateByIDValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateGetTemplateByIDFieldMetaCheckboxTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetTemplateByIDValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[TemplateGetTemplateByIDDirection2]


class TemplateGetTemplateByIDFieldMetaCheckbox(BaseModel):
    type: TemplateGetTemplateByIDTypeCheckbox

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

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

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

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


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


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


class TemplateGetTemplateByIDValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateGetTemplateByIDFieldMetaRadioTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetTemplateByIDValue1TypedDict]]
    direction: NotRequired[TemplateGetTemplateByIDDirection1]


class TemplateGetTemplateByIDFieldMetaRadio(BaseModel):
    type: TemplateGetTemplateByIDTypeRadio

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

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


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


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


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


class TemplateGetTemplateByIDFieldMetaNumberTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeNumber
    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[TemplateGetTemplateByIDTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateGetTemplateByIDVerticalAlign2]]


class TemplateGetTemplateByIDFieldMetaNumber(BaseModel):
    type: TemplateGetTemplateByIDTypeNumber

    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[TemplateGetTemplateByIDTextAlign6], 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[TemplateGetTemplateByIDVerticalAlign2],
        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 TemplateGetTemplateByIDTypeText(str, Enum):
    TEXT = "text"


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


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


class TemplateGetTemplateByIDFieldMetaTextTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeText
    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[TemplateGetTemplateByIDTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateGetTemplateByIDVerticalAlign1]]


class TemplateGetTemplateByIDFieldMetaText(BaseModel):
    type: TemplateGetTemplateByIDTypeText

    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[TemplateGetTemplateByIDTextAlign5], 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[TemplateGetTemplateByIDVerticalAlign1],
        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 TemplateGetTemplateByIDTypeDate(str, Enum):
    DATE = "date"


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


class TemplateGetTemplateByIDFieldMetaDateTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetTemplateByIDTextAlign4]


class TemplateGetTemplateByIDFieldMetaDate(BaseModel):
    type: TemplateGetTemplateByIDTypeDate

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


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


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


class TemplateGetTemplateByIDFieldMetaEmailTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetTemplateByIDTextAlign3]


class TemplateGetTemplateByIDFieldMetaEmail(BaseModel):
    type: TemplateGetTemplateByIDTypeEmail

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


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


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


class TemplateGetTemplateByIDFieldMetaNameTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetTemplateByIDTextAlign2]


class TemplateGetTemplateByIDFieldMetaName(BaseModel):
    type: TemplateGetTemplateByIDTypeName

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


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


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


class TemplateGetTemplateByIDFieldMetaInitialsTypedDict(TypedDict):
    type: TemplateGetTemplateByIDTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetTemplateByIDTextAlign1]


class TemplateGetTemplateByIDFieldMetaInitials(BaseModel):
    type: TemplateGetTemplateByIDTypeInitials

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


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


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


class TemplateGetTemplateByIDFieldMetaSignature(BaseModel):
    type: TemplateGetTemplateByIDTypeSignature

    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


TemplateGetTemplateByIDFieldMetaUnionTypedDict = TypeAliasType(
    "TemplateGetTemplateByIDFieldMetaUnionTypedDict",
    Union[
        TemplateGetTemplateByIDFieldMetaSignatureTypedDict,
        TemplateGetTemplateByIDFieldMetaInitialsTypedDict,
        TemplateGetTemplateByIDFieldMetaNameTypedDict,
        TemplateGetTemplateByIDFieldMetaEmailTypedDict,
        TemplateGetTemplateByIDFieldMetaDateTypedDict,
        TemplateGetTemplateByIDFieldMetaRadioTypedDict,
        TemplateGetTemplateByIDFieldMetaDropdownTypedDict,
        TemplateGetTemplateByIDFieldMetaCheckboxTypedDict,
        TemplateGetTemplateByIDFieldMetaTextTypedDict,
        TemplateGetTemplateByIDFieldMetaNumberTypedDict,
    ],
)


TemplateGetTemplateByIDFieldMetaUnion = TypeAliasType(
    "TemplateGetTemplateByIDFieldMetaUnion",
    Union[
        TemplateGetTemplateByIDFieldMetaSignature,
        TemplateGetTemplateByIDFieldMetaInitials,
        TemplateGetTemplateByIDFieldMetaName,
        TemplateGetTemplateByIDFieldMetaEmail,
        TemplateGetTemplateByIDFieldMetaDate,
        TemplateGetTemplateByIDFieldMetaRadio,
        TemplateGetTemplateByIDFieldMetaDropdown,
        TemplateGetTemplateByIDFieldMetaCheckbox,
        TemplateGetTemplateByIDFieldMetaText,
        TemplateGetTemplateByIDFieldMetaNumber,
    ],
)


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


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

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

    type: TemplateGetTemplateByIDFieldType

    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[TemplateGetTemplateByIDFieldMetaUnion],
        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 TemplateGetTemplateByIDFolderType(str, Enum):
    DOCUMENT = "DOCUMENT"
    TEMPLATE = "TEMPLATE"


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


class TemplateGetTemplateByIDFolderTypedDict(TypedDict):
    id: str
    name: str
    type: TemplateGetTemplateByIDFolderType
    visibility: TemplateGetTemplateByIDFolderVisibility
    user_id: float
    team_id: float
    pinned: bool
    parent_id: Nullable[str]
    created_at: str
    updated_at: str


class TemplateGetTemplateByIDFolder(BaseModel):
    id: str

    name: str

    type: TemplateGetTemplateByIDFolderType

    visibility: TemplateGetTemplateByIDFolderVisibility

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


class TemplateGetTemplateByIDEnvelopeItem(BaseModel):
    id: str

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


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

    type: TemplateGetTemplateByIDType
    visibility: TemplateGetTemplateByIDVisibility
    id: float
    external_id: Nullable[str]
    title: str
    user_id: float
    team_id: float
    auth_options: Nullable[TemplateGetTemplateByIDAuthOptionsTypedDict]
    created_at: str
    updated_at: str
    public_title: str
    public_description: str
    folder_id: Nullable[str]
    envelope_id: str
    template_document_data: TemplateGetTemplateByIDTemplateDocumentDataTypedDict
    template_meta: TemplateGetTemplateByIDTemplateMetaTypedDict
    direct_link: Nullable[TemplateGetTemplateByIDDirectLinkTypedDict]
    user: TemplateGetTemplateByIDUserTypedDict
    recipients: List[TemplateGetTemplateByIDRecipientTypedDict]
    fields: List[TemplateGetTemplateByIDFieldTypedDict]
    folder: Nullable[TemplateGetTemplateByIDFolderTypedDict]
    envelope_items: List[TemplateGetTemplateByIDEnvelopeItemTypedDict]
    template_document_data_id: NotRequired[str]


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

    type: TemplateGetTemplateByIDType

    visibility: TemplateGetTemplateByIDVisibility

    id: float

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

    title: str

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

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

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

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

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

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

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

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

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

    template_document_data: Annotated[
        TemplateGetTemplateByIDTemplateDocumentData,
        pydantic.Field(alias="templateDocumentData"),
    ]

    template_meta: Annotated[
        TemplateGetTemplateByIDTemplateMeta, pydantic.Field(alias="templateMeta")
    ]

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

    user: TemplateGetTemplateByIDUser

    recipients: List[TemplateGetTemplateByIDRecipient]

    fields: List[TemplateGetTemplateByIDField]

    folder: Nullable[TemplateGetTemplateByIDFolder]

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

    template_document_data_id: Annotated[
        Optional[str], pydantic.Field(alias="templateDocumentDataId")
    ] = ""

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