"""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 documenso_sdk.utils import get_discriminator
from enum import Enum
import httpx
import pydantic
from pydantic import Discriminator, Tag, model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class EnvelopeFieldCreateManyDataRequest2TypedDict(TypedDict):
    placeholder: str
    recipient_id: float
    width: NotRequired[float]
    height: NotRequired[float]
    match_all: NotRequired[bool]
    envelope_item_id: NotRequired[str]


class EnvelopeFieldCreateManyDataRequest2(BaseModel):
    placeholder: str

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

    width: Optional[float] = None

    height: Optional[float] = None

    match_all: Annotated[Optional[bool], pydantic.Field(alias="matchAll")] = None

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["width", "height", "matchAll", "envelopeItemId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


class EnvelopeFieldCreateManyDataRequest1(BaseModel):
    page: float

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

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

    width: float

    height: float

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["envelopeItemId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


EnvelopeFieldCreateManyDataUnionTypedDict = TypeAliasType(
    "EnvelopeFieldCreateManyDataUnionTypedDict",
    Union[
        EnvelopeFieldCreateManyDataRequest2TypedDict,
        EnvelopeFieldCreateManyDataRequest1TypedDict,
    ],
)


EnvelopeFieldCreateManyDataUnion = TypeAliasType(
    "EnvelopeFieldCreateManyDataUnion",
    Union[EnvelopeFieldCreateManyDataRequest2, EnvelopeFieldCreateManyDataRequest1],
)


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


class EnvelopeFieldCreateManyValue3TypedDict(TypedDict):
    value: str


class EnvelopeFieldCreateManyValue3(BaseModel):
    value: str


class EnvelopeFieldCreateManyFieldMetaDropdownTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValue3TypedDict]]
    default_value: NotRequired[str]


class EnvelopeFieldCreateManyFieldMetaDropdown(BaseModel):
    type: EnvelopeFieldCreateManyTypeDropdown

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "defaultValue",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaCheckboxTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[EnvelopeFieldCreateManyDirection2]


class EnvelopeFieldCreateManyFieldMetaCheckbox(BaseModel):
    type: EnvelopeFieldCreateManyTypeCheckbox

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

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

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "validationRule",
                "validationLength",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class EnvelopeFieldCreateManyFieldMetaRadioTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[EnvelopeFieldCreateManyValue1TypedDict]]
    direction: NotRequired[EnvelopeFieldCreateManyDirection1]


class EnvelopeFieldCreateManyFieldMetaRadio(BaseModel):
    type: EnvelopeFieldCreateManyTypeRadio

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

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "values",
                "direction",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


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


class EnvelopeFieldCreateManyFieldMetaNumberTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeNumber
    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[EnvelopeFieldCreateManyTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlign2]]


class EnvelopeFieldCreateManyFieldMetaNumber(BaseModel):
    type: EnvelopeFieldCreateManyTypeNumber

    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[EnvelopeFieldCreateManyTextAlign6], 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[EnvelopeFieldCreateManyVerticalAlign2],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "numberFormat",
                "value",
                "minValue",
                "maxValue",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(
            [
                "numberFormat",
                "minValue",
                "maxValue",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


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


class EnvelopeFieldCreateManyFieldMetaTextTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeText
    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[EnvelopeFieldCreateManyTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[EnvelopeFieldCreateManyVerticalAlign1]]


class EnvelopeFieldCreateManyFieldMetaText(BaseModel):
    type: EnvelopeFieldCreateManyTypeText

    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[EnvelopeFieldCreateManyTextAlign5], 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[EnvelopeFieldCreateManyVerticalAlign1],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "label",
                "placeholder",
                "required",
                "readOnly",
                "fontSize",
                "text",
                "characterLimit",
                "textAlign",
                "lineHeight",
                "letterSpacing",
                "verticalAlign",
            ]
        )
        nullable_fields = set(["lineHeight", "letterSpacing", "verticalAlign"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyFieldMetaDateTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlign4]


class EnvelopeFieldCreateManyFieldMetaDate(BaseModel):
    type: EnvelopeFieldCreateManyTypeDate

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyFieldMetaEmailTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlign3]


class EnvelopeFieldCreateManyFieldMetaEmail(BaseModel):
    type: EnvelopeFieldCreateManyTypeEmail

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyFieldMetaNameTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlign2]


class EnvelopeFieldCreateManyFieldMetaName(BaseModel):
    type: EnvelopeFieldCreateManyTypeName

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyFieldMetaInitialsTypedDict(TypedDict):
    type: EnvelopeFieldCreateManyTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[EnvelopeFieldCreateManyTextAlign1]


class EnvelopeFieldCreateManyFieldMetaInitials(BaseModel):
    type: EnvelopeFieldCreateManyTypeInitials

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize", "textAlign"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


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


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


class EnvelopeFieldCreateManyFieldMetaSignature(BaseModel):
    type: EnvelopeFieldCreateManyTypeSignature

    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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["label", "placeholder", "required", "readOnly", "fontSize"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


EnvelopeFieldCreateManyFieldMetaUnionTypedDict = TypeAliasType(
    "EnvelopeFieldCreateManyFieldMetaUnionTypedDict",
    Union[
        EnvelopeFieldCreateManyFieldMetaSignatureTypedDict,
        EnvelopeFieldCreateManyFieldMetaInitialsTypedDict,
        EnvelopeFieldCreateManyFieldMetaNameTypedDict,
        EnvelopeFieldCreateManyFieldMetaEmailTypedDict,
        EnvelopeFieldCreateManyFieldMetaDateTypedDict,
        EnvelopeFieldCreateManyFieldMetaRadioTypedDict,
        EnvelopeFieldCreateManyFieldMetaDropdownTypedDict,
        EnvelopeFieldCreateManyFieldMetaCheckboxTypedDict,
        EnvelopeFieldCreateManyFieldMetaTextTypedDict,
        EnvelopeFieldCreateManyFieldMetaNumberTypedDict,
    ],
)


EnvelopeFieldCreateManyFieldMetaUnion = Annotated[
    Union[
        Annotated[EnvelopeFieldCreateManyFieldMetaSignature, Tag("signature")],
        Annotated[EnvelopeFieldCreateManyFieldMetaInitials, Tag("initials")],
        Annotated[EnvelopeFieldCreateManyFieldMetaName, Tag("name")],
        Annotated[EnvelopeFieldCreateManyFieldMetaEmail, Tag("email")],
        Annotated[EnvelopeFieldCreateManyFieldMetaDate, Tag("date")],
        Annotated[EnvelopeFieldCreateManyFieldMetaText, Tag("text")],
        Annotated[EnvelopeFieldCreateManyFieldMetaNumber, Tag("number")],
        Annotated[EnvelopeFieldCreateManyFieldMetaRadio, Tag("radio")],
        Annotated[EnvelopeFieldCreateManyFieldMetaCheckbox, Tag("checkbox")],
        Annotated[EnvelopeFieldCreateManyFieldMetaDropdown, Tag("dropdown")],
    ],
    Discriminator(lambda m: get_discriminator(m, "type", "type")),
]


class EnvelopeFieldCreateManyDataResponseTypedDict(TypedDict):
    envelope_id: str
    envelope_item_id: str
    type: EnvelopeFieldCreateManyType
    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: EnvelopeFieldCreateManyType

    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 = set(["documentId", "templateId"])
        nullable_fields = set(["fieldMeta", "documentId", "templateId"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


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

    data: List[EnvelopeFieldCreateManyDataResponseTypedDict]


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

    data: List[EnvelopeFieldCreateManyDataResponse]
