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


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


class FieldCreateTemplateFieldValueDropdownTypedDict(TypedDict):
    value: str


class FieldCreateTemplateFieldValueDropdown(BaseModel):
    value: str


class FieldCreateTemplateFieldFieldMetaDropdownRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueDropdownTypedDict]]
    default_value: NotRequired[str]


class FieldCreateTemplateFieldFieldMetaDropdownRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeDropdownRequest2

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

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


class FieldCreateTemplateFieldFieldDropdownTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeDropdownRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaDropdownRequestTypedDict]


class FieldCreateTemplateFieldFieldDropdown(BaseModel):
    type: FieldCreateTemplateFieldTypeDropdownRequest1

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


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


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


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


class FieldCreateTemplateFieldValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateTemplateFieldDirectionCheckbox]


class FieldCreateTemplateFieldFieldMetaCheckboxRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeCheckboxRequest2

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

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

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

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


class FieldCreateTemplateFieldFieldCheckboxTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeCheckboxRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaCheckboxRequestTypedDict]


class FieldCreateTemplateFieldFieldCheckbox(BaseModel):
    type: FieldCreateTemplateFieldTypeCheckboxRequest1

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


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


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


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


class FieldCreateTemplateFieldValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldFieldMetaRadioRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueRadioTypedDict]]
    direction: NotRequired[FieldCreateTemplateFieldDirectionRadio]


class FieldCreateTemplateFieldFieldMetaRadioRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeRadioRequest2

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

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


class FieldCreateTemplateFieldFieldRadioTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeRadioRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaRadioRequestTypedDict]


class FieldCreateTemplateFieldFieldRadio(BaseModel):
    type: FieldCreateTemplateFieldTypeRadioRequest1

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


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


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


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


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


class FieldCreateTemplateFieldFieldMetaNumberRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeNumberRequest2
    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[FieldCreateTemplateFieldTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateTemplateFieldVerticalAlignNumber]]


class FieldCreateTemplateFieldFieldMetaNumberRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeNumberRequest2

    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[FieldCreateTemplateFieldTextAlignNumber],
        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[FieldCreateTemplateFieldVerticalAlignNumber],
        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 FieldCreateTemplateFieldFieldNumberTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeNumberRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaNumberRequestTypedDict]


class FieldCreateTemplateFieldFieldNumber(BaseModel):
    type: FieldCreateTemplateFieldTypeNumberRequest1

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


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


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


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


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


class FieldCreateTemplateFieldFieldMetaTextRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeTextRequest2
    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[FieldCreateTemplateFieldTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldCreateTemplateFieldVerticalAlignText]]


class FieldCreateTemplateFieldFieldMetaTextRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeTextRequest2

    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[FieldCreateTemplateFieldTextAlignText],
        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[FieldCreateTemplateFieldVerticalAlignText],
        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 FieldCreateTemplateFieldFieldTextTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeTextRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaTextRequestTypedDict]


class FieldCreateTemplateFieldFieldText(BaseModel):
    type: FieldCreateTemplateFieldTypeTextRequest1

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


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


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


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


class FieldCreateTemplateFieldFieldMetaDateRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignDate]


class FieldCreateTemplateFieldFieldMetaDateRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeDateRequest2

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


class FieldCreateTemplateFieldFieldDateTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeDateRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaDateRequestTypedDict]


class FieldCreateTemplateFieldFieldDate(BaseModel):
    type: FieldCreateTemplateFieldTypeDateRequest1

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


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


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


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


class FieldCreateTemplateFieldFieldMetaEmailRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignEmail]


class FieldCreateTemplateFieldFieldMetaEmailRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeEmailRequest2

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


class FieldCreateTemplateFieldFieldEmailTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeEmailRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaEmailRequestTypedDict]


class FieldCreateTemplateFieldFieldEmail(BaseModel):
    type: FieldCreateTemplateFieldTypeEmailRequest1

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


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


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


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


class FieldCreateTemplateFieldFieldMetaNameRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignName]


class FieldCreateTemplateFieldFieldMetaNameRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeNameRequest2

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


class FieldCreateTemplateFieldFieldNameTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeNameRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaNameRequestTypedDict]


class FieldCreateTemplateFieldFieldName(BaseModel):
    type: FieldCreateTemplateFieldTypeNameRequest1

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


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


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


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


class FieldCreateTemplateFieldFieldMetaInitialsRequestTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignInitials]


class FieldCreateTemplateFieldFieldMetaInitialsRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeInitialsRequest2

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


class FieldCreateTemplateFieldFieldInitialsTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeInitialsRequest1
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[FieldCreateTemplateFieldFieldMetaInitialsRequestTypedDict]


class FieldCreateTemplateFieldFieldInitials(BaseModel):
    type: FieldCreateTemplateFieldTypeInitialsRequest1

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


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


class FieldCreateTemplateFieldFieldFreeSignatureTypedDict(TypedDict):
    type: FieldCreateTemplateFieldTypeFreeSignature
    recipient_id: float
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float


class FieldCreateTemplateFieldFieldFreeSignature(BaseModel):
    type: FieldCreateTemplateFieldTypeFreeSignature

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


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


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


class FieldCreateTemplateFieldFieldMetaSignatureRequest(BaseModel):
    type: FieldCreateTemplateFieldTypeSignatureRequest2

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


class FieldCreateTemplateFieldFieldSignature(BaseModel):
    type: FieldCreateTemplateFieldTypeSignatureRequest1

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


FieldCreateTemplateFieldFieldUnionTypedDict = TypeAliasType(
    "FieldCreateTemplateFieldFieldUnionTypedDict",
    Union[
        FieldCreateTemplateFieldFieldFreeSignatureTypedDict,
        FieldCreateTemplateFieldFieldSignatureTypedDict,
        FieldCreateTemplateFieldFieldInitialsTypedDict,
        FieldCreateTemplateFieldFieldNameTypedDict,
        FieldCreateTemplateFieldFieldEmailTypedDict,
        FieldCreateTemplateFieldFieldDateTypedDict,
        FieldCreateTemplateFieldFieldTextTypedDict,
        FieldCreateTemplateFieldFieldNumberTypedDict,
        FieldCreateTemplateFieldFieldRadioTypedDict,
        FieldCreateTemplateFieldFieldCheckboxTypedDict,
        FieldCreateTemplateFieldFieldDropdownTypedDict,
    ],
)


FieldCreateTemplateFieldFieldUnion = TypeAliasType(
    "FieldCreateTemplateFieldFieldUnion",
    Union[
        FieldCreateTemplateFieldFieldFreeSignature,
        FieldCreateTemplateFieldFieldSignature,
        FieldCreateTemplateFieldFieldInitials,
        FieldCreateTemplateFieldFieldName,
        FieldCreateTemplateFieldFieldEmail,
        FieldCreateTemplateFieldFieldDate,
        FieldCreateTemplateFieldFieldText,
        FieldCreateTemplateFieldFieldNumber,
        FieldCreateTemplateFieldFieldRadio,
        FieldCreateTemplateFieldFieldCheckbox,
        FieldCreateTemplateFieldFieldDropdown,
    ],
)


class FieldCreateTemplateFieldRequestTypedDict(TypedDict):
    template_id: float
    field: FieldCreateTemplateFieldFieldUnionTypedDict


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

    field: FieldCreateTemplateFieldFieldUnion


class FieldCreateTemplateFieldInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldCreateTemplateFieldInternalServerErrorIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldInternalServerErrorIssue]] = None


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

    data: FieldCreateTemplateFieldInternalServerErrorData = field(hash=False)

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


class FieldCreateTemplateFieldForbiddenIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldForbiddenIssue]] = None


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

    data: FieldCreateTemplateFieldForbiddenErrorData = field(hash=False)

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


class FieldCreateTemplateFieldUnauthorizedIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldUnauthorizedIssue]] = None


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

    data: FieldCreateTemplateFieldUnauthorizedErrorData = field(hash=False)

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


class FieldCreateTemplateFieldBadRequestIssue(BaseModel):
    message: str


class FieldCreateTemplateFieldBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldCreateTemplateFieldBadRequestIssue]] = None


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

    data: FieldCreateTemplateFieldBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldCreateTemplateFieldBadRequestErrorData,
        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 FieldCreateTemplateFieldTypeResponse(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 FieldCreateTemplateFieldFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldCreateTemplateFieldValueResponse3TypedDict(TypedDict):
    value: str


class FieldCreateTemplateFieldValueResponse3(BaseModel):
    value: str


class FieldCreateTemplateFieldFieldMetaDropdownResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueResponse3TypedDict]]
    default_value: NotRequired[str]


class FieldCreateTemplateFieldFieldMetaDropdownResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeDropdown

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

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


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


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


class FieldCreateTemplateFieldValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldCreateTemplateFieldDirectionResponse2]


class FieldCreateTemplateFieldFieldMetaCheckboxResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeCheckbox

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

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

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

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


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


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


class FieldCreateTemplateFieldValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldCreateTemplateFieldFieldMetaRadioResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldCreateTemplateFieldValueResponse1TypedDict]]
    direction: NotRequired[FieldCreateTemplateFieldDirectionResponse1]


class FieldCreateTemplateFieldFieldMetaRadioResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeRadio

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

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


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


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


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


class FieldCreateTemplateFieldFieldMetaNumberResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeNumber
    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[FieldCreateTemplateFieldTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateTemplateFieldVerticalAlignResponse2]
    ]


class FieldCreateTemplateFieldFieldMetaNumberResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeNumber

    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[FieldCreateTemplateFieldTextAlignResponse6],
        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[FieldCreateTemplateFieldVerticalAlignResponse2],
        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 FieldCreateTemplateFieldFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldCreateTemplateFieldFieldMetaTextResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeText
    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[FieldCreateTemplateFieldTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[FieldCreateTemplateFieldVerticalAlignResponse1]
    ]


class FieldCreateTemplateFieldFieldMetaTextResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeText

    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[FieldCreateTemplateFieldTextAlignResponse5],
        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[FieldCreateTemplateFieldVerticalAlignResponse1],
        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 FieldCreateTemplateFieldFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class FieldCreateTemplateFieldFieldMetaDateResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignResponse4]


class FieldCreateTemplateFieldFieldMetaDateResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeDate

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


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


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


class FieldCreateTemplateFieldFieldMetaEmailResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignResponse3]


class FieldCreateTemplateFieldFieldMetaEmailResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeEmail

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


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


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


class FieldCreateTemplateFieldFieldMetaNameResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignResponse2]


class FieldCreateTemplateFieldFieldMetaNameResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeName

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


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


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


class FieldCreateTemplateFieldFieldMetaInitialsResponseTypedDict(TypedDict):
    type: FieldCreateTemplateFieldFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldCreateTemplateFieldTextAlignResponse1]


class FieldCreateTemplateFieldFieldMetaInitialsResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeInitials

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


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


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


class FieldCreateTemplateFieldFieldMetaSignatureResponse(BaseModel):
    type: FieldCreateTemplateFieldFieldMetaTypeSignature

    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


FieldCreateTemplateFieldFieldMetaUnionTypedDict = TypeAliasType(
    "FieldCreateTemplateFieldFieldMetaUnionTypedDict",
    Union[
        FieldCreateTemplateFieldFieldMetaSignatureResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaInitialsResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaNameResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaEmailResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaDateResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaRadioResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaDropdownResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaCheckboxResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaTextResponseTypedDict,
        FieldCreateTemplateFieldFieldMetaNumberResponseTypedDict,
    ],
)


FieldCreateTemplateFieldFieldMetaUnion = TypeAliasType(
    "FieldCreateTemplateFieldFieldMetaUnion",
    Union[
        FieldCreateTemplateFieldFieldMetaSignatureResponse,
        FieldCreateTemplateFieldFieldMetaInitialsResponse,
        FieldCreateTemplateFieldFieldMetaNameResponse,
        FieldCreateTemplateFieldFieldMetaEmailResponse,
        FieldCreateTemplateFieldFieldMetaDateResponse,
        FieldCreateTemplateFieldFieldMetaRadioResponse,
        FieldCreateTemplateFieldFieldMetaDropdownResponse,
        FieldCreateTemplateFieldFieldMetaCheckboxResponse,
        FieldCreateTemplateFieldFieldMetaTextResponse,
        FieldCreateTemplateFieldFieldMetaNumberResponse,
    ],
)


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

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


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

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

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

    type: FieldCreateTemplateFieldTypeResponse

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