"""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 get_discriminator
from enum import Enum
import httpx
import pydantic
from pydantic import Discriminator, Tag, model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class TemplateGetManyRequestTypedDict(TypedDict):
    template_ids: List[float]


class TemplateGetManyRequest(BaseModel):
    template_ids: Annotated[List[float], pydantic.Field(alias="templateIds")]


class TemplateGetManyInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class TemplateGetManyInternalServerErrorIssue(BaseModel):
    message: str


class TemplateGetManyInternalServerErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[TemplateGetManyInternalServerErrorIssue]] = None


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

    data: TemplateGetManyInternalServerErrorData = field(hash=False)

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


class TemplateGetManyForbiddenIssue(BaseModel):
    message: str


class TemplateGetManyForbiddenErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[TemplateGetManyForbiddenIssue]] = None


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

    data: TemplateGetManyForbiddenErrorData = field(hash=False)

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


class TemplateGetManyUnauthorizedIssue(BaseModel):
    message: str


class TemplateGetManyUnauthorizedErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[TemplateGetManyUnauthorizedIssue]] = None


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

    data: TemplateGetManyUnauthorizedErrorData = field(hash=False)

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


class TemplateGetManyBadRequestIssue(BaseModel):
    message: str


class TemplateGetManyBadRequestErrorData(BaseModel):
    message: str
    code: str
    issues: Optional[List[TemplateGetManyBadRequestIssue]] = None


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

    data: TemplateGetManyBadRequestErrorData = field(hash=False)

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


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


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


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


class TemplateGetManyAuthOptionsTypedDict(TypedDict):
    global_access_auth: List[TemplateGetManyGlobalAccessAuth]
    global_action_auth: List[TemplateGetManyGlobalActionAuth]


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

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


class TemplateGetManyTeamTypedDict(TypedDict):
    id: float
    url: str


class TemplateGetManyTeam(BaseModel):
    id: float

    url: str


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


class TemplateGetManyValue3TypedDict(TypedDict):
    value: str


class TemplateGetManyValue3(BaseModel):
    value: str


class TemplateGetManyFieldMetaDropdownTypedDict(TypedDict):
    type: TemplateGetManyTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetManyValue3TypedDict]]
    default_value: NotRequired[str]


class TemplateGetManyFieldMetaDropdown(BaseModel):
    type: TemplateGetManyTypeDropdown

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "defaultValue",
            ]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateGetManyFieldMetaCheckboxTypedDict(TypedDict):
    type: TemplateGetManyTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetManyValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[TemplateGetManyDirection2]


class TemplateGetManyFieldMetaCheckbox(BaseModel):
    type: TemplateGetManyTypeCheckbox

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

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

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

    direction: Optional[TemplateGetManyDirection2] = TemplateGetManyDirection2.VERTICAL

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "validationRule",
                "validationLength",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class TemplateGetManyFieldMetaRadioTypedDict(TypedDict):
    type: TemplateGetManyTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[TemplateGetManyValue1TypedDict]]
    direction: NotRequired[TemplateGetManyDirection1]


class TemplateGetManyFieldMetaRadio(BaseModel):
    type: TemplateGetManyTypeRadio

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

    direction: Optional[TemplateGetManyDirection1] = TemplateGetManyDirection1.VERTICAL

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


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


class TemplateGetManyFieldMetaNumberTypedDict(TypedDict):
    type: TemplateGetManyTypeNumber
    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[TemplateGetManyTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateGetManyVerticalAlign2]]


class TemplateGetManyFieldMetaNumber(BaseModel):
    type: TemplateGetManyTypeNumber

    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[TemplateGetManyTextAlign6], 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[TemplateGetManyVerticalAlign2],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "numberFormat",
                "value",
                "minValue",
                "maxValue",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(
            [
                "numberFormat",
                "minValue",
                "maxValue",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


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


class TemplateGetManyFieldMetaTextTypedDict(TypedDict):
    type: TemplateGetManyTypeText
    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[TemplateGetManyTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[TemplateGetManyVerticalAlign1]]


class TemplateGetManyFieldMetaText(BaseModel):
    type: TemplateGetManyTypeText

    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[TemplateGetManyTextAlign5], 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[TemplateGetManyVerticalAlign1],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "text",
                "characterLimit",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(["lineHeight", "letterSpacing", "verticalAlign"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


class TemplateGetManyFieldMetaDateTypedDict(TypedDict):
    type: TemplateGetManyTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetManyTextAlign4]


class TemplateGetManyFieldMetaDate(BaseModel):
    type: TemplateGetManyTypeDate

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyFieldMetaEmailTypedDict(TypedDict):
    type: TemplateGetManyTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetManyTextAlign3]


class TemplateGetManyFieldMetaEmail(BaseModel):
    type: TemplateGetManyTypeEmail

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyFieldMetaNameTypedDict(TypedDict):
    type: TemplateGetManyTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetManyTextAlign2]


class TemplateGetManyFieldMetaName(BaseModel):
    type: TemplateGetManyTypeName

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyFieldMetaInitialsTypedDict(TypedDict):
    type: TemplateGetManyTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[TemplateGetManyTextAlign1]


class TemplateGetManyFieldMetaInitials(BaseModel):
    type: TemplateGetManyTypeInitials

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class TemplateGetManyFieldMetaSignature(BaseModel):
    type: TemplateGetManyTypeSignature

    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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize"]
        )
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


TemplateGetManyFieldMetaUnionTypedDict = TypeAliasType(
    "TemplateGetManyFieldMetaUnionTypedDict",
    Union[
        TemplateGetManyFieldMetaSignatureTypedDict,
        TemplateGetManyFieldMetaInitialsTypedDict,
        TemplateGetManyFieldMetaNameTypedDict,
        TemplateGetManyFieldMetaEmailTypedDict,
        TemplateGetManyFieldMetaDateTypedDict,
        TemplateGetManyFieldMetaRadioTypedDict,
        TemplateGetManyFieldMetaDropdownTypedDict,
        TemplateGetManyFieldMetaCheckboxTypedDict,
        TemplateGetManyFieldMetaTextTypedDict,
        TemplateGetManyFieldMetaNumberTypedDict,
    ],
)


TemplateGetManyFieldMetaUnion = Annotated[
    Union[
        Annotated[TemplateGetManyFieldMetaSignature, Tag("signature")],
        Annotated[TemplateGetManyFieldMetaInitials, Tag("initials")],
        Annotated[TemplateGetManyFieldMetaName, Tag("name")],
        Annotated[TemplateGetManyFieldMetaEmail, Tag("email")],
        Annotated[TemplateGetManyFieldMetaDate, Tag("date")],
        Annotated[TemplateGetManyFieldMetaText, Tag("text")],
        Annotated[TemplateGetManyFieldMetaNumber, Tag("number")],
        Annotated[TemplateGetManyFieldMetaRadio, Tag("radio")],
        Annotated[TemplateGetManyFieldMetaCheckbox, Tag("checkbox")],
        Annotated[TemplateGetManyFieldMetaDropdown, Tag("dropdown")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


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


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

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

    type: TemplateGetManyFieldType

    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[TemplateGetManyFieldMetaUnion], 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 = set(["documentId", "templateId"])
        nullable_fields = set(["fieldMeta", "documentId", "templateId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


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


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


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


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


class TemplateGetManyRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[TemplateGetManyAccessAuth]
    action_auth: List[TemplateGetManyActionAuth]


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

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


class TemplateGetManyRecipientTypedDict(TypedDict):
    envelope_id: str
    role: TemplateGetManyRole
    read_status: TemplateGetManyReadStatus
    signing_status: TemplateGetManySigningStatus
    send_status: TemplateGetManySendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[TemplateGetManyRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: TemplateGetManyRole

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

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

    send_status: Annotated[
        TemplateGetManySendStatus, 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[TemplateGetManyRecipientAuthOptions],
        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 = set(["documentId", "templateId"])
        nullable_fields = set(
            [
                "documentDeletedAt",
                "expired",
                "signedAt",
                "authOptions",
                "signingOrder",
                "rejectionReason",
                "documentId",
                "templateId",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


class TemplateGetManyTemplateMetaTypedDict(TypedDict):
    signing_order: TemplateGetManySigningOrder
    distribution_method: TemplateGetManyDistributionMethod


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

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


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


class TemplateGetManyDirectLink(BaseModel):
    token: str

    enabled: bool


class TemplateGetManyDataTypedDict(TypedDict):
    type: TemplateGetManyType
    visibility: TemplateGetManyVisibility
    id: float
    external_id: Nullable[str]
    title: str
    user_id: float
    team_id: float
    auth_options: Nullable[TemplateGetManyAuthOptionsTypedDict]
    created_at: str
    updated_at: str
    public_title: str
    public_description: str
    folder_id: Nullable[str]
    use_legacy_field_insertion: bool
    envelope_id: str
    team: Nullable[TemplateGetManyTeamTypedDict]
    fields: List[TemplateGetManyFieldTypedDict]
    recipients: List[TemplateGetManyRecipientTypedDict]
    template_meta: Nullable[TemplateGetManyTemplateMetaTypedDict]
    direct_link: Nullable[TemplateGetManyDirectLinkTypedDict]
    template_document_data_id: NotRequired[str]


class TemplateGetManyData(BaseModel):
    type: TemplateGetManyType

    visibility: TemplateGetManyVisibility

    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[TemplateGetManyAuthOptions], 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")]

    use_legacy_field_insertion: Annotated[
        bool, pydantic.Field(alias="useLegacyFieldInsertion")
    ]

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

    team: Nullable[TemplateGetManyTeam]

    fields: List[TemplateGetManyField]

    recipients: List[TemplateGetManyRecipient]

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

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["templateDocumentDataId"])
        nullable_fields = set(
            [
                "externalId",
                "authOptions",
                "folderId",
                "team",
                "templateMeta",
                "directLink",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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

    data: List[TemplateGetManyDataTypedDict]


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

    data: List[TemplateGetManyData]
