"""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 FieldGetDocumentFieldRequestTypedDict(TypedDict):
    field_id: float


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


class FieldGetDocumentFieldInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class FieldGetDocumentFieldInternalServerErrorIssue(BaseModel):
    message: str


class FieldGetDocumentFieldInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetDocumentFieldInternalServerErrorIssue]] = None


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

    data: FieldGetDocumentFieldInternalServerErrorData = field(hash=False)

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


class FieldGetDocumentFieldNotFoundIssue(BaseModel):
    message: str


class FieldGetDocumentFieldNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetDocumentFieldNotFoundIssue]] = None


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

    data: FieldGetDocumentFieldNotFoundErrorData = field(hash=False)

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


class FieldGetDocumentFieldForbiddenIssue(BaseModel):
    message: str


class FieldGetDocumentFieldForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetDocumentFieldForbiddenIssue]] = None


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

    data: FieldGetDocumentFieldForbiddenErrorData = field(hash=False)

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


class FieldGetDocumentFieldUnauthorizedIssue(BaseModel):
    message: str


class FieldGetDocumentFieldUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetDocumentFieldUnauthorizedIssue]] = None


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

    data: FieldGetDocumentFieldUnauthorizedErrorData = field(hash=False)

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


class FieldGetDocumentFieldBadRequestIssue(BaseModel):
    message: str


class FieldGetDocumentFieldBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[FieldGetDocumentFieldBadRequestIssue]] = None


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

    data: FieldGetDocumentFieldBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: FieldGetDocumentFieldBadRequestErrorData,
        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 FieldGetDocumentFieldType(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 FieldGetDocumentFieldTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class FieldGetDocumentFieldValue3TypedDict(TypedDict):
    value: str


class FieldGetDocumentFieldValue3(BaseModel):
    value: str


class FieldGetDocumentFieldFieldMetaDropdownTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetDocumentFieldValue3TypedDict]]
    default_value: NotRequired[str]


class FieldGetDocumentFieldFieldMetaDropdown(BaseModel):
    type: FieldGetDocumentFieldTypeDropdown

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

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


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


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


class FieldGetDocumentFieldValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldGetDocumentFieldFieldMetaCheckboxTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetDocumentFieldValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[FieldGetDocumentFieldDirection2]


class FieldGetDocumentFieldFieldMetaCheckbox(BaseModel):
    type: FieldGetDocumentFieldTypeCheckbox

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

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

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

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


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


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


class FieldGetDocumentFieldValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class FieldGetDocumentFieldFieldMetaRadioTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[FieldGetDocumentFieldValue1TypedDict]]
    direction: NotRequired[FieldGetDocumentFieldDirection1]


class FieldGetDocumentFieldFieldMetaRadio(BaseModel):
    type: FieldGetDocumentFieldTypeRadio

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

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


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


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


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


class FieldGetDocumentFieldFieldMetaNumberTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeNumber
    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[FieldGetDocumentFieldTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldGetDocumentFieldVerticalAlign2]]


class FieldGetDocumentFieldFieldMetaNumber(BaseModel):
    type: FieldGetDocumentFieldTypeNumber

    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[FieldGetDocumentFieldTextAlign6], 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[FieldGetDocumentFieldVerticalAlign2],
        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 FieldGetDocumentFieldTypeText(str, Enum):
    TEXT = "text"


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


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


class FieldGetDocumentFieldFieldMetaTextTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeText
    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[FieldGetDocumentFieldTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[FieldGetDocumentFieldVerticalAlign1]]


class FieldGetDocumentFieldFieldMetaText(BaseModel):
    type: FieldGetDocumentFieldTypeText

    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[FieldGetDocumentFieldTextAlign5], 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[FieldGetDocumentFieldVerticalAlign1],
        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 FieldGetDocumentFieldTypeDate(str, Enum):
    DATE = "date"


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


class FieldGetDocumentFieldFieldMetaDateTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetDocumentFieldTextAlign4]


class FieldGetDocumentFieldFieldMetaDate(BaseModel):
    type: FieldGetDocumentFieldTypeDate

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


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


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


class FieldGetDocumentFieldFieldMetaEmailTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetDocumentFieldTextAlign3]


class FieldGetDocumentFieldFieldMetaEmail(BaseModel):
    type: FieldGetDocumentFieldTypeEmail

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


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


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


class FieldGetDocumentFieldFieldMetaNameTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetDocumentFieldTextAlign2]


class FieldGetDocumentFieldFieldMetaName(BaseModel):
    type: FieldGetDocumentFieldTypeName

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


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


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


class FieldGetDocumentFieldFieldMetaInitialsTypedDict(TypedDict):
    type: FieldGetDocumentFieldTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[FieldGetDocumentFieldTextAlign1]


class FieldGetDocumentFieldFieldMetaInitials(BaseModel):
    type: FieldGetDocumentFieldTypeInitials

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


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


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


class FieldGetDocumentFieldFieldMetaSignature(BaseModel):
    type: FieldGetDocumentFieldTypeSignature

    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


FieldGetDocumentFieldFieldMetaUnionTypedDict = TypeAliasType(
    "FieldGetDocumentFieldFieldMetaUnionTypedDict",
    Union[
        FieldGetDocumentFieldFieldMetaSignatureTypedDict,
        FieldGetDocumentFieldFieldMetaInitialsTypedDict,
        FieldGetDocumentFieldFieldMetaNameTypedDict,
        FieldGetDocumentFieldFieldMetaEmailTypedDict,
        FieldGetDocumentFieldFieldMetaDateTypedDict,
        FieldGetDocumentFieldFieldMetaRadioTypedDict,
        FieldGetDocumentFieldFieldMetaDropdownTypedDict,
        FieldGetDocumentFieldFieldMetaCheckboxTypedDict,
        FieldGetDocumentFieldFieldMetaTextTypedDict,
        FieldGetDocumentFieldFieldMetaNumberTypedDict,
    ],
)


FieldGetDocumentFieldFieldMetaUnion = TypeAliasType(
    "FieldGetDocumentFieldFieldMetaUnion",
    Union[
        FieldGetDocumentFieldFieldMetaSignature,
        FieldGetDocumentFieldFieldMetaInitials,
        FieldGetDocumentFieldFieldMetaName,
        FieldGetDocumentFieldFieldMetaEmail,
        FieldGetDocumentFieldFieldMetaDate,
        FieldGetDocumentFieldFieldMetaRadio,
        FieldGetDocumentFieldFieldMetaDropdown,
        FieldGetDocumentFieldFieldMetaCheckbox,
        FieldGetDocumentFieldFieldMetaText,
        FieldGetDocumentFieldFieldMetaNumber,
    ],
)


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

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


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

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

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

    type: FieldGetDocumentFieldType

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