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


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


class EnvelopeFieldCreateManyValueDropdownTypedDict(TypedDict):
    value: str


class EnvelopeFieldCreateManyValueDropdown(BaseModel):
    value: str


class EnvelopeFieldCreateManyFieldMetaDropdownRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDropdownRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueDropdownTypedDict]]
    default_value: NotRequired[str]


class EnvelopeFieldCreateManyFieldMetaDropdownRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeDropdownRequest2

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

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


class EnvelopeFieldCreateManyDataDropdownTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDropdownRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaDropdownRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataDropdown(BaseModel):
    type: EnvelopeFieldCreateManyTypeDropdownRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaCheckboxRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeCheckboxRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[EnvelopeFieldCreateManyDirectionCheckbox]


class EnvelopeFieldCreateManyFieldMetaCheckboxRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeCheckboxRequest2

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

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

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

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


class EnvelopeFieldCreateManyDataCheckboxTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeCheckboxRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaCheckboxRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataCheckbox(BaseModel):
    type: EnvelopeFieldCreateManyTypeCheckboxRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaRadioRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeRadioRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueRadioTypedDict]]
    direction: NotRequired[EnvelopeFieldCreateManyDirectionRadio]


class EnvelopeFieldCreateManyFieldMetaRadioRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeRadioRequest2

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

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


class EnvelopeFieldCreateManyDataRadioTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeRadioRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaRadioRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataRadio(BaseModel):
    type: EnvelopeFieldCreateManyTypeRadioRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


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


class EnvelopeFieldCreateManyFieldMetaNumberRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeNumberRequest2
    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[EnvelopeFieldCreateManyTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlignNumber]]


class EnvelopeFieldCreateManyFieldMetaNumberRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeNumberRequest2

    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[EnvelopeFieldCreateManyTextAlignNumber],
        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[EnvelopeFieldCreateManyVerticalAlignNumber],
        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 EnvelopeFieldCreateManyDataNumberTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeNumberRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaNumberRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataNumber(BaseModel):
    type: EnvelopeFieldCreateManyTypeNumberRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


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


class EnvelopeFieldCreateManyFieldMetaTextRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeTextRequest2
    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[EnvelopeFieldCreateManyTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlignText]]


class EnvelopeFieldCreateManyFieldMetaTextRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeTextRequest2

    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[EnvelopeFieldCreateManyTextAlignText],
        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[EnvelopeFieldCreateManyVerticalAlignText],
        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 EnvelopeFieldCreateManyDataTextTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeTextRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaTextRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataText(BaseModel):
    type: EnvelopeFieldCreateManyTypeTextRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaDateRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDateRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignDate]


class EnvelopeFieldCreateManyFieldMetaDateRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeDateRequest2

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


class EnvelopeFieldCreateManyDataDateTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDateRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaDateRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataDate(BaseModel):
    type: EnvelopeFieldCreateManyTypeDateRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaEmailRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeEmailRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignEmail]


class EnvelopeFieldCreateManyFieldMetaEmailRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeEmailRequest2

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


class EnvelopeFieldCreateManyDataEmailTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeEmailRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaEmailRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataEmail(BaseModel):
    type: EnvelopeFieldCreateManyTypeEmailRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaNameRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeNameRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignName]


class EnvelopeFieldCreateManyFieldMetaNameRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeNameRequest2

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


class EnvelopeFieldCreateManyDataNameTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeNameRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaNameRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataName(BaseModel):
    type: EnvelopeFieldCreateManyTypeNameRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaInitialsRequestTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeInitialsRequest2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignInitials]


class EnvelopeFieldCreateManyFieldMetaInitialsRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeInitialsRequest2

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


class EnvelopeFieldCreateManyDataInitialsTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeInitialsRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaInitialsRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataInitials(BaseModel):
    type: EnvelopeFieldCreateManyTypeInitialsRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


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


class EnvelopeFieldCreateManyDataFreeSignatureTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeFreeSignature
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataFreeSignature(BaseModel):
    type: EnvelopeFieldCreateManyTypeFreeSignature

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaSignatureRequest(BaseModel):
    type: EnvelopeFieldCreateManyTypeSignatureRequest2

    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 EnvelopeFieldCreateManyDataSignatureTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeSignatureRequest1
    recipient_id: float
    page: float
    position_x: float
    position_y: float
    width: float
    height: float
    field_meta: NotRequired[EnvelopeFieldCreateManyFieldMetaSignatureRequestTypedDict]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataSignature(BaseModel):
    type: EnvelopeFieldCreateManyTypeSignatureRequest1

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

    page: float

    position_x: Annotated[float, pydantic.Field(alias="positionX")]

    position_y: Annotated[float, pydantic.Field(alias="positionY")]

    width: float

    height: float

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

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


EnvelopeFieldCreateManyDataUnionTypedDict = TypeAliasType(
    "EnvelopeFieldCreateManyDataUnionTypedDict",
    Union[
        EnvelopeFieldCreateManyDataFreeSignatureTypedDict,
        EnvelopeFieldCreateManyDataSignatureTypedDict,
        EnvelopeFieldCreateManyDataInitialsTypedDict,
        EnvelopeFieldCreateManyDataNameTypedDict,
        EnvelopeFieldCreateManyDataEmailTypedDict,
        EnvelopeFieldCreateManyDataDateTypedDict,
        EnvelopeFieldCreateManyDataTextTypedDict,
        EnvelopeFieldCreateManyDataNumberTypedDict,
        EnvelopeFieldCreateManyDataRadioTypedDict,
        EnvelopeFieldCreateManyDataCheckboxTypedDict,
        EnvelopeFieldCreateManyDataDropdownTypedDict,
    ],
)


EnvelopeFieldCreateManyDataUnion = TypeAliasType(
    "EnvelopeFieldCreateManyDataUnion",
    Union[
        EnvelopeFieldCreateManyDataFreeSignature,
        EnvelopeFieldCreateManyDataSignature,
        EnvelopeFieldCreateManyDataInitials,
        EnvelopeFieldCreateManyDataName,
        EnvelopeFieldCreateManyDataEmail,
        EnvelopeFieldCreateManyDataDate,
        EnvelopeFieldCreateManyDataText,
        EnvelopeFieldCreateManyDataNumber,
        EnvelopeFieldCreateManyDataRadio,
        EnvelopeFieldCreateManyDataCheckbox,
        EnvelopeFieldCreateManyDataDropdown,
    ],
)


class EnvelopeFieldCreateManyRequestTypedDict(TypedDict):
    envelope_id: str
    data: List[EnvelopeFieldCreateManyDataUnionTypedDict]


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

    data: List[EnvelopeFieldCreateManyDataUnion]


class EnvelopeFieldCreateManyInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class EnvelopeFieldCreateManyInternalServerErrorIssue(BaseModel):
    message: str


class EnvelopeFieldCreateManyInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeFieldCreateManyInternalServerErrorIssue]] = None


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

    data: EnvelopeFieldCreateManyInternalServerErrorData = field(hash=False)

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


class EnvelopeFieldCreateManyForbiddenIssue(BaseModel):
    message: str


class EnvelopeFieldCreateManyForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeFieldCreateManyForbiddenIssue]] = None


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

    data: EnvelopeFieldCreateManyForbiddenErrorData = field(hash=False)

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


class EnvelopeFieldCreateManyUnauthorizedIssue(BaseModel):
    message: str


class EnvelopeFieldCreateManyUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeFieldCreateManyUnauthorizedIssue]] = None


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

    data: EnvelopeFieldCreateManyUnauthorizedErrorData = field(hash=False)

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


class EnvelopeFieldCreateManyBadRequestIssue(BaseModel):
    message: str


class EnvelopeFieldCreateManyBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeFieldCreateManyBadRequestIssue]] = None


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

    data: EnvelopeFieldCreateManyBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: EnvelopeFieldCreateManyBadRequestErrorData,
        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 EnvelopeFieldCreateManyTypeResponse(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 EnvelopeFieldCreateManyFieldMetaTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class EnvelopeFieldCreateManyValueResponse3TypedDict(TypedDict):
    value: str


class EnvelopeFieldCreateManyValueResponse3(BaseModel):
    value: str


class EnvelopeFieldCreateManyFieldMetaDropdownResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueResponse3TypedDict]]
    default_value: NotRequired[str]


class EnvelopeFieldCreateManyFieldMetaDropdownResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeDropdown

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

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


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


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


class EnvelopeFieldCreateManyValueResponse2(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaCheckboxResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueResponse2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[EnvelopeFieldCreateManyDirectionResponse2]


class EnvelopeFieldCreateManyFieldMetaCheckboxResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeCheckbox

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

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

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

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


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


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


class EnvelopeFieldCreateManyValueResponse1(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaRadioResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValueResponse1TypedDict]]
    direction: NotRequired[EnvelopeFieldCreateManyDirectionResponse1]


class EnvelopeFieldCreateManyFieldMetaRadioResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeRadio

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

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


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


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


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


class EnvelopeFieldCreateManyFieldMetaNumberResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeNumber
    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[EnvelopeFieldCreateManyTextAlignResponse6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlignResponse2]]


class EnvelopeFieldCreateManyFieldMetaNumberResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeNumber

    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[EnvelopeFieldCreateManyTextAlignResponse6],
        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[EnvelopeFieldCreateManyVerticalAlignResponse2],
        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 EnvelopeFieldCreateManyFieldMetaTypeText(str, Enum):
    TEXT = "text"


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


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


class EnvelopeFieldCreateManyFieldMetaTextResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeText
    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[EnvelopeFieldCreateManyTextAlignResponse5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlignResponse1]]


class EnvelopeFieldCreateManyFieldMetaTextResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeText

    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[EnvelopeFieldCreateManyTextAlignResponse5],
        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[EnvelopeFieldCreateManyVerticalAlignResponse1],
        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 EnvelopeFieldCreateManyFieldMetaTypeDate(str, Enum):
    DATE = "date"


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


class EnvelopeFieldCreateManyFieldMetaDateResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignResponse4]


class EnvelopeFieldCreateManyFieldMetaDateResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeDate

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


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


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


class EnvelopeFieldCreateManyFieldMetaEmailResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignResponse3]


class EnvelopeFieldCreateManyFieldMetaEmailResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeEmail

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


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


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


class EnvelopeFieldCreateManyFieldMetaNameResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignResponse2]


class EnvelopeFieldCreateManyFieldMetaNameResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeName

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


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


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


class EnvelopeFieldCreateManyFieldMetaInitialsResponseTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyFieldMetaTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlignResponse1]


class EnvelopeFieldCreateManyFieldMetaInitialsResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeInitials

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


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


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


class EnvelopeFieldCreateManyFieldMetaSignatureResponse(BaseModel):
    type: EnvelopeFieldCreateManyFieldMetaTypeSignature

    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


EnvelopeFieldCreateManyFieldMetaUnionTypedDict = TypeAliasType(
    "EnvelopeFieldCreateManyFieldMetaUnionTypedDict",
    Union[
        EnvelopeFieldCreateManyFieldMetaSignatureResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaInitialsResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaNameResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaEmailResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaDateResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaRadioResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaDropdownResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaCheckboxResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaTextResponseTypedDict,
        EnvelopeFieldCreateManyFieldMetaNumberResponseTypedDict,
    ],
)


EnvelopeFieldCreateManyFieldMetaUnion = TypeAliasType(
    "EnvelopeFieldCreateManyFieldMetaUnion",
    Union[
        EnvelopeFieldCreateManyFieldMetaSignatureResponse,
        EnvelopeFieldCreateManyFieldMetaInitialsResponse,
        EnvelopeFieldCreateManyFieldMetaNameResponse,
        EnvelopeFieldCreateManyFieldMetaEmailResponse,
        EnvelopeFieldCreateManyFieldMetaDateResponse,
        EnvelopeFieldCreateManyFieldMetaRadioResponse,
        EnvelopeFieldCreateManyFieldMetaDropdownResponse,
        EnvelopeFieldCreateManyFieldMetaCheckboxResponse,
        EnvelopeFieldCreateManyFieldMetaTextResponse,
        EnvelopeFieldCreateManyFieldMetaNumberResponse,
    ],
)


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


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

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

    type: EnvelopeFieldCreateManyTypeResponse

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

    data: List[EnvelopeFieldCreateManyDataResponseTypedDict]


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

    data: List[EnvelopeFieldCreateManyDataResponse]
