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

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


class QueryParamType(str, Enum):
    r"""Filter templates by type."""

    PUBLIC = "PUBLIC"
    PRIVATE = "PRIVATE"


class TemplateFindTemplatesRequestTypedDict(TypedDict):
    query: NotRequired[str]
    r"""The search query."""
    page: NotRequired[float]
    r"""The pagination page number, starts at 1."""
    per_page: NotRequired[float]
    r"""The number of items per page."""
    type: NotRequired[QueryParamType]
    r"""Filter templates by type."""


class TemplateFindTemplatesRequest(BaseModel):
    query: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The search query."""

    page: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The pagination page number, starts at 1."""

    per_page: Annotated[
        Optional[float],
        pydantic.Field(alias="perPage"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The number of items per page."""

    type: Annotated[
        Optional[QueryParamType],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter templates by type."""


class TemplateFindTemplatesTemplatesResponseIssuesTypedDict(TypedDict):
    message: str


class TemplateFindTemplatesTemplatesResponseIssues(BaseModel):
    message: str


class TemplateFindTemplatesTemplatesResponse500ResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateFindTemplatesTemplatesResponseIssues]] = None


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

    data: TemplateFindTemplatesTemplatesResponse500ResponseBodyData

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

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


class TemplateFindTemplatesTemplatesIssuesTypedDict(TypedDict):
    message: str


class TemplateFindTemplatesTemplatesIssues(BaseModel):
    message: str


class TemplateFindTemplatesTemplatesResponseResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateFindTemplatesTemplatesIssues]] = None


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

    data: TemplateFindTemplatesTemplatesResponseResponseBodyData

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

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


class TemplateFindTemplatesIssuesTypedDict(TypedDict):
    message: str


class TemplateFindTemplatesIssues(BaseModel):
    message: str


class TemplateFindTemplatesTemplatesResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[TemplateFindTemplatesIssues]] = None


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

    data: TemplateFindTemplatesTemplatesResponseBodyData

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

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


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


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


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

    ACCOUNT = "ACCOUNT"


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

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


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


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

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

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

        serialized = handler(self)

        m = {}

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

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

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

        return m


class TemplateFindTemplatesTeamTypedDict(TypedDict):
    id: int
    url: str


class TemplateFindTemplatesTeam(BaseModel):
    id: int

    url: str


class TemplateFindTemplatesTemplatesType(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 TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataFields9Type(
    str, Enum
):
    DROPDOWN = "dropdown"


class TemplateFindTemplatesFieldMetaTemplatesResponseValuesTypedDict(TypedDict):
    value: str


class TemplateFindTemplatesFieldMetaTemplatesResponseValues(BaseModel):
    value: str


class TemplateFindTemplatesFieldMeta9TypedDict(TypedDict):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[TemplateFindTemplatesFieldMetaTemplatesResponseValuesTypedDict]
    ]
    default_value: NotRequired[str]


class TemplateFindTemplatesFieldMeta9(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataFields9Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[List[TemplateFindTemplatesFieldMetaTemplatesResponseValues]] = None

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


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


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


class TemplateFindTemplatesFieldMetaTemplatesValues(BaseModel):
    id: float

    checked: bool

    value: str


class TemplateFindTemplatesFieldMeta8TypedDict(TypedDict):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[TemplateFindTemplatesFieldMetaTemplatesValuesTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class TemplateFindTemplatesFieldMeta8(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataFieldsType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[List[TemplateFindTemplatesFieldMetaTemplatesValues]] = None

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

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


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


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


class TemplateFindTemplatesFieldMetaValues(BaseModel):
    id: float

    checked: bool

    value: str


class TemplateFindTemplatesFieldMeta7TypedDict(TypedDict):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[TemplateFindTemplatesFieldMetaValuesTypedDict]]


class TemplateFindTemplatesFieldMeta7(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyDataType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    values: Optional[List[TemplateFindTemplatesFieldMetaValues]] = None


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


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


class TemplateFindTemplatesFieldMeta6(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONResponseBodyType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    value: Optional[str] = None

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

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

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


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


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


class TemplateFindTemplatesFieldMeta5(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200ApplicationJSONType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

    text: Optional[str] = None

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

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


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


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


class TemplateFindTemplatesFieldMeta4(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponse200Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


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


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


class TemplateFindTemplatesFieldMeta3(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesResponseType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


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


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


class TemplateFindTemplatesFieldMeta2(BaseModel):
    type: TemplateFindTemplatesFieldMetaTemplatesType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


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


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


class TemplateFindTemplatesFieldMeta1(BaseModel):
    type: TemplateFindTemplatesFieldMetaType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


TemplateFindTemplatesFieldMetaTypedDict = TypeAliasType(
    "TemplateFindTemplatesFieldMetaTypedDict",
    Union[
        TemplateFindTemplatesFieldMeta1TypedDict,
        TemplateFindTemplatesFieldMeta2TypedDict,
        TemplateFindTemplatesFieldMeta3TypedDict,
        TemplateFindTemplatesFieldMeta4TypedDict,
        TemplateFindTemplatesFieldMeta7TypedDict,
        TemplateFindTemplatesFieldMeta9TypedDict,
        TemplateFindTemplatesFieldMeta5TypedDict,
        TemplateFindTemplatesFieldMeta8TypedDict,
        TemplateFindTemplatesFieldMeta6TypedDict,
    ],
)


TemplateFindTemplatesFieldMeta = TypeAliasType(
    "TemplateFindTemplatesFieldMeta",
    Union[
        TemplateFindTemplatesFieldMeta1,
        TemplateFindTemplatesFieldMeta2,
        TemplateFindTemplatesFieldMeta3,
        TemplateFindTemplatesFieldMeta4,
        TemplateFindTemplatesFieldMeta7,
        TemplateFindTemplatesFieldMeta9,
        TemplateFindTemplatesFieldMeta5,
        TemplateFindTemplatesFieldMeta8,
        TemplateFindTemplatesFieldMeta6,
    ],
)


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


class TemplateFindTemplatesFields(BaseModel):
    type: TemplateFindTemplatesTemplatesType

    id: int

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

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

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

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

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

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

    inserted: bool

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

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

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

    width: Optional[Any] = None

    height: Optional[Any] = None

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

        serialized = handler(self)

        m = {}

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

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

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

        return m


class TemplateFindTemplatesRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"


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


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


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


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

    ACCOUNT = "ACCOUNT"


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

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


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


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

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

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

        serialized = handler(self)

        m = {}

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

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

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

        return m


class TemplateFindTemplatesRecipientsTypedDict(TypedDict):
    role: TemplateFindTemplatesRole
    read_status: TemplateFindTemplatesReadStatus
    signing_status: TemplateFindTemplatesSigningStatus
    send_status: TemplateFindTemplatesSendStatus
    id: int
    document_id: Nullable[int]
    template_id: Nullable[int]
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[TemplateFindTemplatesTemplatesAuthOptionsTypedDict]
    signing_order: Nullable[float]
    r"""The order in which the recipient should sign the document. Only works if the document is set to sequential signing."""
    rejection_reason: Nullable[str]


class TemplateFindTemplatesRecipients(BaseModel):
    role: TemplateFindTemplatesRole

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

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

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

    id: int

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

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

    email: str

    name: str

    token: str

    document_deleted_at: Annotated[
        Nullable[str], pydantic.Field(alias="documentDeletedAt")
    ]

    expired: Nullable[str]

    signed_at: Annotated[Nullable[str], pydantic.Field(alias="signedAt")]

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

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

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

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

        serialized = handler(self)

        m = {}

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

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

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

        return m


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


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


class TemplateFindTemplatesTemplateMetaTypedDict(TypedDict):
    signing_order: Nullable[TemplateFindTemplatesSigningOrder]
    distribution_method: TemplateFindTemplatesDistributionMethod


class TemplateFindTemplatesTemplateMeta(BaseModel):
    signing_order: Annotated[
        Nullable[TemplateFindTemplatesSigningOrder],
        pydantic.Field(alias="signingOrder"),
    ]

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

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

        serialized = handler(self)

        m = {}

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

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

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

        return m


class TemplateFindTemplatesDirectLinkTypedDict(TypedDict):
    token: str
    enabled: bool


class TemplateFindTemplatesDirectLink(BaseModel):
    token: str

    enabled: bool


class TemplateFindTemplatesDataTypedDict(TypedDict):
    type: TemplateFindTemplatesType
    visibility: TemplateFindTemplatesVisibility
    id: int
    external_id: Nullable[str]
    title: str
    user_id: int
    team_id: Nullable[int]
    auth_options: Nullable[TemplateFindTemplatesAuthOptionsTypedDict]
    template_document_data_id: str
    created_at: str
    updated_at: str
    public_title: str
    public_description: str
    team: Nullable[TemplateFindTemplatesTeamTypedDict]
    fields: List[TemplateFindTemplatesFieldsTypedDict]
    recipients: List[TemplateFindTemplatesRecipientsTypedDict]
    template_meta: Nullable[TemplateFindTemplatesTemplateMetaTypedDict]
    direct_link: Nullable[TemplateFindTemplatesDirectLinkTypedDict]


class TemplateFindTemplatesData(BaseModel):
    type: TemplateFindTemplatesType

    visibility: TemplateFindTemplatesVisibility

    id: int

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

    title: str

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

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

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

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

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

    team: Nullable[TemplateFindTemplatesTeam]

    fields: List[TemplateFindTemplatesFields]

    recipients: List[TemplateFindTemplatesRecipients]

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "externalId",
            "teamId",
            "authOptions",
            "team",
            "templateMeta",
            "directLink",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

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

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

        return m


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

    data: List[TemplateFindTemplatesDataTypedDict]
    count: float
    r"""The total number of items."""
    current_page: float
    r"""The current page number, starts at 1."""
    per_page: float
    r"""The number of items per page."""
    total_pages: float
    r"""The total number of pages."""


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

    data: List[TemplateFindTemplatesData]

    count: float
    r"""The total number of items."""

    current_page: Annotated[float, pydantic.Field(alias="currentPage")]
    r"""The current page number, starts at 1."""

    per_page: Annotated[float, pydantic.Field(alias="perPage")]
    r"""The number of items per page."""

    total_pages: Annotated[float, pydantic.Field(alias="totalPages")]
    r"""The total number of pages."""
