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


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


class FieldUpdateDocumentFieldsValueDropdownTypedDict(TypedDict):
    value: str


class FieldUpdateDocumentFieldsValueDropdown(BaseModel):
    value: str


class FieldUpdateDocumentFieldsFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldUpdateDocumentFieldsFieldMetaDropdownRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeDropdownRequest2

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

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


class FieldUpdateDocumentFieldsFieldDropdownTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeDropdownRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaDropdownRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldDropdown(BaseModel):
    type: FieldUpdateDocumentFieldsTypeDropdownRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaDropdownRequest],
        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 FieldUpdateDocumentFieldsTypeCheckboxRequest1(str, Enum):
    CHECKBOX = "CHECKBOX"


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


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


class FieldUpdateDocumentFieldsValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldsFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateDocumentFieldsDirectionCheckbox]


class FieldUpdateDocumentFieldsFieldMetaCheckboxRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeCheckboxRequest2

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

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

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

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


class FieldUpdateDocumentFieldsFieldCheckboxTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeCheckboxRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaCheckboxRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldCheckbox(BaseModel):
    type: FieldUpdateDocumentFieldsTypeCheckboxRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaCheckboxRequest],
        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 FieldUpdateDocumentFieldsTypeRadioRequest1(str, Enum):
    RADIO = "RADIO"


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


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


class FieldUpdateDocumentFieldsValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldsFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueRadioTypedDict]]
    direction: NotRequired[FieldUpdateDocumentFieldsDirectionRadio]


class FieldUpdateDocumentFieldsFieldMetaRadioRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeRadioRequest2

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

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


class FieldUpdateDocumentFieldsFieldRadioTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeRadioRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaRadioRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldRadio(BaseModel):
    type: FieldUpdateDocumentFieldsTypeRadioRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaRadioRequest],
        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 FieldUpdateDocumentFieldsTypeNumberRequest1(str, Enum):
    NUMBER = "NUMBER"


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


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


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


class FieldUpdateDocumentFieldsFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeNumberRequest2
    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[FieldUpdateDocumentFieldsTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateDocumentFieldsVerticalAlignNumber]]


class FieldUpdateDocumentFieldsFieldMetaNumberRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeNumberRequest2

    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[FieldUpdateDocumentFieldsTextAlignNumber],
        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[FieldUpdateDocumentFieldsVerticalAlignNumber],
        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 FieldUpdateDocumentFieldsFieldNumberTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeNumberRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaNumberRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldNumber(BaseModel):
    type: FieldUpdateDocumentFieldsTypeNumberRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaNumberRequest],
        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 FieldUpdateDocumentFieldsTypeTextRequest1(str, Enum):
    TEXT = "TEXT"


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


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


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


class FieldUpdateDocumentFieldsFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeTextRequest2
    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[FieldUpdateDocumentFieldsTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateDocumentFieldsVerticalAlignText]]


class FieldUpdateDocumentFieldsFieldMetaTextRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeTextRequest2

    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[FieldUpdateDocumentFieldsTextAlignText],
        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[FieldUpdateDocumentFieldsVerticalAlignText],
        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 FieldUpdateDocumentFieldsFieldTextTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeTextRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaTextRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldText(BaseModel):
    type: FieldUpdateDocumentFieldsTypeTextRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaTextRequest],
        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 FieldUpdateDocumentFieldsTypeDateRequest1(str, Enum):
    DATE = "DATE"


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


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


class FieldUpdateDocumentFieldsFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignDate]


class FieldUpdateDocumentFieldsFieldMetaDateRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeDateRequest2

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


class FieldUpdateDocumentFieldsFieldDateTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeDateRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaDateRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldDate(BaseModel):
    type: FieldUpdateDocumentFieldsTypeDateRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaDateRequest],
        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 FieldUpdateDocumentFieldsTypeEmailRequest1(str, Enum):
    EMAIL = "EMAIL"


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


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


class FieldUpdateDocumentFieldsFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignEmail]


class FieldUpdateDocumentFieldsFieldMetaEmailRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeEmailRequest2

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


class FieldUpdateDocumentFieldsFieldEmailTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeEmailRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaEmailRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldEmail(BaseModel):
    type: FieldUpdateDocumentFieldsTypeEmailRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaEmailRequest],
        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 FieldUpdateDocumentFieldsTypeNameRequest1(str, Enum):
    NAME = "NAME"


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


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


class FieldUpdateDocumentFieldsFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignName]


class FieldUpdateDocumentFieldsFieldMetaNameRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeNameRequest2

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


class FieldUpdateDocumentFieldsFieldNameTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeNameRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaNameRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldName(BaseModel):
    type: FieldUpdateDocumentFieldsTypeNameRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaNameRequest],
        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 FieldUpdateDocumentFieldsTypeInitialsRequest1(str, Enum):
    INITIALS = "INITIALS"


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


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


class FieldUpdateDocumentFieldsFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignInitials]


class FieldUpdateDocumentFieldsFieldMetaInitialsRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeInitialsRequest2

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


class FieldUpdateDocumentFieldsFieldInitialsTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsTypeInitialsRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldsFieldMetaInitialsRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldsFieldInitials(BaseModel):
    type: FieldUpdateDocumentFieldsTypeInitialsRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaInitialsRequest],
        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 FieldUpdateDocumentFieldsTypeFreeSignature(str, Enum):
    FREE_SIGNATURE = "FREE_SIGNATURE"


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


class FieldUpdateDocumentFieldsFieldFreeSignature(BaseModel):
    type: FieldUpdateDocumentFieldsTypeFreeSignature

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


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


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


class FieldUpdateDocumentFieldsFieldMetaSignatureRequest(BaseModel):
    type: FieldUpdateDocumentFieldsTypeSignatureRequest2

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


class FieldUpdateDocumentFieldsFieldSignature(BaseModel):
    type: FieldUpdateDocumentFieldsTypeSignatureRequest1

    id: float

    field_meta: Annotated[
        Optional[FieldUpdateDocumentFieldsFieldMetaSignatureRequest],
        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


FieldUpdateDocumentFieldsFieldUnionTypedDict = TypeAliasType(
    "FieldUpdateDocumentFieldsFieldUnionTypedDict",
    Union[
        FieldUpdateDocumentFieldsFieldFreeSignatureTypedDict,
        FieldUpdateDocumentFieldsFieldSignatureTypedDict,
        FieldUpdateDocumentFieldsFieldInitialsTypedDict,
        FieldUpdateDocumentFieldsFieldNameTypedDict,
        FieldUpdateDocumentFieldsFieldEmailTypedDict,
        FieldUpdateDocumentFieldsFieldDateTypedDict,
        FieldUpdateDocumentFieldsFieldTextTypedDict,
        FieldUpdateDocumentFieldsFieldNumberTypedDict,
        FieldUpdateDocumentFieldsFieldRadioTypedDict,
        FieldUpdateDocumentFieldsFieldCheckboxTypedDict,
        FieldUpdateDocumentFieldsFieldDropdownTypedDict,
    ],
)


FieldUpdateDocumentFieldsFieldUnion = TypeAliasType(
    "FieldUpdateDocumentFieldsFieldUnion",
    Union[
        FieldUpdateDocumentFieldsFieldFreeSignature,
        FieldUpdateDocumentFieldsFieldSignature,
        FieldUpdateDocumentFieldsFieldInitials,
        FieldUpdateDocumentFieldsFieldName,
        FieldUpdateDocumentFieldsFieldEmail,
        FieldUpdateDocumentFieldsFieldDate,
        FieldUpdateDocumentFieldsFieldText,
        FieldUpdateDocumentFieldsFieldNumber,
        FieldUpdateDocumentFieldsFieldRadio,
        FieldUpdateDocumentFieldsFieldCheckbox,
        FieldUpdateDocumentFieldsFieldDropdown,
    ],
)


class FieldUpdateDocumentFieldsRequestTypedDict(TypedDict):
    document_id: float
    fields: List[FieldUpdateDocumentFieldsFieldUnionTypedDict]


class FieldUpdateDocumentFieldsRequest(BaseModel):
    document_id: Annotated[float, pydantic.Field(alias="documentId")]

    fields: List[FieldUpdateDocumentFieldsFieldUnion]


class FieldUpdateDocumentFieldsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldUpdateDocumentFieldsInternalServerErrorIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldsInternalServerErrorIssue]] = None


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

    data: FieldUpdateDocumentFieldsInternalServerErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldsForbiddenIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldsForbiddenIssue]] = None


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

    data: FieldUpdateDocumentFieldsForbiddenErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldsUnauthorizedIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldsUnauthorizedIssue]] = None


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

    data: FieldUpdateDocumentFieldsUnauthorizedErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldsBadRequestIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldsBadRequestIssue]] = None


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

    data: FieldUpdateDocumentFieldsBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldUpdateDocumentFieldsBadRequestErrorData,
        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 FieldUpdateDocumentFieldsTypeResponse(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 FieldUpdateDocumentFieldsFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldUpdateDocumentFieldsValueResponse3TypedDict(TypedDict):
    value: str


class FieldUpdateDocumentFieldsValueResponse3(BaseModel):
    value: str


class FieldUpdateDocumentFieldsFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldUpdateDocumentFieldsFieldMetaDropdownResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeDropdown

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

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


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


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


class FieldUpdateDocumentFieldsValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldsFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateDocumentFieldsDirectionResponse2]


class FieldUpdateDocumentFieldsFieldMetaCheckboxResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldUpdateDocumentFieldsValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldsFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldsValueResponse1TypedDict]]
    direction: NotRequired[FieldUpdateDocumentFieldsDirectionResponse1]


class FieldUpdateDocumentFieldsFieldMetaRadioResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeRadio

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

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


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


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


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


class FieldUpdateDocumentFieldsFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeNumber
    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[FieldUpdateDocumentFieldsTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateDocumentFieldsVerticalAlignResponse2]
    ]


class FieldUpdateDocumentFieldsFieldMetaNumberResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeNumber

    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[FieldUpdateDocumentFieldsTextAlignResponse6],
        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[FieldUpdateDocumentFieldsVerticalAlignResponse2],
        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 FieldUpdateDocumentFieldsFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldUpdateDocumentFieldsFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeText
    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[FieldUpdateDocumentFieldsTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateDocumentFieldsVerticalAlignResponse1]
    ]


class FieldUpdateDocumentFieldsFieldMetaTextResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeText

    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[FieldUpdateDocumentFieldsTextAlignResponse5],
        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[FieldUpdateDocumentFieldsVerticalAlignResponse1],
        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 FieldUpdateDocumentFieldsFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldUpdateDocumentFieldsFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignResponse4]


class FieldUpdateDocumentFieldsFieldMetaDateResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeDate

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


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


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


class FieldUpdateDocumentFieldsFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignResponse3]


class FieldUpdateDocumentFieldsFieldMetaEmailResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeEmail

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


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


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


class FieldUpdateDocumentFieldsFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignResponse2]


class FieldUpdateDocumentFieldsFieldMetaNameResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeName

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


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


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


class FieldUpdateDocumentFieldsFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldsFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldsTextAlignResponse1]


class FieldUpdateDocumentFieldsFieldMetaInitialsResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeInitials

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


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


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


class FieldUpdateDocumentFieldsFieldMetaSignatureResponse(BaseModel):
    type: FieldUpdateDocumentFieldsFieldMetaTypeSignature

    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


FieldUpdateDocumentFieldsFieldMetaUnionTypedDict = TypeAliasType(
    "FieldUpdateDocumentFieldsFieldMetaUnionTypedDict",
    Union[
        FieldUpdateDocumentFieldsFieldMetaSignatureResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaInitialsResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaNameResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaEmailResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaDateResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaRadioResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaDropdownResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaCheckboxResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaTextResponseTypedDict,
        FieldUpdateDocumentFieldsFieldMetaNumberResponseTypedDict,
    ],
)


FieldUpdateDocumentFieldsFieldMetaUnion = TypeAliasType(
    "FieldUpdateDocumentFieldsFieldMetaUnion",
    Union[
        FieldUpdateDocumentFieldsFieldMetaSignatureResponse,
        FieldUpdateDocumentFieldsFieldMetaInitialsResponse,
        FieldUpdateDocumentFieldsFieldMetaNameResponse,
        FieldUpdateDocumentFieldsFieldMetaEmailResponse,
        FieldUpdateDocumentFieldsFieldMetaDateResponse,
        FieldUpdateDocumentFieldsFieldMetaRadioResponse,
        FieldUpdateDocumentFieldsFieldMetaDropdownResponse,
        FieldUpdateDocumentFieldsFieldMetaCheckboxResponse,
        FieldUpdateDocumentFieldsFieldMetaTextResponse,
        FieldUpdateDocumentFieldsFieldMetaNumberResponse,
    ],
)


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


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

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

    type: FieldUpdateDocumentFieldsTypeResponse

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

    fields: List[FieldUpdateDocumentFieldsFieldResponseTypedDict]


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

    fields: List[FieldUpdateDocumentFieldsFieldResponse]
