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


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


class RecipientGetTemplateRecipientInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class RecipientGetTemplateRecipientInternalServerErrorIssue(BaseModel):
    message: str


class RecipientGetTemplateRecipientInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetTemplateRecipientInternalServerErrorIssue]] = None


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

    data: RecipientGetTemplateRecipientInternalServerErrorData = field(hash=False)

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


class RecipientGetTemplateRecipientNotFoundIssue(BaseModel):
    message: str


class RecipientGetTemplateRecipientNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetTemplateRecipientNotFoundIssue]] = None


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

    data: RecipientGetTemplateRecipientNotFoundErrorData = field(hash=False)

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


class RecipientGetTemplateRecipientForbiddenIssue(BaseModel):
    message: str


class RecipientGetTemplateRecipientForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetTemplateRecipientForbiddenIssue]] = None


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

    data: RecipientGetTemplateRecipientForbiddenErrorData = field(hash=False)

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


class RecipientGetTemplateRecipientUnauthorizedIssue(BaseModel):
    message: str


class RecipientGetTemplateRecipientUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetTemplateRecipientUnauthorizedIssue]] = None


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

    data: RecipientGetTemplateRecipientUnauthorizedErrorData = field(hash=False)

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


class RecipientGetTemplateRecipientBadRequestIssue(BaseModel):
    message: str


class RecipientGetTemplateRecipientBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetTemplateRecipientBadRequestIssue]] = None


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

    data: RecipientGetTemplateRecipientBadRequestErrorData = field(hash=False)

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


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


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


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


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


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


class RecipientGetTemplateRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: List[RecipientGetTemplateRecipientAccessAuth]
    action_auth: List[RecipientGetTemplateRecipientActionAuth]


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

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


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


class RecipientGetTemplateRecipientValue3TypedDict(TypedDict):
    value: str


class RecipientGetTemplateRecipientValue3(BaseModel):
    value: str


class RecipientGetTemplateRecipientFieldMetaDropdownTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetTemplateRecipientValue3TypedDict]]
    default_value: NotRequired[str]


class RecipientGetTemplateRecipientFieldMetaDropdown(BaseModel):
    type: RecipientGetTemplateRecipientTypeDropdown

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

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


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


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


class RecipientGetTemplateRecipientValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientGetTemplateRecipientFieldMetaCheckboxTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetTemplateRecipientValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[RecipientGetTemplateRecipientDirection2]


class RecipientGetTemplateRecipientFieldMetaCheckbox(BaseModel):
    type: RecipientGetTemplateRecipientTypeCheckbox

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

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

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

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


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


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


class RecipientGetTemplateRecipientValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientGetTemplateRecipientFieldMetaRadioTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientGetTemplateRecipientValue1TypedDict]]
    direction: NotRequired[RecipientGetTemplateRecipientDirection1]


class RecipientGetTemplateRecipientFieldMetaRadio(BaseModel):
    type: RecipientGetTemplateRecipientTypeRadio

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

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


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


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


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


class RecipientGetTemplateRecipientFieldMetaNumberTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeNumber
    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[RecipientGetTemplateRecipientTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[RecipientGetTemplateRecipientVerticalAlign2]]


class RecipientGetTemplateRecipientFieldMetaNumber(BaseModel):
    type: RecipientGetTemplateRecipientTypeNumber

    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[RecipientGetTemplateRecipientTextAlign6],
        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[RecipientGetTemplateRecipientVerticalAlign2],
        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 RecipientGetTemplateRecipientTypeText(str, Enum):
    TEXT = "text"


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


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


class RecipientGetTemplateRecipientFieldMetaTextTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeText
    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[RecipientGetTemplateRecipientTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[RecipientGetTemplateRecipientVerticalAlign1]]


class RecipientGetTemplateRecipientFieldMetaText(BaseModel):
    type: RecipientGetTemplateRecipientTypeText

    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[RecipientGetTemplateRecipientTextAlign5],
        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[RecipientGetTemplateRecipientVerticalAlign1],
        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 RecipientGetTemplateRecipientTypeDate(str, Enum):
    DATE = "date"


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


class RecipientGetTemplateRecipientFieldMetaDateTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetTemplateRecipientTextAlign4]


class RecipientGetTemplateRecipientFieldMetaDate(BaseModel):
    type: RecipientGetTemplateRecipientTypeDate

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


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


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


class RecipientGetTemplateRecipientFieldMetaEmailTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetTemplateRecipientTextAlign3]


class RecipientGetTemplateRecipientFieldMetaEmail(BaseModel):
    type: RecipientGetTemplateRecipientTypeEmail

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


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


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


class RecipientGetTemplateRecipientFieldMetaNameTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetTemplateRecipientTextAlign2]


class RecipientGetTemplateRecipientFieldMetaName(BaseModel):
    type: RecipientGetTemplateRecipientTypeName

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


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


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


class RecipientGetTemplateRecipientFieldMetaInitialsTypedDict(TypedDict):
    type: RecipientGetTemplateRecipientTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientGetTemplateRecipientTextAlign1]


class RecipientGetTemplateRecipientFieldMetaInitials(BaseModel):
    type: RecipientGetTemplateRecipientTypeInitials

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


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


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


class RecipientGetTemplateRecipientFieldMetaSignature(BaseModel):
    type: RecipientGetTemplateRecipientTypeSignature

    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


RecipientGetTemplateRecipientFieldMetaUnionTypedDict = TypeAliasType(
    "RecipientGetTemplateRecipientFieldMetaUnionTypedDict",
    Union[
        RecipientGetTemplateRecipientFieldMetaSignatureTypedDict,
        RecipientGetTemplateRecipientFieldMetaInitialsTypedDict,
        RecipientGetTemplateRecipientFieldMetaNameTypedDict,
        RecipientGetTemplateRecipientFieldMetaEmailTypedDict,
        RecipientGetTemplateRecipientFieldMetaDateTypedDict,
        RecipientGetTemplateRecipientFieldMetaRadioTypedDict,
        RecipientGetTemplateRecipientFieldMetaDropdownTypedDict,
        RecipientGetTemplateRecipientFieldMetaCheckboxTypedDict,
        RecipientGetTemplateRecipientFieldMetaTextTypedDict,
        RecipientGetTemplateRecipientFieldMetaNumberTypedDict,
    ],
)


RecipientGetTemplateRecipientFieldMetaUnion = TypeAliasType(
    "RecipientGetTemplateRecipientFieldMetaUnion",
    Union[
        RecipientGetTemplateRecipientFieldMetaSignature,
        RecipientGetTemplateRecipientFieldMetaInitials,
        RecipientGetTemplateRecipientFieldMetaName,
        RecipientGetTemplateRecipientFieldMetaEmail,
        RecipientGetTemplateRecipientFieldMetaDate,
        RecipientGetTemplateRecipientFieldMetaRadio,
        RecipientGetTemplateRecipientFieldMetaDropdown,
        RecipientGetTemplateRecipientFieldMetaCheckbox,
        RecipientGetTemplateRecipientFieldMetaText,
        RecipientGetTemplateRecipientFieldMetaNumber,
    ],
)


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


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

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

    type: RecipientGetTemplateRecipientType

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

    envelope_id: str
    role: RecipientGetTemplateRecipientRole
    read_status: RecipientGetTemplateRecipientReadStatus
    signing_status: RecipientGetTemplateRecipientSigningStatus
    send_status: RecipientGetTemplateRecipientSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientGetTemplateRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    fields: List[RecipientGetTemplateRecipientFieldTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

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

    role: RecipientGetTemplateRecipientRole

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

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

    send_status: Annotated[
        RecipientGetTemplateRecipientSendStatus, 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[RecipientGetTemplateRecipientAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

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

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

    fields: List[RecipientGetTemplateRecipientField]

    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
