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


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


class FieldCreateDocumentFieldsValueDropdownTypedDict(TypedDict):
    value: str


class FieldCreateDocumentFieldsValueDropdown(BaseModel):
    value: str


class FieldCreateDocumentFieldsFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldCreateDocumentFieldsFieldMetaDropdownRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeDropdownRequest2

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

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


class FieldCreateDocumentFieldsFieldDropdownTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeDropdownRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaDropdownRequestTypedDict]


class FieldCreateDocumentFieldsFieldDropdown(BaseModel):
    type: FieldCreateDocumentFieldsTypeDropdownRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateDocumentFieldsFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateDocumentFieldsDirectionCheckbox]


class FieldCreateDocumentFieldsFieldMetaCheckboxRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeCheckboxRequest2

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

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

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

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


class FieldCreateDocumentFieldsFieldCheckboxTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeCheckboxRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaCheckboxRequestTypedDict]


class FieldCreateDocumentFieldsFieldCheckbox(BaseModel):
    type: FieldCreateDocumentFieldsTypeCheckboxRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateDocumentFieldsFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueRadioTypedDict]]
    direction: NotRequired[FieldCreateDocumentFieldsDirectionRadio]


class FieldCreateDocumentFieldsFieldMetaRadioRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeRadioRequest2

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

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


class FieldCreateDocumentFieldsFieldRadioTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeRadioRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaRadioRequestTypedDict]


class FieldCreateDocumentFieldsFieldRadio(BaseModel):
    type: FieldCreateDocumentFieldsTypeRadioRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


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


class FieldCreateDocumentFieldsFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeNumberRequest2
    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[FieldCreateDocumentFieldsTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateDocumentFieldsVerticalAlignNumber]]


class FieldCreateDocumentFieldsFieldMetaNumberRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeNumberRequest2

    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[FieldCreateDocumentFieldsTextAlignNumber],
        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[FieldCreateDocumentFieldsVerticalAlignNumber],
        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 FieldCreateDocumentFieldsFieldNumberTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeNumberRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaNumberRequestTypedDict]


class FieldCreateDocumentFieldsFieldNumber(BaseModel):
    type: FieldCreateDocumentFieldsTypeNumberRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


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


class FieldCreateDocumentFieldsFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeTextRequest2
    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[FieldCreateDocumentFieldsTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateDocumentFieldsVerticalAlignText]]


class FieldCreateDocumentFieldsFieldMetaTextRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeTextRequest2

    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[FieldCreateDocumentFieldsTextAlignText],
        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[FieldCreateDocumentFieldsVerticalAlignText],
        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 FieldCreateDocumentFieldsFieldTextTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeTextRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaTextRequestTypedDict]


class FieldCreateDocumentFieldsFieldText(BaseModel):
    type: FieldCreateDocumentFieldsTypeTextRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignDate]


class FieldCreateDocumentFieldsFieldMetaDateRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeDateRequest2

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


class FieldCreateDocumentFieldsFieldDateTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeDateRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaDateRequestTypedDict]


class FieldCreateDocumentFieldsFieldDate(BaseModel):
    type: FieldCreateDocumentFieldsTypeDateRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignEmail]


class FieldCreateDocumentFieldsFieldMetaEmailRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeEmailRequest2

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


class FieldCreateDocumentFieldsFieldEmailTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeEmailRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaEmailRequestTypedDict]


class FieldCreateDocumentFieldsFieldEmail(BaseModel):
    type: FieldCreateDocumentFieldsTypeEmailRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignName]


class FieldCreateDocumentFieldsFieldMetaNameRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeNameRequest2

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


class FieldCreateDocumentFieldsFieldNameTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeNameRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaNameRequestTypedDict]


class FieldCreateDocumentFieldsFieldName(BaseModel):
    type: FieldCreateDocumentFieldsTypeNameRequest1

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

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

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

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

    width: float

    height: float

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


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


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


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


class FieldCreateDocumentFieldsFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignInitials]


class FieldCreateDocumentFieldsFieldMetaInitialsRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeInitialsRequest2

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


class FieldCreateDocumentFieldsFieldInitialsTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeInitialsRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaInitialsRequestTypedDict]


class FieldCreateDocumentFieldsFieldInitials(BaseModel):
    type: FieldCreateDocumentFieldsTypeInitialsRequest1

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

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

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

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

    width: float

    height: float

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


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


class FieldCreateDocumentFieldsFieldFreeSignatureTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeFreeSignature
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float


class FieldCreateDocumentFieldsFieldFreeSignature(BaseModel):
    type: FieldCreateDocumentFieldsTypeFreeSignature

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

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

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

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

    width: float

    height: float


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


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


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


class FieldCreateDocumentFieldsFieldMetaSignatureRequest(BaseModel):
    type: FieldCreateDocumentFieldsTypeSignatureRequest2

    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 FieldCreateDocumentFieldsFieldSignatureTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsTypeSignatureRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateDocumentFieldsFieldMetaSignatureRequestTypedDict]


class FieldCreateDocumentFieldsFieldSignature(BaseModel):
    type: FieldCreateDocumentFieldsTypeSignatureRequest1

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

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

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

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

    width: float

    height: float

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


FieldCreateDocumentFieldsFieldUnionTypedDict = TypeAliasType(
    "FieldCreateDocumentFieldsFieldUnionTypedDict",
    Union[
        FieldCreateDocumentFieldsFieldFreeSignatureTypedDict,
        FieldCreateDocumentFieldsFieldSignatureTypedDict,
        FieldCreateDocumentFieldsFieldInitialsTypedDict,
        FieldCreateDocumentFieldsFieldNameTypedDict,
        FieldCreateDocumentFieldsFieldEmailTypedDict,
        FieldCreateDocumentFieldsFieldDateTypedDict,
        FieldCreateDocumentFieldsFieldTextTypedDict,
        FieldCreateDocumentFieldsFieldNumberTypedDict,
        FieldCreateDocumentFieldsFieldRadioTypedDict,
        FieldCreateDocumentFieldsFieldCheckboxTypedDict,
        FieldCreateDocumentFieldsFieldDropdownTypedDict,
    ],
)


FieldCreateDocumentFieldsFieldUnion = TypeAliasType(
    "FieldCreateDocumentFieldsFieldUnion",
    Union[
        FieldCreateDocumentFieldsFieldFreeSignature,
        FieldCreateDocumentFieldsFieldSignature,
        FieldCreateDocumentFieldsFieldInitials,
        FieldCreateDocumentFieldsFieldName,
        FieldCreateDocumentFieldsFieldEmail,
        FieldCreateDocumentFieldsFieldDate,
        FieldCreateDocumentFieldsFieldText,
        FieldCreateDocumentFieldsFieldNumber,
        FieldCreateDocumentFieldsFieldRadio,
        FieldCreateDocumentFieldsFieldCheckbox,
        FieldCreateDocumentFieldsFieldDropdown,
    ],
)


class FieldCreateDocumentFieldsRequestTypedDict(TypedDict):
    document_id: float
    fields: List[FieldCreateDocumentFieldsFieldUnionTypedDict]


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

    fields: List[FieldCreateDocumentFieldsFieldUnion]


class FieldCreateDocumentFieldsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldCreateDocumentFieldsInternalServerErrorIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldsInternalServerErrorIssue]] = None


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

    data: FieldCreateDocumentFieldsInternalServerErrorData = field(hash=False)

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


class FieldCreateDocumentFieldsForbiddenIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldsForbiddenIssue]] = None


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

    data: FieldCreateDocumentFieldsForbiddenErrorData = field(hash=False)

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


class FieldCreateDocumentFieldsUnauthorizedIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldsUnauthorizedIssue]] = None


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

    data: FieldCreateDocumentFieldsUnauthorizedErrorData = field(hash=False)

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


class FieldCreateDocumentFieldsBadRequestIssue(BaseModel):
    message: str


class FieldCreateDocumentFieldsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateDocumentFieldsBadRequestIssue]] = None


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

    data: FieldCreateDocumentFieldsBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateDocumentFieldsBadRequestErrorData,
        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 FieldCreateDocumentFieldsTypeResponse(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 FieldCreateDocumentFieldsFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldCreateDocumentFieldsValueResponse3TypedDict(TypedDict):
    value: str


class FieldCreateDocumentFieldsValueResponse3(BaseModel):
    value: str


class FieldCreateDocumentFieldsFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldCreateDocumentFieldsFieldMetaDropdownResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeDropdown

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

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


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


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


class FieldCreateDocumentFieldsValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateDocumentFieldsFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateDocumentFieldsDirectionResponse2]


class FieldCreateDocumentFieldsFieldMetaCheckboxResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldCreateDocumentFieldsValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateDocumentFieldsFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateDocumentFieldsValueResponse1TypedDict]]
    direction: NotRequired[FieldCreateDocumentFieldsDirectionResponse1]


class FieldCreateDocumentFieldsFieldMetaRadioResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeRadio

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

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


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


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


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


class FieldCreateDocumentFieldsFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeNumber
    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[FieldCreateDocumentFieldsTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateDocumentFieldsVerticalAlignResponse2]
    ]


class FieldCreateDocumentFieldsFieldMetaNumberResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeNumber

    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[FieldCreateDocumentFieldsTextAlignResponse6],
        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[FieldCreateDocumentFieldsVerticalAlignResponse2],
        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 FieldCreateDocumentFieldsFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldCreateDocumentFieldsFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeText
    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[FieldCreateDocumentFieldsTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateDocumentFieldsVerticalAlignResponse1]
    ]


class FieldCreateDocumentFieldsFieldMetaTextResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeText

    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[FieldCreateDocumentFieldsTextAlignResponse5],
        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[FieldCreateDocumentFieldsVerticalAlignResponse1],
        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 FieldCreateDocumentFieldsFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldCreateDocumentFieldsFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignResponse4]


class FieldCreateDocumentFieldsFieldMetaDateResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeDate

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


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


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


class FieldCreateDocumentFieldsFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignResponse3]


class FieldCreateDocumentFieldsFieldMetaEmailResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeEmail

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


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


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


class FieldCreateDocumentFieldsFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignResponse2]


class FieldCreateDocumentFieldsFieldMetaNameResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeName

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


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


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


class FieldCreateDocumentFieldsFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldCreateDocumentFieldsFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateDocumentFieldsTextAlignResponse1]


class FieldCreateDocumentFieldsFieldMetaInitialsResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeInitials

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


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


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


class FieldCreateDocumentFieldsFieldMetaSignatureResponse(BaseModel):
    type: FieldCreateDocumentFieldsFieldMetaTypeSignature

    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


FieldCreateDocumentFieldsFieldMetaUnionTypedDict = TypeAliasType(
    "FieldCreateDocumentFieldsFieldMetaUnionTypedDict",
    Union[
        FieldCreateDocumentFieldsFieldMetaSignatureResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaInitialsResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaNameResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaEmailResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaDateResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaRadioResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaDropdownResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaCheckboxResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaTextResponseTypedDict,
        FieldCreateDocumentFieldsFieldMetaNumberResponseTypedDict,
    ],
)


FieldCreateDocumentFieldsFieldMetaUnion = TypeAliasType(
    "FieldCreateDocumentFieldsFieldMetaUnion",
    Union[
        FieldCreateDocumentFieldsFieldMetaSignatureResponse,
        FieldCreateDocumentFieldsFieldMetaInitialsResponse,
        FieldCreateDocumentFieldsFieldMetaNameResponse,
        FieldCreateDocumentFieldsFieldMetaEmailResponse,
        FieldCreateDocumentFieldsFieldMetaDateResponse,
        FieldCreateDocumentFieldsFieldMetaRadioResponse,
        FieldCreateDocumentFieldsFieldMetaDropdownResponse,
        FieldCreateDocumentFieldsFieldMetaCheckboxResponse,
        FieldCreateDocumentFieldsFieldMetaTextResponse,
        FieldCreateDocumentFieldsFieldMetaNumberResponse,
    ],
)


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


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

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

    type: FieldCreateDocumentFieldsTypeResponse

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

    fields: List[FieldCreateDocumentFieldsFieldResponseTypedDict]


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

    fields: List[FieldCreateDocumentFieldsFieldResponse]
