"""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 FieldMetadata, PathParamMetadata
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 FieldGetTemplateFieldRequestTypedDict(TypedDict):
    field_id: float


class FieldGetTemplateFieldRequest(BaseModel):
    field_id: Annotated[
        float,
        pydantic.Field(alias="fieldId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]


class FieldGetTemplateFieldInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldGetTemplateFieldInternalServerErrorIssue(BaseModel):
    message: str


class FieldGetTemplateFieldInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetTemplateFieldInternalServerErrorIssue]] = None


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

    data: FieldGetTemplateFieldInternalServerErrorData = field(hash=False)

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


class FieldGetTemplateFieldNotFoundIssue(BaseModel):
    message: str


class FieldGetTemplateFieldNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetTemplateFieldNotFoundIssue]] = None


@dataclass(unsafe_hash=True)
class FieldGetTemplateFieldNotFoundError(DocumensoError):
    r"""Not found"""

    data: FieldGetTemplateFieldNotFoundErrorData = field(hash=False)

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


class FieldGetTemplateFieldForbiddenIssue(BaseModel):
    message: str


class FieldGetTemplateFieldForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetTemplateFieldForbiddenIssue]] = None


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

    data: FieldGetTemplateFieldForbiddenErrorData = field(hash=False)

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


class FieldGetTemplateFieldUnauthorizedIssue(BaseModel):
    message: str


class FieldGetTemplateFieldUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetTemplateFieldUnauthorizedIssue]] = None


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

    data: FieldGetTemplateFieldUnauthorizedErrorData = field(hash=False)

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


class FieldGetTemplateFieldBadRequestIssue(BaseModel):
    message: str


class FieldGetTemplateFieldBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetTemplateFieldBadRequestIssue]] = None


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

    data: FieldGetTemplateFieldBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldGetTemplateFieldBadRequestErrorData,
        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 FieldGetTemplateFieldType(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 FieldGetTemplateFieldTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldGetTemplateFieldValue3TypedDict(TypedDict):
    value: str


class FieldGetTemplateFieldValue3(BaseModel):
    value: str


class FieldGetTemplateFieldFieldMetaDropdownTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetTemplateFieldValue3TypedDict]]
    default_value: NotRequired[str]


class FieldGetTemplateFieldFieldMetaDropdown(BaseModel):
    type: FieldGetTemplateFieldTypeDropdown

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

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


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


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


class FieldGetTemplateFieldValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldGetTemplateFieldFieldMetaCheckboxTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetTemplateFieldValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldGetTemplateFieldDirection2]


class FieldGetTemplateFieldFieldMetaCheckbox(BaseModel):
    type: FieldGetTemplateFieldTypeCheckbox

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

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

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

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


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


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


class FieldGetTemplateFieldValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldGetTemplateFieldFieldMetaRadioTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetTemplateFieldValue1TypedDict]]
    direction: NotRequired[FieldGetTemplateFieldDirection1]


class FieldGetTemplateFieldFieldMetaRadio(BaseModel):
    type: FieldGetTemplateFieldTypeRadio

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

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


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


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


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


class FieldGetTemplateFieldFieldMetaNumberTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeNumber
    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[FieldGetTemplateFieldTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldGetTemplateFieldVerticalAlign2]]


class FieldGetTemplateFieldFieldMetaNumber(BaseModel):
    type: FieldGetTemplateFieldTypeNumber

    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[FieldGetTemplateFieldTextAlign6], 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[FieldGetTemplateFieldVerticalAlign2],
        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 FieldGetTemplateFieldTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldGetTemplateFieldFieldMetaTextTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeText
    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[FieldGetTemplateFieldTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldGetTemplateFieldVerticalAlign1]]


class FieldGetTemplateFieldFieldMetaText(BaseModel):
    type: FieldGetTemplateFieldTypeText

    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[FieldGetTemplateFieldTextAlign5], 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[FieldGetTemplateFieldVerticalAlign1],
        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 FieldGetTemplateFieldTypeDate(str, Enum):
    DATE = "date"


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


class FieldGetTemplateFieldFieldMetaDateTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetTemplateFieldTextAlign4]


class FieldGetTemplateFieldFieldMetaDate(BaseModel):
    type: FieldGetTemplateFieldTypeDate

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


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


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


class FieldGetTemplateFieldFieldMetaEmailTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetTemplateFieldTextAlign3]


class FieldGetTemplateFieldFieldMetaEmail(BaseModel):
    type: FieldGetTemplateFieldTypeEmail

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


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


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


class FieldGetTemplateFieldFieldMetaNameTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetTemplateFieldTextAlign2]


class FieldGetTemplateFieldFieldMetaName(BaseModel):
    type: FieldGetTemplateFieldTypeName

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


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


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


class FieldGetTemplateFieldFieldMetaInitialsTypedDict(TypedDict):
    type: FieldGetTemplateFieldTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetTemplateFieldTextAlign1]


class FieldGetTemplateFieldFieldMetaInitials(BaseModel):
    type: FieldGetTemplateFieldTypeInitials

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


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


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


class FieldGetTemplateFieldFieldMetaSignature(BaseModel):
    type: FieldGetTemplateFieldTypeSignature

    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


FieldGetTemplateFieldFieldMetaUnionTypedDict = TypeAliasType(
    "FieldGetTemplateFieldFieldMetaUnionTypedDict",
    Union[
        FieldGetTemplateFieldFieldMetaSignatureTypedDict,
        FieldGetTemplateFieldFieldMetaInitialsTypedDict,
        FieldGetTemplateFieldFieldMetaNameTypedDict,
        FieldGetTemplateFieldFieldMetaEmailTypedDict,
        FieldGetTemplateFieldFieldMetaDateTypedDict,
        FieldGetTemplateFieldFieldMetaRadioTypedDict,
        FieldGetTemplateFieldFieldMetaDropdownTypedDict,
        FieldGetTemplateFieldFieldMetaCheckboxTypedDict,
        FieldGetTemplateFieldFieldMetaTextTypedDict,
        FieldGetTemplateFieldFieldMetaNumberTypedDict,
    ],
)


FieldGetTemplateFieldFieldMetaUnion = TypeAliasType(
    "FieldGetTemplateFieldFieldMetaUnion",
    Union[
        FieldGetTemplateFieldFieldMetaSignature,
        FieldGetTemplateFieldFieldMetaInitials,
        FieldGetTemplateFieldFieldMetaName,
        FieldGetTemplateFieldFieldMetaEmail,
        FieldGetTemplateFieldFieldMetaDate,
        FieldGetTemplateFieldFieldMetaRadio,
        FieldGetTemplateFieldFieldMetaDropdown,
        FieldGetTemplateFieldFieldMetaCheckbox,
        FieldGetTemplateFieldFieldMetaText,
        FieldGetTemplateFieldFieldMetaNumber,
    ],
)


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

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


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

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

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

    type: FieldGetTemplateFieldType

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