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


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


class FieldUpdateDocumentFieldValueDropdownTypedDict(TypedDict):
    value: str


class FieldUpdateDocumentFieldValueDropdown(BaseModel):
    value: str


class FieldUpdateDocumentFieldFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldUpdateDocumentFieldFieldMetaDropdownRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeDropdownRequest2

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

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


class FieldUpdateDocumentFieldFieldDropdownTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeDropdownRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaDropdownRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldDropdown(BaseModel):
    type: FieldUpdateDocumentFieldTypeDropdownRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateDocumentFieldDirectionCheckbox]


class FieldUpdateDocumentFieldFieldMetaCheckboxRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeCheckboxRequest2

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

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

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

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


class FieldUpdateDocumentFieldFieldCheckboxTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeCheckboxRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaCheckboxRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldCheckbox(BaseModel):
    type: FieldUpdateDocumentFieldTypeCheckboxRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueRadioTypedDict]]
    direction: NotRequired[FieldUpdateDocumentFieldDirectionRadio]


class FieldUpdateDocumentFieldFieldMetaRadioRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeRadioRequest2

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

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


class FieldUpdateDocumentFieldFieldRadioTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeRadioRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaRadioRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldRadio(BaseModel):
    type: FieldUpdateDocumentFieldTypeRadioRequest1

    id: float

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


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


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


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


class FieldUpdateDocumentFieldFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeNumberRequest2
    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[FieldUpdateDocumentFieldTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateDocumentFieldVerticalAlignNumber]]


class FieldUpdateDocumentFieldFieldMetaNumberRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeNumberRequest2

    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[FieldUpdateDocumentFieldTextAlignNumber],
        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[FieldUpdateDocumentFieldVerticalAlignNumber],
        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 FieldUpdateDocumentFieldFieldNumberTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeNumberRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaNumberRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldNumber(BaseModel):
    type: FieldUpdateDocumentFieldTypeNumberRequest1

    id: float

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


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


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


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


class FieldUpdateDocumentFieldFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeTextRequest2
    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[FieldUpdateDocumentFieldTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldUpdateDocumentFieldVerticalAlignText]]


class FieldUpdateDocumentFieldFieldMetaTextRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeTextRequest2

    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[FieldUpdateDocumentFieldTextAlignText],
        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[FieldUpdateDocumentFieldVerticalAlignText],
        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 FieldUpdateDocumentFieldFieldTextTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeTextRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaTextRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldText(BaseModel):
    type: FieldUpdateDocumentFieldTypeTextRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignDate]


class FieldUpdateDocumentFieldFieldMetaDateRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeDateRequest2

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


class FieldUpdateDocumentFieldFieldDateTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeDateRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaDateRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldDate(BaseModel):
    type: FieldUpdateDocumentFieldTypeDateRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignEmail]


class FieldUpdateDocumentFieldFieldMetaEmailRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeEmailRequest2

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


class FieldUpdateDocumentFieldFieldEmailTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeEmailRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaEmailRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldEmail(BaseModel):
    type: FieldUpdateDocumentFieldTypeEmailRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignName]


class FieldUpdateDocumentFieldFieldMetaNameRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeNameRequest2

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


class FieldUpdateDocumentFieldFieldNameTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeNameRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaNameRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldName(BaseModel):
    type: FieldUpdateDocumentFieldTypeNameRequest1

    id: float

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


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


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


class FieldUpdateDocumentFieldFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignInitials]


class FieldUpdateDocumentFieldFieldMetaInitialsRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeInitialsRequest2

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


class FieldUpdateDocumentFieldFieldInitialsTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldTypeInitialsRequest1
    id: float
    field_meta: NotRequired[FieldUpdateDocumentFieldFieldMetaInitialsRequestTypedDict]
    page_number: NotRequired[float]
    page_x: NotRequired[float]
    page_y: NotRequired[float]
    width: NotRequired[float]
    height: NotRequired[float]


class FieldUpdateDocumentFieldFieldInitials(BaseModel):
    type: FieldUpdateDocumentFieldTypeInitialsRequest1

    id: float

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


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


class FieldUpdateDocumentFieldFieldFreeSignature(BaseModel):
    type: FieldUpdateDocumentFieldTypeFreeSignature

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


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


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


class FieldUpdateDocumentFieldFieldMetaSignatureRequest(BaseModel):
    type: FieldUpdateDocumentFieldTypeSignatureRequest2

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


class FieldUpdateDocumentFieldFieldSignature(BaseModel):
    type: FieldUpdateDocumentFieldTypeSignatureRequest1

    id: float

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


FieldUpdateDocumentFieldFieldUnionTypedDict = TypeAliasType(
    "FieldUpdateDocumentFieldFieldUnionTypedDict",
    Union[
        FieldUpdateDocumentFieldFieldFreeSignatureTypedDict,
        FieldUpdateDocumentFieldFieldSignatureTypedDict,
        FieldUpdateDocumentFieldFieldInitialsTypedDict,
        FieldUpdateDocumentFieldFieldNameTypedDict,
        FieldUpdateDocumentFieldFieldEmailTypedDict,
        FieldUpdateDocumentFieldFieldDateTypedDict,
        FieldUpdateDocumentFieldFieldTextTypedDict,
        FieldUpdateDocumentFieldFieldNumberTypedDict,
        FieldUpdateDocumentFieldFieldRadioTypedDict,
        FieldUpdateDocumentFieldFieldCheckboxTypedDict,
        FieldUpdateDocumentFieldFieldDropdownTypedDict,
    ],
)


FieldUpdateDocumentFieldFieldUnion = TypeAliasType(
    "FieldUpdateDocumentFieldFieldUnion",
    Union[
        FieldUpdateDocumentFieldFieldFreeSignature,
        FieldUpdateDocumentFieldFieldSignature,
        FieldUpdateDocumentFieldFieldInitials,
        FieldUpdateDocumentFieldFieldName,
        FieldUpdateDocumentFieldFieldEmail,
        FieldUpdateDocumentFieldFieldDate,
        FieldUpdateDocumentFieldFieldText,
        FieldUpdateDocumentFieldFieldNumber,
        FieldUpdateDocumentFieldFieldRadio,
        FieldUpdateDocumentFieldFieldCheckbox,
        FieldUpdateDocumentFieldFieldDropdown,
    ],
)


class FieldUpdateDocumentFieldRequestTypedDict(TypedDict):
    document_id: float
    field: FieldUpdateDocumentFieldFieldUnionTypedDict


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

    field: FieldUpdateDocumentFieldFieldUnion


class FieldUpdateDocumentFieldInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldUpdateDocumentFieldInternalServerErrorIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldInternalServerErrorIssue]] = None


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

    data: FieldUpdateDocumentFieldInternalServerErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldForbiddenIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldForbiddenIssue]] = None


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

    data: FieldUpdateDocumentFieldForbiddenErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldUnauthorizedIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldUnauthorizedIssue]] = None


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

    data: FieldUpdateDocumentFieldUnauthorizedErrorData = field(hash=False)

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


class FieldUpdateDocumentFieldBadRequestIssue(BaseModel):
    message: str


class FieldUpdateDocumentFieldBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldUpdateDocumentFieldBadRequestIssue]] = None


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

    data: FieldUpdateDocumentFieldBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldUpdateDocumentFieldBadRequestErrorData,
        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 FieldUpdateDocumentFieldTypeResponse(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 FieldUpdateDocumentFieldFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldUpdateDocumentFieldValueResponse3TypedDict(TypedDict):
    value: str


class FieldUpdateDocumentFieldValueResponse3(BaseModel):
    value: str


class FieldUpdateDocumentFieldFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldUpdateDocumentFieldFieldMetaDropdownResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeDropdown

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

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


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


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


class FieldUpdateDocumentFieldValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldUpdateDocumentFieldDirectionResponse2]


class FieldUpdateDocumentFieldFieldMetaCheckboxResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldUpdateDocumentFieldValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldUpdateDocumentFieldFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldUpdateDocumentFieldValueResponse1TypedDict]]
    direction: NotRequired[FieldUpdateDocumentFieldDirectionResponse1]


class FieldUpdateDocumentFieldFieldMetaRadioResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeRadio

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

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


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


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


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


class FieldUpdateDocumentFieldFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeNumber
    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[FieldUpdateDocumentFieldTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateDocumentFieldVerticalAlignResponse2]
    ]


class FieldUpdateDocumentFieldFieldMetaNumberResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeNumber

    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[FieldUpdateDocumentFieldTextAlignResponse6],
        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[FieldUpdateDocumentFieldVerticalAlignResponse2],
        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 FieldUpdateDocumentFieldFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldUpdateDocumentFieldFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeText
    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[FieldUpdateDocumentFieldTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldUpdateDocumentFieldVerticalAlignResponse1]
    ]


class FieldUpdateDocumentFieldFieldMetaTextResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeText

    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[FieldUpdateDocumentFieldTextAlignResponse5],
        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[FieldUpdateDocumentFieldVerticalAlignResponse1],
        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 FieldUpdateDocumentFieldFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldUpdateDocumentFieldFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignResponse4]


class FieldUpdateDocumentFieldFieldMetaDateResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeDate

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


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


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


class FieldUpdateDocumentFieldFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignResponse3]


class FieldUpdateDocumentFieldFieldMetaEmailResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeEmail

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


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


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


class FieldUpdateDocumentFieldFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignResponse2]


class FieldUpdateDocumentFieldFieldMetaNameResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeName

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


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


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


class FieldUpdateDocumentFieldFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldUpdateDocumentFieldFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldUpdateDocumentFieldTextAlignResponse1]


class FieldUpdateDocumentFieldFieldMetaInitialsResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeInitials

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


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


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


class FieldUpdateDocumentFieldFieldMetaSignatureResponse(BaseModel):
    type: FieldUpdateDocumentFieldFieldMetaTypeSignature

    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


FieldUpdateDocumentFieldFieldMetaUnionTypedDict = TypeAliasType(
    "FieldUpdateDocumentFieldFieldMetaUnionTypedDict",
    Union[
        FieldUpdateDocumentFieldFieldMetaSignatureResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaInitialsResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaNameResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaEmailResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaDateResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaRadioResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaDropdownResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaCheckboxResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaTextResponseTypedDict,
        FieldUpdateDocumentFieldFieldMetaNumberResponseTypedDict,
    ],
)


FieldUpdateDocumentFieldFieldMetaUnion = TypeAliasType(
    "FieldUpdateDocumentFieldFieldMetaUnion",
    Union[
        FieldUpdateDocumentFieldFieldMetaSignatureResponse,
        FieldUpdateDocumentFieldFieldMetaInitialsResponse,
        FieldUpdateDocumentFieldFieldMetaNameResponse,
        FieldUpdateDocumentFieldFieldMetaEmailResponse,
        FieldUpdateDocumentFieldFieldMetaDateResponse,
        FieldUpdateDocumentFieldFieldMetaRadioResponse,
        FieldUpdateDocumentFieldFieldMetaDropdownResponse,
        FieldUpdateDocumentFieldFieldMetaCheckboxResponse,
        FieldUpdateDocumentFieldFieldMetaTextResponse,
        FieldUpdateDocumentFieldFieldMetaNumberResponse,
    ],
)


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

    envelope_id: str
    envelope_item_id: str
    type: FieldUpdateDocumentFieldTypeResponse
    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[FieldUpdateDocumentFieldFieldMetaUnionTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

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

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

    type: FieldUpdateDocumentFieldTypeResponse

    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[FieldUpdateDocumentFieldFieldMetaUnion],
        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
