"""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 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 RecipientUpdateTemplateRecipientsRoleRequest(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"
    ASSISTANT = "ASSISTANT"


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


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


class RecipientUpdateTemplateRecipientsRecipientRequestTypedDict(TypedDict):
    id: float
    email: NotRequired[str]
    name: NotRequired[str]
    role: NotRequired[RecipientUpdateTemplateRecipientsRoleRequest]
    signing_order: NotRequired[float]
    access_auth: NotRequired[List[RecipientUpdateTemplateRecipientsAccessAuthRequest]]
    action_auth: NotRequired[List[RecipientUpdateTemplateRecipientsActionAuthRequest]]


class RecipientUpdateTemplateRecipientsRecipientRequest(BaseModel):
    id: float

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateTemplateRecipientsRoleRequest] = None

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

    access_auth: Annotated[
        Optional[List[RecipientUpdateTemplateRecipientsAccessAuthRequest]],
        pydantic.Field(alias="accessAuth"),
    ] = None

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


class RecipientUpdateTemplateRecipientsRequestTypedDict(TypedDict):
    template_id: float
    recipients: List[RecipientUpdateTemplateRecipientsRecipientRequestTypedDict]


class RecipientUpdateTemplateRecipientsRequest(BaseModel):
    template_id: Annotated[float, pydantic.Field(alias="templateId")]

    recipients: List[RecipientUpdateTemplateRecipientsRecipientRequest]


class RecipientUpdateTemplateRecipientsInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class RecipientUpdateTemplateRecipientsInternalServerErrorIssue(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[
        List[RecipientUpdateTemplateRecipientsInternalServerErrorIssue]
    ] = None


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

    data: RecipientUpdateTemplateRecipientsInternalServerErrorData = field(hash=False)

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


class RecipientUpdateTemplateRecipientsForbiddenIssue(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateTemplateRecipientsForbiddenIssue]] = None


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

    data: RecipientUpdateTemplateRecipientsForbiddenErrorData = field(hash=False)

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


class RecipientUpdateTemplateRecipientsUnauthorizedIssue(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateTemplateRecipientsUnauthorizedIssue]] = None


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

    data: RecipientUpdateTemplateRecipientsUnauthorizedErrorData = field(hash=False)

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


class RecipientUpdateTemplateRecipientsBadRequestIssue(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateTemplateRecipientsBadRequestIssue]] = None


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

    data: RecipientUpdateTemplateRecipientsBadRequestErrorData = field(hash=False)

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


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


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


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


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


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


class RecipientUpdateTemplateRecipientsAuthOptionsTypedDict(TypedDict):
    access_auth: List[RecipientUpdateTemplateRecipientsAccessAuthResponse]
    action_auth: List[RecipientUpdateTemplateRecipientsActionAuthResponse]


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

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


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


class RecipientUpdateTemplateRecipientsValue3TypedDict(TypedDict):
    value: str


class RecipientUpdateTemplateRecipientsValue3(BaseModel):
    value: str


class RecipientUpdateTemplateRecipientsFieldMetaDropdownTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeDropdown
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateTemplateRecipientsValue3TypedDict]]
    default_value: NotRequired[str]


class RecipientUpdateTemplateRecipientsFieldMetaDropdown(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeDropdown

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

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


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


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


class RecipientUpdateTemplateRecipientsValue2(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientUpdateTemplateRecipientsFieldMetaCheckboxTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeCheckbox
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateTemplateRecipientsValue2TypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[RecipientUpdateTemplateRecipientsDirection2]


class RecipientUpdateTemplateRecipientsFieldMetaCheckbox(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeCheckbox

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

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

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

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


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


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


class RecipientUpdateTemplateRecipientsValue1(BaseModel):
    id: float

    checked: bool

    value: str


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


class RecipientUpdateTemplateRecipientsFieldMetaRadioTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeRadio
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[RecipientUpdateTemplateRecipientsValue1TypedDict]]
    direction: NotRequired[RecipientUpdateTemplateRecipientsDirection1]


class RecipientUpdateTemplateRecipientsFieldMetaRadio(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeRadio

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

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


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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaNumberTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeNumber
    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[RecipientUpdateTemplateRecipientsTextAlign6]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateTemplateRecipientsVerticalAlign2]
    ]


class RecipientUpdateTemplateRecipientsFieldMetaNumber(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeNumber

    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[RecipientUpdateTemplateRecipientsTextAlign6],
        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[RecipientUpdateTemplateRecipientsVerticalAlign2],
        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 RecipientUpdateTemplateRecipientsTypeText(str, Enum):
    TEXT = "text"


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


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


class RecipientUpdateTemplateRecipientsFieldMetaTextTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeText
    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[RecipientUpdateTemplateRecipientsTextAlign5]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[
        Nullable[RecipientUpdateTemplateRecipientsVerticalAlign1]
    ]


class RecipientUpdateTemplateRecipientsFieldMetaText(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeText

    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[RecipientUpdateTemplateRecipientsTextAlign5],
        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[RecipientUpdateTemplateRecipientsVerticalAlign1],
        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 RecipientUpdateTemplateRecipientsTypeDate(str, Enum):
    DATE = "date"


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


class RecipientUpdateTemplateRecipientsFieldMetaDateTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeDate
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateTemplateRecipientsTextAlign4]


class RecipientUpdateTemplateRecipientsFieldMetaDate(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeDate

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaEmailTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeEmail
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateTemplateRecipientsTextAlign3]


class RecipientUpdateTemplateRecipientsFieldMetaEmail(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeEmail

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaNameTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeName
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateTemplateRecipientsTextAlign2]


class RecipientUpdateTemplateRecipientsFieldMetaName(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeName

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaInitialsTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsTypeInitials
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[RecipientUpdateTemplateRecipientsTextAlign1]


class RecipientUpdateTemplateRecipientsFieldMetaInitials(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeInitials

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaSignature(BaseModel):
    type: RecipientUpdateTemplateRecipientsTypeSignature

    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


RecipientUpdateTemplateRecipientsFieldMetaUnionTypedDict = TypeAliasType(
    "RecipientUpdateTemplateRecipientsFieldMetaUnionTypedDict",
    Union[
        RecipientUpdateTemplateRecipientsFieldMetaSignatureTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaInitialsTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaNameTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaEmailTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaDateTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaRadioTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaDropdownTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaCheckboxTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaTextTypedDict,
        RecipientUpdateTemplateRecipientsFieldMetaNumberTypedDict,
    ],
)


RecipientUpdateTemplateRecipientsFieldMetaUnion = TypeAliasType(
    "RecipientUpdateTemplateRecipientsFieldMetaUnion",
    Union[
        RecipientUpdateTemplateRecipientsFieldMetaSignature,
        RecipientUpdateTemplateRecipientsFieldMetaInitials,
        RecipientUpdateTemplateRecipientsFieldMetaName,
        RecipientUpdateTemplateRecipientsFieldMetaEmail,
        RecipientUpdateTemplateRecipientsFieldMetaDate,
        RecipientUpdateTemplateRecipientsFieldMetaRadio,
        RecipientUpdateTemplateRecipientsFieldMetaDropdown,
        RecipientUpdateTemplateRecipientsFieldMetaCheckbox,
        RecipientUpdateTemplateRecipientsFieldMetaText,
        RecipientUpdateTemplateRecipientsFieldMetaNumber,
    ],
)


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


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

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

    type: RecipientUpdateTemplateRecipientsType

    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[RecipientUpdateTemplateRecipientsFieldMetaUnion],
        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 RecipientUpdateTemplateRecipientsRecipientResponseTypedDict(TypedDict):
    envelope_id: str
    role: RecipientUpdateTemplateRecipientsRoleResponse
    read_status: RecipientUpdateTemplateRecipientsReadStatus
    signing_status: RecipientUpdateTemplateRecipientsSigningStatus
    send_status: RecipientUpdateTemplateRecipientsSendStatus
    id: float
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientUpdateTemplateRecipientsAuthOptionsTypedDict]
    signing_order: Nullable[float]
    rejection_reason: Nullable[str]
    fields: List[RecipientUpdateTemplateRecipientsFieldTypedDict]
    document_id: NotRequired[Nullable[float]]
    template_id: NotRequired[Nullable[float]]


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

    role: RecipientUpdateTemplateRecipientsRoleResponse

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

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

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

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

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

    fields: List[RecipientUpdateTemplateRecipientsField]

    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


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

    recipients: List[RecipientUpdateTemplateRecipientsRecipientResponseTypedDict]


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

    recipients: List[RecipientUpdateTemplateRecipientsRecipientResponse]
