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


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


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


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


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


class TemplateCreateTemplateTemporaryDateFormat(str, Enum):
    YYYY_M_MDD_HH_MM_A = "yyyy-MM-dd hh:mm a"
    YYYY_M_MDD = "yyyy-MM-dd"
    DD_MM_SLASH_YYYY = "dd/MM/yyyy"
    MM_DD_SLASH_YYYY = "MM/dd/yyyy"
    YY_M_MDD = "yy-MM-dd"
    MMMM_DD_COMMA_YYYY = "MMMM dd, yyyy"
    EEEE_MMMM_DD_COMMA_YYYY = "EEEE, MMMM dd, yyyy"
    DD_MM_SLASH_YYYY_HH_MM_A = "dd/MM/yyyy hh:mm a"
    DD_MM_SLASH_YYYY_H_HMM = "dd/MM/yyyy HH:mm"
    MM_DD_SLASH_YYYY_HH_MM_A = "MM/dd/yyyy hh:mm a"
    MM_DD_SLASH_YYYY_H_HMM = "MM/dd/yyyy HH:mm"
    DD_DOT_MM_DOT_YYYY = "dd.MM.yyyy"
    DD_DOT_MM_DOT_YYYY_H_HMM = "dd.MM.yyyy HH:mm"
    YYYY_M_MDD_H_HMM = "yyyy-MM-dd HH:mm"
    YY_M_MDD_HH_MM_A = "yy-MM-dd hh:mm a"
    YY_M_MDD_H_HMM = "yy-MM-dd HH:mm"
    YYYY_M_MDD_H_HMMSS = "yyyy-MM-dd HH:mm:ss"
    MMMM_DD_COMMA_YYYY_HH_MM_A = "MMMM dd, yyyy hh:mm a"
    MMMM_DD_COMMA_YYYY_H_HMM = "MMMM dd, yyyy HH:mm"
    EEEE_MMMM_DD_COMMA_YYYY_HH_MM_A = "EEEE, MMMM dd, yyyy hh:mm a"
    EEEE_MMMM_DD_COMMA_YYYY_H_HMM = "EEEE, MMMM dd, yyyy HH:mm"
    ISO8601_FULL = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"


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


class TemplateCreateTemplateTemporaryMetaEmailSettingsTypedDict(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 TemplateCreateTemplateTemporaryMetaEmailSettings(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 TemplateCreateTemplateTemporaryLanguage(str, Enum):
    DE = "de"
    EN = "en"
    FR = "fr"
    ES = "es"
    IT = "it"
    PL = "pl"


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


class TemplateCreateTemplateTemporaryMetaTypedDict(TypedDict):
    subject: NotRequired[str]
    message: NotRequired[str]
    timezone: NotRequired[str]
    date_format: NotRequired[TemplateCreateTemplateTemporaryDateFormat]
    distribution_method: NotRequired[
        TemplateCreateTemplateTemporaryMetaDistributionMethod
    ]
    email_id: NotRequired[Nullable[str]]
    email_reply_to: NotRequired[Nullable[str]]
    email_settings: NotRequired[
        TemplateCreateTemplateTemporaryMetaEmailSettingsTypedDict
    ]
    redirect_url: NotRequired[str]
    language: NotRequired[TemplateCreateTemplateTemporaryLanguage]
    typed_signature_enabled: NotRequired[bool]
    upload_signature_enabled: NotRequired[bool]
    draw_signature_enabled: NotRequired[bool]
    signing_order: NotRequired[TemplateCreateTemplateTemporarySigningOrderRequest]
    allow_dictate_next_signer: NotRequired[bool]


class TemplateCreateTemplateTemporaryMeta(BaseModel):
    subject: Optional[str] = None

    message: Optional[str] = None

    timezone: Optional[str] = None

    date_format: Annotated[
        Optional[TemplateCreateTemplateTemporaryDateFormat],
        pydantic.Field(alias="dateFormat"),
    ] = None

    distribution_method: Annotated[
        Optional[TemplateCreateTemplateTemporaryMetaDistributionMethod],
        pydantic.Field(alias="distributionMethod"),
    ] = None

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

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

    email_settings: Annotated[
        Optional[TemplateCreateTemplateTemporaryMetaEmailSettings],
        pydantic.Field(alias="emailSettings"),
    ] = None

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

    language: Optional[TemplateCreateTemplateTemporaryLanguage] = None

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

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

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

    signing_order: Annotated[
        Optional[TemplateCreateTemplateTemporarySigningOrderRequest],
        pydantic.Field(alias="signingOrder"),
    ] = None

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "subject",
            "message",
            "timezone",
            "dateFormat",
            "distributionMethod",
            "emailId",
            "emailReplyTo",
            "emailSettings",
            "redirectUrl",
            "language",
            "typedSignatureEnabled",
            "uploadSignatureEnabled",
            "drawSignatureEnabled",
            "signingOrder",
            "allowDictateNextSigner",
        ]
        nullable_fields = ["emailId", "emailReplyTo"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class TemplateCreateTemplateTemporaryTypeLink(str, Enum):
    LINK = "link"


class TemplateCreateTemplateTemporaryAttachmentTypedDict(TypedDict):
    label: str
    data: str
    type: NotRequired[TemplateCreateTemplateTemporaryTypeLink]


class TemplateCreateTemplateTemporaryAttachment(BaseModel):
    label: str

    data: str

    type: Optional[TemplateCreateTemplateTemporaryTypeLink] = (
        TemplateCreateTemplateTemporaryTypeLink.LINK
    )


class TemplateCreateTemplateTemporaryRequestTypedDict(TypedDict):
    title: str
    folder_id: NotRequired[str]
    external_id: NotRequired[Nullable[str]]
    visibility: NotRequired[TemplateCreateTemplateTemporaryVisibilityRequest]
    global_access_auth: NotRequired[
        List[TemplateCreateTemplateTemporaryGlobalAccessAuthRequest]
    ]
    global_action_auth: NotRequired[
        List[TemplateCreateTemplateTemporaryGlobalActionAuthRequest]
    ]
    public_title: NotRequired[str]
    public_description: NotRequired[str]
    type: NotRequired[TemplateCreateTemplateTemporaryTypeRequest]
    meta: NotRequired[TemplateCreateTemplateTemporaryMetaTypedDict]
    attachments: NotRequired[List[TemplateCreateTemplateTemporaryAttachmentTypedDict]]


class TemplateCreateTemplateTemporaryRequest(BaseModel):
    title: str

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

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

    visibility: Optional[TemplateCreateTemplateTemporaryVisibilityRequest] = None

    global_access_auth: Annotated[
        Optional[List[TemplateCreateTemplateTemporaryGlobalAccessAuthRequest]],
        pydantic.Field(alias="globalAccessAuth"),
    ] = None

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

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

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

    type: Optional[TemplateCreateTemplateTemporaryTypeRequest] = None

    meta: Optional[TemplateCreateTemplateTemporaryMeta] = None

    attachments: Optional[List[TemplateCreateTemplateTemporaryAttachment]] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "folderId",
            "externalId",
            "visibility",
            "globalAccessAuth",
            "globalActionAuth",
            "publicTitle",
            "publicDescription",
            "type",
            "meta",
            "attachments",
        ]
        nullable_fields = ["externalId"]
        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 TemplateCreateTemplateTemporaryInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class TemplateCreateTemplateTemporaryInternalServerErrorIssue(BaseModel):
    message: str


class TemplateCreateTemplateTemporaryInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateTemplateTemporaryInternalServerErrorIssue]] = (
        None
    )


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

    data: TemplateCreateTemplateTemporaryInternalServerErrorData = field(hash=False)

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


class TemplateCreateTemplateTemporaryForbiddenIssue(BaseModel):
    message: str


class TemplateCreateTemplateTemporaryForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateTemplateTemporaryForbiddenIssue]] = None


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

    data: TemplateCreateTemplateTemporaryForbiddenErrorData = field(hash=False)

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


class TemplateCreateTemplateTemporaryUnauthorizedIssue(BaseModel):
    message: str


class TemplateCreateTemplateTemporaryUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateTemplateTemporaryUnauthorizedIssue]] = None


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

    data: TemplateCreateTemplateTemporaryUnauthorizedErrorData = field(hash=False)

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


class TemplateCreateTemplateTemporaryBadRequestIssue(BaseModel):
    message: str


class TemplateCreateTemplateTemporaryBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateCreateTemplateTemporaryBadRequestIssue]] = None


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

    data: TemplateCreateTemplateTemporaryBadRequestErrorData = field(hash=False)

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


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


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


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


class TemplateCreateTemplateTemporaryAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[TemplateCreateTemplateTemporaryGlobalAccessAuthResponse]
    global_action_auth: List[TemplateCreateTemplateTemporaryGlobalActionAuthResponse]


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

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


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


class TemplateCreateTemplateTemporaryTemplateDocumentDataTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTemplateDocumentDataType
    id: str
    data: str
    initial_data: str
    envelope_item_id: str


class TemplateCreateTemplateTemporaryTemplateDocumentData(BaseModel):
    type: TemplateCreateTemplateTemporaryTemplateDocumentDataType

    id: str

    data: str

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

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


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


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


class TemplateCreateTemplateTemporaryTemplateMetaEmailSettingsTypedDict(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 TemplateCreateTemplateTemporaryTemplateMetaEmailSettings(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 TemplateCreateTemplateTemporaryTemplateMetaTypedDict(TypedDict):
    id: str
    subject: Nullable[str]
    message: Nullable[str]
    timezone: Nullable[str]
    date_format: Nullable[str]
    signing_order: TemplateCreateTemplateTemporaryTemplateMetaSigningOrder
    typed_signature_enabled: bool
    upload_signature_enabled: bool
    draw_signature_enabled: bool
    allow_dictate_next_signer: bool
    distribution_method: TemplateCreateTemplateTemporaryTemplateMetaDistributionMethod
    redirect_url: Nullable[str]
    language: str
    email_settings: Nullable[
        TemplateCreateTemplateTemporaryTemplateMetaEmailSettingsTypedDict
    ]
    email_id: Nullable[str]
    email_reply_to: Nullable[str]
    template_id: Nullable[float]


class TemplateCreateTemplateTemporaryTemplateMeta(BaseModel):
    id: str

    subject: Nullable[str]

    message: Nullable[str]

    timezone: Nullable[str]

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

    signing_order: Annotated[
        TemplateCreateTemplateTemporaryTemplateMetaSigningOrder,
        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[
        TemplateCreateTemplateTemporaryTemplateMetaDistributionMethod,
        pydantic.Field(alias="distributionMethod"),
    ]

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

    language: str

    email_settings: Annotated[
        Nullable[TemplateCreateTemplateTemporaryTemplateMetaEmailSettings],
        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 TemplateCreateTemplateTemporaryDirectLinkTypedDict(TypedDict):
    id: str
    envelope_id: str
    token: str
    created_at: str
    enabled: bool
    direct_template_recipient_id: float
    template_id: float


class TemplateCreateTemplateTemporaryDirectLink(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 TemplateCreateTemplateTemporaryUserTypedDict(TypedDict):
    id: float
    name: Nullable[str]
    email: str


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


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


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


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


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


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


class TemplateCreateTemplateTemporaryRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[TemplateCreateTemplateTemporaryAccessAuth]
    action_auth: List[TemplateCreateTemplateTemporaryActionAuth]


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

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


class TemplateCreateTemplateTemporaryRecipientTypedDict(TypedDict):
    envelope_id: str
    role: TemplateCreateTemplateTemporaryRole
    read_status: TemplateCreateTemplateTemporaryReadStatus
    signing_status: TemplateCreateTemplateTemporarySigningStatus
    send_status: TemplateCreateTemplateTemporarySendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[TemplateCreateTemplateTemporaryRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: TemplateCreateTemplateTemporaryRole

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

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

    send_status: Annotated[
        TemplateCreateTemplateTemporarySendStatus, 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[TemplateCreateTemplateTemporaryRecipientAuthOptions],
        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 TemplateCreateTemplateTemporaryFieldType(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 TemplateCreateTemplateTemporaryTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class TemplateCreateTemplateTemporaryValue3TypedDict(TypedDict):
    value: str


class TemplateCreateTemplateTemporaryValue3(BaseModel):
    value: str


class TemplateCreateTemplateTemporaryFieldMetaDropdownTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateTemplateTemporaryValue3TypedDict]]
    default_value: NotRequired[str]


class TemplateCreateTemplateTemporaryFieldMetaDropdown(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeDropdown

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

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


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


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


class TemplateCreateTemplateTemporaryValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateCreateTemplateTemporaryFieldMetaCheckboxTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateTemplateTemporaryValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[TemplateCreateTemplateTemporaryDirection2]


class TemplateCreateTemplateTemporaryFieldMetaCheckbox(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeCheckbox

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

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

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

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


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


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


class TemplateCreateTemplateTemporaryValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateCreateTemplateTemporaryFieldMetaRadioTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateCreateTemplateTemporaryValue1TypedDict]]
    direction: NotRequired[TemplateCreateTemplateTemporaryDirection1]


class TemplateCreateTemplateTemporaryFieldMetaRadio(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeRadio

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

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


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


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


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


class TemplateCreateTemplateTemporaryFieldMetaNumberTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeNumber
    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[TemplateCreateTemplateTemporaryTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateCreateTemplateTemporaryVerticalAlign2]]


class TemplateCreateTemplateTemporaryFieldMetaNumber(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeNumber

    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[TemplateCreateTemplateTemporaryTextAlign6],
        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[TemplateCreateTemplateTemporaryVerticalAlign2],
        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 TemplateCreateTemplateTemporaryTypeText(str, Enum):
    TEXT = "text"


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


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


class TemplateCreateTemplateTemporaryFieldMetaTextTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeText
    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[TemplateCreateTemplateTemporaryTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateCreateTemplateTemporaryVerticalAlign1]]


class TemplateCreateTemplateTemporaryFieldMetaText(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeText

    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[TemplateCreateTemplateTemporaryTextAlign5],
        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[TemplateCreateTemplateTemporaryVerticalAlign1],
        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 TemplateCreateTemplateTemporaryTypeDate(str, Enum):
    DATE = "date"


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


class TemplateCreateTemplateTemporaryFieldMetaDateTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateTemplateTemporaryTextAlign4]


class TemplateCreateTemplateTemporaryFieldMetaDate(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeDate

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


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


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


class TemplateCreateTemplateTemporaryFieldMetaEmailTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateTemplateTemporaryTextAlign3]


class TemplateCreateTemplateTemporaryFieldMetaEmail(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeEmail

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


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


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


class TemplateCreateTemplateTemporaryFieldMetaNameTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateTemplateTemporaryTextAlign2]


class TemplateCreateTemplateTemporaryFieldMetaName(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeName

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


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


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


class TemplateCreateTemplateTemporaryFieldMetaInitialsTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateCreateTemplateTemporaryTextAlign1]


class TemplateCreateTemplateTemporaryFieldMetaInitials(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeInitials

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


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


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


class TemplateCreateTemplateTemporaryFieldMetaSignature(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeSignature

    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


TemplateCreateTemplateTemporaryFieldMetaUnionTypedDict = TypeAliasType(
    "TemplateCreateTemplateTemporaryFieldMetaUnionTypedDict",
    Union[
        TemplateCreateTemplateTemporaryFieldMetaSignatureTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaInitialsTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaNameTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaEmailTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaDateTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaRadioTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaDropdownTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaCheckboxTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaTextTypedDict,
        TemplateCreateTemplateTemporaryFieldMetaNumberTypedDict,
    ],
)


TemplateCreateTemplateTemporaryFieldMetaUnion = TypeAliasType(
    "TemplateCreateTemplateTemporaryFieldMetaUnion",
    Union[
        TemplateCreateTemplateTemporaryFieldMetaSignature,
        TemplateCreateTemplateTemporaryFieldMetaInitials,
        TemplateCreateTemplateTemporaryFieldMetaName,
        TemplateCreateTemplateTemporaryFieldMetaEmail,
        TemplateCreateTemplateTemporaryFieldMetaDate,
        TemplateCreateTemplateTemporaryFieldMetaRadio,
        TemplateCreateTemplateTemporaryFieldMetaDropdown,
        TemplateCreateTemplateTemporaryFieldMetaCheckbox,
        TemplateCreateTemplateTemporaryFieldMetaText,
        TemplateCreateTemplateTemporaryFieldMetaNumber,
    ],
)


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


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

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

    type: TemplateCreateTemplateTemporaryFieldType

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


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


class TemplateCreateTemplateTemporaryFolderTypedDict(TypedDict):
    id: str
    name: str
    type: TemplateCreateTemplateTemporaryFolderType
    visibility: TemplateCreateTemplateTemporaryFolderVisibility
    user_id: float
    team_id: float
    pinned: bool
    parent_id: Nullable[str]
    created_at: str
    updated_at: str


class TemplateCreateTemplateTemporaryFolder(BaseModel):
    id: str

    name: str

    type: TemplateCreateTemplateTemporaryFolderType

    visibility: TemplateCreateTemplateTemporaryFolderVisibility

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


class TemplateCreateTemplateTemporaryEnvelopeItem(BaseModel):
    id: str

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


class TemplateCreateTemplateTemporaryTemplateTypedDict(TypedDict):
    type: TemplateCreateTemplateTemporaryTypeResponse
    visibility: TemplateCreateTemplateTemporaryVisibilityResponse
    id: float
    external_id: Nullable[str]
    title: str
    user_id: float
    team_id: float
    auth_options: Nullable[TemplateCreateTemplateTemporaryAuthOptionsTypedDict]
    created_at: str
    updated_at: str
    public_title: str
    public_description: str
    folder_id: Nullable[str]
    envelope_id: str
    template_document_data: TemplateCreateTemplateTemporaryTemplateDocumentDataTypedDict
    template_meta: TemplateCreateTemplateTemporaryTemplateMetaTypedDict
    direct_link: Nullable[TemplateCreateTemplateTemporaryDirectLinkTypedDict]
    user: TemplateCreateTemplateTemporaryUserTypedDict
    recipients: List[TemplateCreateTemplateTemporaryRecipientTypedDict]
    fields: List[TemplateCreateTemplateTemporaryFieldTypedDict]
    folder: Nullable[TemplateCreateTemplateTemporaryFolderTypedDict]
    envelope_items: List[TemplateCreateTemplateTemporaryEnvelopeItemTypedDict]
    template_document_data_id: NotRequired[str]


class TemplateCreateTemplateTemporaryTemplate(BaseModel):
    type: TemplateCreateTemplateTemporaryTypeResponse

    visibility: TemplateCreateTemplateTemporaryVisibilityResponse

    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[TemplateCreateTemplateTemporaryAuthOptions],
        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[
        TemplateCreateTemplateTemporaryTemplateDocumentData,
        pydantic.Field(alias="templateDocumentData"),
    ]

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

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

    user: TemplateCreateTemplateTemporaryUser

    recipients: List[TemplateCreateTemplateTemporaryRecipient]

    fields: List[TemplateCreateTemplateTemporaryField]

    folder: Nullable[TemplateCreateTemplateTemporaryFolder]

    envelope_items: Annotated[
        List[TemplateCreateTemplateTemporaryEnvelopeItem],
        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


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

    template: TemplateCreateTemplateTemporaryTemplateTypedDict
    upload_url: str


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

    template: TemplateCreateTemplateTemporaryTemplate

    upload_url: Annotated[str, pydantic.Field(alias="uploadUrl")]
