"""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 RecipientGetDocumentRecipientRequestTypedDict(TypedDict):
    recipient_id: float


class RecipientGetDocumentRecipientRequest(BaseModel):
    recipient_id: Annotated[
        float,
        pydantic.Field(alias="recipientId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]


class RecipientGetDocumentRecipientInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class RecipientGetDocumentRecipientInternalServerErrorIssue(BaseModel):
    message: str


class RecipientGetDocumentRecipientInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientInternalServerErrorIssue]] = None


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

    data: RecipientGetDocumentRecipientInternalServerErrorData = field(hash=False)

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


class RecipientGetDocumentRecipientNotFoundIssue(BaseModel):
    message: str


class RecipientGetDocumentRecipientNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientNotFoundIssue]] = None


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

    data: RecipientGetDocumentRecipientNotFoundErrorData = field(hash=False)

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


class RecipientGetDocumentRecipientForbiddenIssue(BaseModel):
    message: str


class RecipientGetDocumentRecipientForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientForbiddenIssue]] = None


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

    data: RecipientGetDocumentRecipientForbiddenErrorData = field(hash=False)

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


class RecipientGetDocumentRecipientUnauthorizedIssue(BaseModel):
    message: str


class RecipientGetDocumentRecipientUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientUnauthorizedIssue]] = None


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

    data: RecipientGetDocumentRecipientUnauthorizedErrorData = field(hash=False)

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


class RecipientGetDocumentRecipientBadRequestIssue(BaseModel):
    message: str


class RecipientGetDocumentRecipientBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientBadRequestIssue]] = None


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

    data: RecipientGetDocumentRecipientBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: RecipientGetDocumentRecipientBadRequestErrorData,
        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 RecipientGetDocumentRecipientRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


class RecipientGetDocumentRecipientReadStatus(str, Enum):
    NOT_OPENED = "NOT_OPENED"
    OPENED = "OPENED"


class RecipientGetDocumentRecipientSigningStatus(str, Enum):
    NOT_SIGNED = "NOT_SIGNED"
    SIGNED = "SIGNED"
    REJECTED = "REJECTED"


class RecipientGetDocumentRecipientSendStatus(str, Enum):
    NOT_SENT = "NOT_SENT"
    SENT = "SENT"


class RecipientGetDocumentRecipientAccessAuth(str, Enum):
    ACCOUNT = "ACCOUNT"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"


class RecipientGetDocumentRecipientActionAuth(str, Enum):
    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    PASSWORD = "PASSWORD"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class RecipientGetDocumentRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[RecipientGetDocumentRecipientAccessAuth]
    action_auth: List[RecipientGetDocumentRecipientActionAuth]


class RecipientGetDocumentRecipientAuthOptions(BaseModel):
    access_auth: Annotated[
        List[RecipientGetDocumentRecipientAccessAuth],
        pydantic.Field(alias="accessAuth"),
    ]

    action_auth: Annotated[
        List[RecipientGetDocumentRecipientActionAuth],
        pydantic.Field(alias="actionAuth"),
    ]


class RecipientGetDocumentRecipientType(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 RecipientGetDocumentRecipientTypeDropdown(str, Enum):
    DROPDOWN = "dropdown"


class RecipientGetDocumentRecipientValue3TypedDict(TypedDict):
    value: str


class RecipientGetDocumentRecipientValue3(BaseModel):
    value: str


class RecipientGetDocumentRecipientFieldMetaDropdownTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetDocumentRecipientValue3TypedDict]]
    default_value: NotRequired[str]


class RecipientGetDocumentRecipientFieldMetaDropdown(BaseModel):
    type: RecipientGetDocumentRecipientTypeDropdown

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

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


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


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


class RecipientGetDocumentRecipientValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientGetDocumentRecipientFieldMetaCheckboxTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetDocumentRecipientValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[RecipientGetDocumentRecipientDirection2]


class RecipientGetDocumentRecipientFieldMetaCheckbox(BaseModel):
    type: RecipientGetDocumentRecipientTypeCheckbox

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

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

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

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


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


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


class RecipientGetDocumentRecipientValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientGetDocumentRecipientFieldMetaRadioTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetDocumentRecipientValue1TypedDict]]
    direction: NotRequired[RecipientGetDocumentRecipientDirection1]


class RecipientGetDocumentRecipientFieldMetaRadio(BaseModel):
    type: RecipientGetDocumentRecipientTypeRadio

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

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


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


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


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


class RecipientGetDocumentRecipientFieldMetaNumberTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeNumber
    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[RecipientGetDocumentRecipientTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[RecipientGetDocumentRecipientVerticalAlign2]]


class RecipientGetDocumentRecipientFieldMetaNumber(BaseModel):
    type: RecipientGetDocumentRecipientTypeNumber

    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[RecipientGetDocumentRecipientTextAlign6],
        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[RecipientGetDocumentRecipientVerticalAlign2],
        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 RecipientGetDocumentRecipientTypeText(str, Enum):
    TEXT = "text"


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


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


class RecipientGetDocumentRecipientFieldMetaTextTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeText
    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[RecipientGetDocumentRecipientTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[RecipientGetDocumentRecipientVerticalAlign1]]


class RecipientGetDocumentRecipientFieldMetaText(BaseModel):
    type: RecipientGetDocumentRecipientTypeText

    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[RecipientGetDocumentRecipientTextAlign5],
        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[RecipientGetDocumentRecipientVerticalAlign1],
        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 RecipientGetDocumentRecipientTypeDate(str, Enum):
    DATE = "date"


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


class RecipientGetDocumentRecipientFieldMetaDateTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetDocumentRecipientTextAlign4]


class RecipientGetDocumentRecipientFieldMetaDate(BaseModel):
    type: RecipientGetDocumentRecipientTypeDate

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


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


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


class RecipientGetDocumentRecipientFieldMetaEmailTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetDocumentRecipientTextAlign3]


class RecipientGetDocumentRecipientFieldMetaEmail(BaseModel):
    type: RecipientGetDocumentRecipientTypeEmail

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


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


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


class RecipientGetDocumentRecipientFieldMetaNameTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetDocumentRecipientTextAlign2]


class RecipientGetDocumentRecipientFieldMetaName(BaseModel):
    type: RecipientGetDocumentRecipientTypeName

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


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


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


class RecipientGetDocumentRecipientFieldMetaInitialsTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetDocumentRecipientTextAlign1]


class RecipientGetDocumentRecipientFieldMetaInitials(BaseModel):
    type: RecipientGetDocumentRecipientTypeInitials

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


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


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


class RecipientGetDocumentRecipientFieldMetaSignature(BaseModel):
    type: RecipientGetDocumentRecipientTypeSignature

    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


RecipientGetDocumentRecipientFieldMetaUnionTypedDict = TypeAliasType(
    "RecipientGetDocumentRecipientFieldMetaUnionTypedDict",
    Union[
        RecipientGetDocumentRecipientFieldMetaSignatureTypedDict,
        RecipientGetDocumentRecipientFieldMetaInitialsTypedDict,
        RecipientGetDocumentRecipientFieldMetaNameTypedDict,
        RecipientGetDocumentRecipientFieldMetaEmailTypedDict,
        RecipientGetDocumentRecipientFieldMetaDateTypedDict,
        RecipientGetDocumentRecipientFieldMetaRadioTypedDict,
        RecipientGetDocumentRecipientFieldMetaDropdownTypedDict,
        RecipientGetDocumentRecipientFieldMetaCheckboxTypedDict,
        RecipientGetDocumentRecipientFieldMetaTextTypedDict,
        RecipientGetDocumentRecipientFieldMetaNumberTypedDict,
    ],
)


RecipientGetDocumentRecipientFieldMetaUnion = TypeAliasType(
    "RecipientGetDocumentRecipientFieldMetaUnion",
    Union[
        RecipientGetDocumentRecipientFieldMetaSignature,
        RecipientGetDocumentRecipientFieldMetaInitials,
        RecipientGetDocumentRecipientFieldMetaName,
        RecipientGetDocumentRecipientFieldMetaEmail,
        RecipientGetDocumentRecipientFieldMetaDate,
        RecipientGetDocumentRecipientFieldMetaRadio,
        RecipientGetDocumentRecipientFieldMetaDropdown,
        RecipientGetDocumentRecipientFieldMetaCheckbox,
        RecipientGetDocumentRecipientFieldMetaText,
        RecipientGetDocumentRecipientFieldMetaNumber,
    ],
)


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


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

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

    type: RecipientGetDocumentRecipientType

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

    envelope_id: str
    role: RecipientGetDocumentRecipientRole
    read_status: RecipientGetDocumentRecipientReadStatus
    signing_status: RecipientGetDocumentRecipientSigningStatus
    send_status: RecipientGetDocumentRecipientSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientGetDocumentRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    fields: List[RecipientGetDocumentRecipientFieldTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

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

    role: RecipientGetDocumentRecipientRole

    read_status: Annotated[
        RecipientGetDocumentRecipientReadStatus, pydantic.Field(alias="readStatus")
    ]

    signing_status: Annotated[
        RecipientGetDocumentRecipientSigningStatus,
        pydantic.Field(alias="signingStatus"),
    ]

    send_status: Annotated[
        RecipientGetDocumentRecipientSendStatus, pydantic.Field(alias="sendStatus")
    ]

    id: float

    email: str

    name: str

    token: str

    document_deleted_at: Annotated[
        Nullable[str], pydantic.Field(alias="documentDeletedAt")
    ]

    expired: Nullable[str]

    signed_at: Annotated[Nullable[str], pydantic.Field(alias="signedAt")]

    auth_options: Annotated[
        Nullable[RecipientGetDocumentRecipientAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

    signing_order: Annotated[Nullable[float], pydantic.Field(alias="signingOrder")]

    rejection_reason: Annotated[Nullable[str], pydantic.Field(alias="rejectionReason")]

    fields: List[RecipientGetDocumentRecipientField]

    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 = [
            "documentDeletedAt",
            "expired",
            "signedAt",
            "authOptions",
            "signingOrder",
            "rejectionReason",
            "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
