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


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


class FieldUpdateTemplateFieldsValueDropdownTypedDict(TypedDict):
    value: str


class FieldUpdateTemplateFieldsValueDropdown(BaseModel):
    value: str


class FieldUpdateTemplateFieldsFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldUpdateTemplateFieldsFieldMetaDropdownRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeDropdownRequest2

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

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


class FieldUpdateTemplateFieldsFieldDropdownTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeDropdownRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaDropdownRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldDropdown(BaseModel):
    type: FieldUpdateTemplateFieldsTypeDropdownRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateTemplateFieldsFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateTemplateFieldsDirectionCheckbox]


class FieldUpdateTemplateFieldsFieldMetaCheckboxRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeCheckboxRequest2

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

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

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

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


class FieldUpdateTemplateFieldsFieldCheckboxTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeCheckboxRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaCheckboxRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldCheckbox(BaseModel):
    type: FieldUpdateTemplateFieldsTypeCheckboxRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateTemplateFieldsFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueRadioTypedDict]]
    direction: NotRequired[FieldUpdateTemplateFieldsDirectionRadio]


class FieldUpdateTemplateFieldsFieldMetaRadioRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeRadioRequest2

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

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


class FieldUpdateTemplateFieldsFieldRadioTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeRadioRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaRadioRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldRadio(BaseModel):
    type: FieldUpdateTemplateFieldsTypeRadioRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


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


class FieldUpdateTemplateFieldsFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeNumberRequest2
    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[FieldUpdateTemplateFieldsTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateTemplateFieldsVerticalAlignNumber]]


class FieldUpdateTemplateFieldsFieldMetaNumberRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeNumberRequest2

    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[FieldUpdateTemplateFieldsTextAlignNumber],
        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[FieldUpdateTemplateFieldsVerticalAlignNumber],
        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 FieldUpdateTemplateFieldsFieldNumberTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeNumberRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaNumberRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldNumber(BaseModel):
    type: FieldUpdateTemplateFieldsTypeNumberRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


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


class FieldUpdateTemplateFieldsFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeTextRequest2
    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[FieldUpdateTemplateFieldsTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateTemplateFieldsVerticalAlignText]]


class FieldUpdateTemplateFieldsFieldMetaTextRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeTextRequest2

    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[FieldUpdateTemplateFieldsTextAlignText],
        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[FieldUpdateTemplateFieldsVerticalAlignText],
        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 FieldUpdateTemplateFieldsFieldTextTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeTextRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaTextRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldText(BaseModel):
    type: FieldUpdateTemplateFieldsTypeTextRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignDate]


class FieldUpdateTemplateFieldsFieldMetaDateRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeDateRequest2

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


class FieldUpdateTemplateFieldsFieldDateTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeDateRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaDateRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldDate(BaseModel):
    type: FieldUpdateTemplateFieldsTypeDateRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignEmail]


class FieldUpdateTemplateFieldsFieldMetaEmailRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeEmailRequest2

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


class FieldUpdateTemplateFieldsFieldEmailTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeEmailRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaEmailRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldEmail(BaseModel):
    type: FieldUpdateTemplateFieldsTypeEmailRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignName]


class FieldUpdateTemplateFieldsFieldMetaNameRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeNameRequest2

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


class FieldUpdateTemplateFieldsFieldNameTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeNameRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaNameRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldName(BaseModel):
    type: FieldUpdateTemplateFieldsTypeNameRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignInitials]


class FieldUpdateTemplateFieldsFieldMetaInitialsRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeInitialsRequest2

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


class FieldUpdateTemplateFieldsFieldInitialsTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeInitialsRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaInitialsRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldInitials(BaseModel):
    type: FieldUpdateTemplateFieldsTypeInitialsRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


class FieldUpdateTemplateFieldsFieldFreeSignatureTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeFreeSignature
    id: float
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldFreeSignature(BaseModel):
    type: FieldUpdateTemplateFieldsTypeFreeSignature

    id: float

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


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


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


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


class FieldUpdateTemplateFieldsFieldMetaSignatureRequest(BaseModel):
    type: FieldUpdateTemplateFieldsTypeSignatureRequest2

    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 FieldUpdateTemplateFieldsFieldSignatureTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsTypeSignatureRequest1
    id: float
    field_meta: NotRequired[FieldUpdateTemplateFieldsFieldMetaSignatureRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateTemplateFieldsFieldSignature(BaseModel):
    type: FieldUpdateTemplateFieldsTypeSignatureRequest1

    id: float

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

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

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

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

    width: Optional[float] = None

    height: Optional[float] = None


FieldUpdateTemplateFieldsFieldUnionTypedDict = TypeAliasType(
    "FieldUpdateTemplateFieldsFieldUnionTypedDict",
    Union[
        FieldUpdateTemplateFieldsFieldFreeSignatureTypedDict,
        FieldUpdateTemplateFieldsFieldSignatureTypedDict,
        FieldUpdateTemplateFieldsFieldInitialsTypedDict,
        FieldUpdateTemplateFieldsFieldNameTypedDict,
        FieldUpdateTemplateFieldsFieldEmailTypedDict,
        FieldUpdateTemplateFieldsFieldDateTypedDict,
        FieldUpdateTemplateFieldsFieldTextTypedDict,
        FieldUpdateTemplateFieldsFieldNumberTypedDict,
        FieldUpdateTemplateFieldsFieldRadioTypedDict,
        FieldUpdateTemplateFieldsFieldCheckboxTypedDict,
        FieldUpdateTemplateFieldsFieldDropdownTypedDict,
    ],
)


FieldUpdateTemplateFieldsFieldUnion = TypeAliasType(
    "FieldUpdateTemplateFieldsFieldUnion",
    Union[
        FieldUpdateTemplateFieldsFieldFreeSignature,
        FieldUpdateTemplateFieldsFieldSignature,
        FieldUpdateTemplateFieldsFieldInitials,
        FieldUpdateTemplateFieldsFieldName,
        FieldUpdateTemplateFieldsFieldEmail,
        FieldUpdateTemplateFieldsFieldDate,
        FieldUpdateTemplateFieldsFieldText,
        FieldUpdateTemplateFieldsFieldNumber,
        FieldUpdateTemplateFieldsFieldRadio,
        FieldUpdateTemplateFieldsFieldCheckbox,
        FieldUpdateTemplateFieldsFieldDropdown,
    ],
)


class FieldUpdateTemplateFieldsRequestTypedDict(TypedDict):
    template_id: float
    fields: List[FieldUpdateTemplateFieldsFieldUnionTypedDict]


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

    fields: List[FieldUpdateTemplateFieldsFieldUnion]


class FieldUpdateTemplateFieldsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldUpdateTemplateFieldsInternalServerErrorIssue(BaseModel):
    message: str


class FieldUpdateTemplateFieldsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateTemplateFieldsInternalServerErrorIssue]] = None


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

    data: FieldUpdateTemplateFieldsInternalServerErrorData = field(hash=False)

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


class FieldUpdateTemplateFieldsForbiddenIssue(BaseModel):
    message: str


class FieldUpdateTemplateFieldsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateTemplateFieldsForbiddenIssue]] = None


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

    data: FieldUpdateTemplateFieldsForbiddenErrorData = field(hash=False)

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


class FieldUpdateTemplateFieldsUnauthorizedIssue(BaseModel):
    message: str


class FieldUpdateTemplateFieldsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateTemplateFieldsUnauthorizedIssue]] = None


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

    data: FieldUpdateTemplateFieldsUnauthorizedErrorData = field(hash=False)

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


class FieldUpdateTemplateFieldsBadRequestIssue(BaseModel):
    message: str


class FieldUpdateTemplateFieldsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateTemplateFieldsBadRequestIssue]] = None


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

    data: FieldUpdateTemplateFieldsBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldUpdateTemplateFieldsBadRequestErrorData,
        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 FieldUpdateTemplateFieldsTypeResponse(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 FieldUpdateTemplateFieldsFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldUpdateTemplateFieldsValueResponse3TypedDict(TypedDict):
    value: str


class FieldUpdateTemplateFieldsValueResponse3(BaseModel):
    value: str


class FieldUpdateTemplateFieldsFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldUpdateTemplateFieldsFieldMetaDropdownResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeDropdown

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

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


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


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


class FieldUpdateTemplateFieldsValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateTemplateFieldsFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateTemplateFieldsDirectionResponse2]


class FieldUpdateTemplateFieldsFieldMetaCheckboxResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldUpdateTemplateFieldsValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateTemplateFieldsFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateTemplateFieldsValueResponse1TypedDict]]
    direction: NotRequired[FieldUpdateTemplateFieldsDirectionResponse1]


class FieldUpdateTemplateFieldsFieldMetaRadioResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeRadio

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

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


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


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


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


class FieldUpdateTemplateFieldsFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeNumber
    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[FieldUpdateTemplateFieldsTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateTemplateFieldsVerticalAlignResponse2]
    ]


class FieldUpdateTemplateFieldsFieldMetaNumberResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeNumber

    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[FieldUpdateTemplateFieldsTextAlignResponse6],
        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[FieldUpdateTemplateFieldsVerticalAlignResponse2],
        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 FieldUpdateTemplateFieldsFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldUpdateTemplateFieldsFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeText
    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[FieldUpdateTemplateFieldsTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateTemplateFieldsVerticalAlignResponse1]
    ]


class FieldUpdateTemplateFieldsFieldMetaTextResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeText

    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[FieldUpdateTemplateFieldsTextAlignResponse5],
        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[FieldUpdateTemplateFieldsVerticalAlignResponse1],
        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 FieldUpdateTemplateFieldsFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldUpdateTemplateFieldsFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignResponse4]


class FieldUpdateTemplateFieldsFieldMetaDateResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeDate

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


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


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


class FieldUpdateTemplateFieldsFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignResponse3]


class FieldUpdateTemplateFieldsFieldMetaEmailResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeEmail

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


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


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


class FieldUpdateTemplateFieldsFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignResponse2]


class FieldUpdateTemplateFieldsFieldMetaNameResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeName

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


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


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


class FieldUpdateTemplateFieldsFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldUpdateTemplateFieldsFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateTemplateFieldsTextAlignResponse1]


class FieldUpdateTemplateFieldsFieldMetaInitialsResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeInitials

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


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


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


class FieldUpdateTemplateFieldsFieldMetaSignatureResponse(BaseModel):
    type: FieldUpdateTemplateFieldsFieldMetaTypeSignature

    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


FieldUpdateTemplateFieldsFieldMetaUnionTypedDict = TypeAliasType(
    "FieldUpdateTemplateFieldsFieldMetaUnionTypedDict",
    Union[
        FieldUpdateTemplateFieldsFieldMetaSignatureResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaInitialsResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaNameResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaEmailResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaDateResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaRadioResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaDropdownResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaCheckboxResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaTextResponseTypedDict,
        FieldUpdateTemplateFieldsFieldMetaNumberResponseTypedDict,
    ],
)


FieldUpdateTemplateFieldsFieldMetaUnion = TypeAliasType(
    "FieldUpdateTemplateFieldsFieldMetaUnion",
    Union[
        FieldUpdateTemplateFieldsFieldMetaSignatureResponse,
        FieldUpdateTemplateFieldsFieldMetaInitialsResponse,
        FieldUpdateTemplateFieldsFieldMetaNameResponse,
        FieldUpdateTemplateFieldsFieldMetaEmailResponse,
        FieldUpdateTemplateFieldsFieldMetaDateResponse,
        FieldUpdateTemplateFieldsFieldMetaRadioResponse,
        FieldUpdateTemplateFieldsFieldMetaDropdownResponse,
        FieldUpdateTemplateFieldsFieldMetaCheckboxResponse,
        FieldUpdateTemplateFieldsFieldMetaTextResponse,
        FieldUpdateTemplateFieldsFieldMetaNumberResponse,
    ],
)


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


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

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

    type: FieldUpdateTemplateFieldsTypeResponse

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

    fields: List[FieldUpdateTemplateFieldsFieldResponseTypedDict]


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

    fields: List[FieldUpdateTemplateFieldsFieldResponse]
