"""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 FieldCreateTemplateFieldsTypeDropdownRequest1(str, Enum):
    DROPDOWN = "DROPDOWN"


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


class FieldCreateTemplateFieldsValueDropdownTypedDict(TypedDict):
    value: str


class FieldCreateTemplateFieldsValueDropdown(BaseModel):
    value: str


class FieldCreateTemplateFieldsFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldCreateTemplateFieldsFieldMetaDropdownRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeDropdownRequest2

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

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


class FieldCreateTemplateFieldsFieldDropdownTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeDropdownRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaDropdownRequestTypedDict]


class FieldCreateTemplateFieldsFieldDropdown(BaseModel):
    type: FieldCreateTemplateFieldsTypeDropdownRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaDropdownRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeCheckboxRequest1(str, Enum):
    CHECKBOX = "CHECKBOX"


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


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


class FieldCreateTemplateFieldsValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldsFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateTemplateFieldsDirectionCheckbox]


class FieldCreateTemplateFieldsFieldMetaCheckboxRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeCheckboxRequest2

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

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

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

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


class FieldCreateTemplateFieldsFieldCheckboxTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeCheckboxRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaCheckboxRequestTypedDict]


class FieldCreateTemplateFieldsFieldCheckbox(BaseModel):
    type: FieldCreateTemplateFieldsTypeCheckboxRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaCheckboxRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeRadioRequest1(str, Enum):
    RADIO = "RADIO"


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


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


class FieldCreateTemplateFieldsValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldsFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueRadioTypedDict]]
    direction: NotRequired[FieldCreateTemplateFieldsDirectionRadio]


class FieldCreateTemplateFieldsFieldMetaRadioRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeRadioRequest2

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

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


class FieldCreateTemplateFieldsFieldRadioTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeRadioRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaRadioRequestTypedDict]


class FieldCreateTemplateFieldsFieldRadio(BaseModel):
    type: FieldCreateTemplateFieldsTypeRadioRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaRadioRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeNumberRequest1(str, Enum):
    NUMBER = "NUMBER"


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


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


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


class FieldCreateTemplateFieldsFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeNumberRequest2
    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[FieldCreateTemplateFieldsTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateTemplateFieldsVerticalAlignNumber]]


class FieldCreateTemplateFieldsFieldMetaNumberRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeNumberRequest2

    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[FieldCreateTemplateFieldsTextAlignNumber],
        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[FieldCreateTemplateFieldsVerticalAlignNumber],
        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 FieldCreateTemplateFieldsFieldNumberTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeNumberRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaNumberRequestTypedDict]


class FieldCreateTemplateFieldsFieldNumber(BaseModel):
    type: FieldCreateTemplateFieldsTypeNumberRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaNumberRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeTextRequest1(str, Enum):
    TEXT = "TEXT"


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


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


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


class FieldCreateTemplateFieldsFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeTextRequest2
    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[FieldCreateTemplateFieldsTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateTemplateFieldsVerticalAlignText]]


class FieldCreateTemplateFieldsFieldMetaTextRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeTextRequest2

    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[FieldCreateTemplateFieldsTextAlignText],
        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[FieldCreateTemplateFieldsVerticalAlignText],
        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 FieldCreateTemplateFieldsFieldTextTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeTextRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaTextRequestTypedDict]


class FieldCreateTemplateFieldsFieldText(BaseModel):
    type: FieldCreateTemplateFieldsTypeTextRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaTextRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeDateRequest1(str, Enum):
    DATE = "DATE"


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


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


class FieldCreateTemplateFieldsFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignDate]


class FieldCreateTemplateFieldsFieldMetaDateRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeDateRequest2

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


class FieldCreateTemplateFieldsFieldDateTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeDateRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaDateRequestTypedDict]


class FieldCreateTemplateFieldsFieldDate(BaseModel):
    type: FieldCreateTemplateFieldsTypeDateRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaDateRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeEmailRequest1(str, Enum):
    EMAIL = "EMAIL"


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


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


class FieldCreateTemplateFieldsFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignEmail]


class FieldCreateTemplateFieldsFieldMetaEmailRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeEmailRequest2

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


class FieldCreateTemplateFieldsFieldEmailTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeEmailRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaEmailRequestTypedDict]


class FieldCreateTemplateFieldsFieldEmail(BaseModel):
    type: FieldCreateTemplateFieldsTypeEmailRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaEmailRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeNameRequest1(str, Enum):
    NAME = "NAME"


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


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


class FieldCreateTemplateFieldsFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignName]


class FieldCreateTemplateFieldsFieldMetaNameRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeNameRequest2

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


class FieldCreateTemplateFieldsFieldNameTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeNameRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaNameRequestTypedDict]


class FieldCreateTemplateFieldsFieldName(BaseModel):
    type: FieldCreateTemplateFieldsTypeNameRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaNameRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeInitialsRequest1(str, Enum):
    INITIALS = "INITIALS"


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


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


class FieldCreateTemplateFieldsFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignInitials]


class FieldCreateTemplateFieldsFieldMetaInitialsRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeInitialsRequest2

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


class FieldCreateTemplateFieldsFieldInitialsTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeInitialsRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaInitialsRequestTypedDict]


class FieldCreateTemplateFieldsFieldInitials(BaseModel):
    type: FieldCreateTemplateFieldsTypeInitialsRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaInitialsRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


class FieldCreateTemplateFieldsTypeFreeSignature(str, Enum):
    FREE_SIGNATURE = "FREE_SIGNATURE"


class FieldCreateTemplateFieldsFieldFreeSignatureTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeFreeSignature
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float


class FieldCreateTemplateFieldsFieldFreeSignature(BaseModel):
    type: FieldCreateTemplateFieldsTypeFreeSignature

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float


class FieldCreateTemplateFieldsTypeSignatureRequest1(str, Enum):
    SIGNATURE = "SIGNATURE"


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


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


class FieldCreateTemplateFieldsFieldMetaSignatureRequest(BaseModel):
    type: FieldCreateTemplateFieldsTypeSignatureRequest2

    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


class FieldCreateTemplateFieldsFieldSignatureTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsTypeSignatureRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldsFieldMetaSignatureRequestTypedDict]


class FieldCreateTemplateFieldsFieldSignature(BaseModel):
    type: FieldCreateTemplateFieldsTypeSignatureRequest1

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

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[FieldCreateTemplateFieldsFieldMetaSignatureRequest],
        pydantic.Field(alias="fieldMeta"),
    ] = None


FieldCreateTemplateFieldsFieldUnionTypedDict = TypeAliasType(
    "FieldCreateTemplateFieldsFieldUnionTypedDict",
    Union[
        FieldCreateTemplateFieldsFieldFreeSignatureTypedDict,
        FieldCreateTemplateFieldsFieldSignatureTypedDict,
        FieldCreateTemplateFieldsFieldInitialsTypedDict,
        FieldCreateTemplateFieldsFieldNameTypedDict,
        FieldCreateTemplateFieldsFieldEmailTypedDict,
        FieldCreateTemplateFieldsFieldDateTypedDict,
        FieldCreateTemplateFieldsFieldTextTypedDict,
        FieldCreateTemplateFieldsFieldNumberTypedDict,
        FieldCreateTemplateFieldsFieldRadioTypedDict,
        FieldCreateTemplateFieldsFieldCheckboxTypedDict,
        FieldCreateTemplateFieldsFieldDropdownTypedDict,
    ],
)


FieldCreateTemplateFieldsFieldUnion = TypeAliasType(
    "FieldCreateTemplateFieldsFieldUnion",
    Union[
        FieldCreateTemplateFieldsFieldFreeSignature,
        FieldCreateTemplateFieldsFieldSignature,
        FieldCreateTemplateFieldsFieldInitials,
        FieldCreateTemplateFieldsFieldName,
        FieldCreateTemplateFieldsFieldEmail,
        FieldCreateTemplateFieldsFieldDate,
        FieldCreateTemplateFieldsFieldText,
        FieldCreateTemplateFieldsFieldNumber,
        FieldCreateTemplateFieldsFieldRadio,
        FieldCreateTemplateFieldsFieldCheckbox,
        FieldCreateTemplateFieldsFieldDropdown,
    ],
)


class FieldCreateTemplateFieldsRequestTypedDict(TypedDict):
    template_id: float
    fields: List[FieldCreateTemplateFieldsFieldUnionTypedDict]


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

    fields: List[FieldCreateTemplateFieldsFieldUnion]


class FieldCreateTemplateFieldsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldCreateTemplateFieldsInternalServerErrorIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldsInternalServerErrorIssue]] = None


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

    data: FieldCreateTemplateFieldsInternalServerErrorData = field(hash=False)

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


class FieldCreateTemplateFieldsForbiddenIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldsForbiddenIssue]] = None


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

    data: FieldCreateTemplateFieldsForbiddenErrorData = field(hash=False)

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


class FieldCreateTemplateFieldsUnauthorizedIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldsUnauthorizedIssue]] = None


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

    data: FieldCreateTemplateFieldsUnauthorizedErrorData = field(hash=False)

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


class FieldCreateTemplateFieldsBadRequestIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldsBadRequestIssue]] = None


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

    data: FieldCreateTemplateFieldsBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateTemplateFieldsBadRequestErrorData,
        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 FieldCreateTemplateFieldsTypeResponse(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 FieldCreateTemplateFieldsFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldCreateTemplateFieldsValueResponse3TypedDict(TypedDict):
    value: str


class FieldCreateTemplateFieldsValueResponse3(BaseModel):
    value: str


class FieldCreateTemplateFieldsFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldCreateTemplateFieldsFieldMetaDropdownResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeDropdown

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

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


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


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


class FieldCreateTemplateFieldsValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldsFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateTemplateFieldsDirectionResponse2]


class FieldCreateTemplateFieldsFieldMetaCheckboxResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldCreateTemplateFieldsValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldsFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldsValueResponse1TypedDict]]
    direction: NotRequired[FieldCreateTemplateFieldsDirectionResponse1]


class FieldCreateTemplateFieldsFieldMetaRadioResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeRadio

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

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


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


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


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


class FieldCreateTemplateFieldsFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeNumber
    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[FieldCreateTemplateFieldsTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateTemplateFieldsVerticalAlignResponse2]
    ]


class FieldCreateTemplateFieldsFieldMetaNumberResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeNumber

    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[FieldCreateTemplateFieldsTextAlignResponse6],
        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[FieldCreateTemplateFieldsVerticalAlignResponse2],
        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 FieldCreateTemplateFieldsFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldCreateTemplateFieldsFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeText
    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[FieldCreateTemplateFieldsTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateTemplateFieldsVerticalAlignResponse1]
    ]


class FieldCreateTemplateFieldsFieldMetaTextResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeText

    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[FieldCreateTemplateFieldsTextAlignResponse5],
        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[FieldCreateTemplateFieldsVerticalAlignResponse1],
        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 FieldCreateTemplateFieldsFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldCreateTemplateFieldsFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignResponse4]


class FieldCreateTemplateFieldsFieldMetaDateResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeDate

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


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


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


class FieldCreateTemplateFieldsFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignResponse3]


class FieldCreateTemplateFieldsFieldMetaEmailResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeEmail

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


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


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


class FieldCreateTemplateFieldsFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignResponse2]


class FieldCreateTemplateFieldsFieldMetaNameResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeName

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


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


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


class FieldCreateTemplateFieldsFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldsFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldsTextAlignResponse1]


class FieldCreateTemplateFieldsFieldMetaInitialsResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeInitials

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


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


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


class FieldCreateTemplateFieldsFieldMetaSignatureResponse(BaseModel):
    type: FieldCreateTemplateFieldsFieldMetaTypeSignature

    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


FieldCreateTemplateFieldsFieldMetaUnionTypedDict = TypeAliasType(
    "FieldCreateTemplateFieldsFieldMetaUnionTypedDict",
    Union[
        FieldCreateTemplateFieldsFieldMetaSignatureResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaInitialsResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaNameResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaEmailResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaDateResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaRadioResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaDropdownResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaCheckboxResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaTextResponseTypedDict,
        FieldCreateTemplateFieldsFieldMetaNumberResponseTypedDict,
    ],
)


FieldCreateTemplateFieldsFieldMetaUnion = TypeAliasType(
    "FieldCreateTemplateFieldsFieldMetaUnion",
    Union[
        FieldCreateTemplateFieldsFieldMetaSignatureResponse,
        FieldCreateTemplateFieldsFieldMetaInitialsResponse,
        FieldCreateTemplateFieldsFieldMetaNameResponse,
        FieldCreateTemplateFieldsFieldMetaEmailResponse,
        FieldCreateTemplateFieldsFieldMetaDateResponse,
        FieldCreateTemplateFieldsFieldMetaRadioResponse,
        FieldCreateTemplateFieldsFieldMetaDropdownResponse,
        FieldCreateTemplateFieldsFieldMetaCheckboxResponse,
        FieldCreateTemplateFieldsFieldMetaTextResponse,
        FieldCreateTemplateFieldsFieldMetaNumberResponse,
    ],
)


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


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

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

    type: FieldCreateTemplateFieldsTypeResponse

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

    fields: List[FieldCreateTemplateFieldsFieldResponseTypedDict]


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

    fields: List[FieldCreateTemplateFieldsFieldResponse]
