"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from documenso_sdk import utils
from documenso_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from enum import Enum
import pydantic
from pydantic import model_serializer
from typing import Any, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class RecipientUpdateTemplateRecipientRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"


class RecipientUpdateTemplateRecipientAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class RecipientUpdateTemplateRecipientActionAuth(str, Enum):
    r"""The type of authentication required for the recipient to sign the document."""

    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class RecipientUpdateTemplateRecipientRecipientTypedDict(TypedDict):
    id: float
    r"""The ID of the recipient to update."""
    email: NotRequired[str]
    name: NotRequired[str]
    role: NotRequired[RecipientUpdateTemplateRecipientRole]
    signing_order: NotRequired[float]
    access_auth: NotRequired[Nullable[RecipientUpdateTemplateRecipientAccessAuth]]
    r"""The type of authentication required for the recipient to access the document."""
    action_auth: NotRequired[Nullable[RecipientUpdateTemplateRecipientActionAuth]]
    r"""The type of authentication required for the recipient to sign the document."""


class RecipientUpdateTemplateRecipientRecipient(BaseModel):
    id: float
    r"""The ID of the recipient to update."""

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateTemplateRecipientRole] = None

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

    access_auth: Annotated[
        OptionalNullable[RecipientUpdateTemplateRecipientAccessAuth],
        pydantic.Field(alias="accessAuth"),
    ] = UNSET
    r"""The type of authentication required for the recipient to access the document."""

    action_auth: Annotated[
        OptionalNullable[RecipientUpdateTemplateRecipientActionAuth],
        pydantic.Field(alias="actionAuth"),
    ] = UNSET
    r"""The type of authentication required for the recipient to sign the document."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "email",
            "name",
            "role",
            "signingOrder",
            "accessAuth",
            "actionAuth",
        ]
        nullable_fields = ["accessAuth", "actionAuth"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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 RecipientUpdateTemplateRecipientRequestBodyTypedDict(TypedDict):
    template_id: float
    recipient: RecipientUpdateTemplateRecipientRecipientTypedDict


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

    recipient: RecipientUpdateTemplateRecipientRecipient


class RecipientUpdateTemplateRecipientTemplatesRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateTemplateRecipientTemplatesRecipientsIssues(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientTemplatesRecipientsResponseResponseBodyData(
    BaseModel
):
    message: str

    code: str

    issues: Optional[
        List[RecipientUpdateTemplateRecipientTemplatesRecipientsIssues]
    ] = None


class RecipientUpdateTemplateRecipientTemplatesRecipientsResponseResponseBody(
    Exception
):
    r"""Internal server error"""

    data: RecipientUpdateTemplateRecipientTemplatesRecipientsResponseResponseBodyData

    def __init__(
        self,
        data: RecipientUpdateTemplateRecipientTemplatesRecipientsResponseResponseBodyData,
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data,
            RecipientUpdateTemplateRecipientTemplatesRecipientsResponseResponseBodyData,
        )


class RecipientUpdateTemplateRecipientIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateTemplateRecipientIssues(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientTemplatesRecipientsResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateTemplateRecipientIssues]] = None


class RecipientUpdateTemplateRecipientTemplatesRecipientsResponseBody(Exception):
    r"""Invalid input data"""

    data: RecipientUpdateTemplateRecipientTemplatesRecipientsResponseBodyData

    def __init__(
        self, data: RecipientUpdateTemplateRecipientTemplatesRecipientsResponseBodyData
    ):
        self.data = data

    def __str__(self) -> str:
        return utils.marshal_json(
            self.data,
            RecipientUpdateTemplateRecipientTemplatesRecipientsResponseBodyData,
        )


class RecipientUpdateTemplateRecipientTemplatesRecipientsRole(str, Enum):
    CC = "CC"
    SIGNER = "SIGNER"
    VIEWER = "VIEWER"
    APPROVER = "APPROVER"


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


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


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


class RecipientUpdateTemplateRecipientTemplatesRecipientsAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class RecipientUpdateTemplateRecipientTemplatesRecipientsActionAuth(str, Enum):
    r"""The type of authentication required for the recipient to sign the document."""

    ACCOUNT = "ACCOUNT"
    PASSKEY = "PASSKEY"
    TWO_FACTOR_AUTH = "TWO_FACTOR_AUTH"
    EXPLICIT_NONE = "EXPLICIT_NONE"


class RecipientUpdateTemplateRecipientAuthOptionsTypedDict(TypedDict):
    access_auth: Nullable[RecipientUpdateTemplateRecipientTemplatesRecipientsAccessAuth]
    r"""The type of authentication required for the recipient to access the document."""
    action_auth: Nullable[RecipientUpdateTemplateRecipientTemplatesRecipientsActionAuth]
    r"""The type of authentication required for the recipient to sign the document."""


class RecipientUpdateTemplateRecipientAuthOptions(BaseModel):
    access_auth: Annotated[
        Nullable[RecipientUpdateTemplateRecipientTemplatesRecipientsAccessAuth],
        pydantic.Field(alias="accessAuth"),
    ]
    r"""The type of authentication required for the recipient to access the document."""

    action_auth: Annotated[
        Nullable[RecipientUpdateTemplateRecipientTemplatesRecipientsActionAuth],
        pydantic.Field(alias="actionAuth"),
    ]
    r"""The type of authentication required for the recipient to sign the document."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["accessAuth", "actionAuth"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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 RecipientUpdateTemplateRecipientType(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 RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFields9Type(
    str, Enum
):
    DROPDOWN = "dropdown"


class RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponseValuesTypedDict(
    TypedDict
):
    value: str


class RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponseValues(
    BaseModel
):
    value: str


class RecipientUpdateTemplateRecipientFieldMeta9TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponseValuesTypedDict
        ]
    ]
    default_value: NotRequired[str]


class RecipientUpdateTemplateRecipientFieldMeta9(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFields9Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    values: Optional[
        List[RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponseValues]
    ] = None

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


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


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


class RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateTemplateRecipientFieldMeta8TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFields8Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsValuesTypedDict
        ]
    ]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class RecipientUpdateTemplateRecipientFieldMeta8(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFields8Type

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    values: Optional[
        List[RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsValues]
    ] = None

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

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


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


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


class RecipientUpdateTemplateRecipientFieldMetaValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateTemplateRecipientFieldMeta7TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[RecipientUpdateTemplateRecipientFieldMetaValuesTypedDict]]


class RecipientUpdateTemplateRecipientFieldMeta7(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyFieldsType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    values: Optional[List[RecipientUpdateTemplateRecipientFieldMetaValues]] = None


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


class RecipientUpdateTemplateRecipientFieldMeta6TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    number_format: NotRequired[str]
    value: NotRequired[str]
    min_value: NotRequired[float]
    max_value: NotRequired[float]
    font_size: NotRequired[float]


class RecipientUpdateTemplateRecipientFieldMeta6(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

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

    value: Optional[str] = None

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

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

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


class RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONType(
    str, Enum
):
    TEXT = "text"


class RecipientUpdateTemplateRecipientFieldMeta5TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    font_size: NotRequired[float]


class RecipientUpdateTemplateRecipientFieldMeta5(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200ApplicationJSONType

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

    read_only: Annotated[Optional[bool], pydantic.Field(alias="readOnly")] = None

    text: Optional[str] = None

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

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


class RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200Type(
    str, Enum
):
    DATE = "date"


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


class RecipientUpdateTemplateRecipientFieldMeta4(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponse200Type

    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")] = None


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


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


class RecipientUpdateTemplateRecipientFieldMeta3(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsResponseType

    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")] = None


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


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


class RecipientUpdateTemplateRecipientFieldMeta2(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaTemplatesRecipientsType

    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")] = None


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


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


class RecipientUpdateTemplateRecipientFieldMeta1(BaseModel):
    type: RecipientUpdateTemplateRecipientFieldMetaType

    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")] = None


RecipientUpdateTemplateRecipientFieldMetaTypedDict = TypeAliasType(
    "RecipientUpdateTemplateRecipientFieldMetaTypedDict",
    Union[
        RecipientUpdateTemplateRecipientFieldMeta1TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta2TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta3TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta4TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta7TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta9TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta5TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta8TypedDict,
        RecipientUpdateTemplateRecipientFieldMeta6TypedDict,
    ],
)


RecipientUpdateTemplateRecipientFieldMeta = TypeAliasType(
    "RecipientUpdateTemplateRecipientFieldMeta",
    Union[
        RecipientUpdateTemplateRecipientFieldMeta1,
        RecipientUpdateTemplateRecipientFieldMeta2,
        RecipientUpdateTemplateRecipientFieldMeta3,
        RecipientUpdateTemplateRecipientFieldMeta4,
        RecipientUpdateTemplateRecipientFieldMeta7,
        RecipientUpdateTemplateRecipientFieldMeta9,
        RecipientUpdateTemplateRecipientFieldMeta5,
        RecipientUpdateTemplateRecipientFieldMeta8,
        RecipientUpdateTemplateRecipientFieldMeta6,
    ],
)


class RecipientUpdateTemplateRecipientFieldsTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientType
    id: int
    secondary_id: str
    document_id: Nullable[int]
    template_id: Nullable[int]
    recipient_id: int
    page: float
    r"""The page number of the field on the document. Starts from 1."""
    custom_text: str
    inserted: bool
    field_meta: Nullable[RecipientUpdateTemplateRecipientFieldMetaTypedDict]
    position_x: NotRequired[Any]
    position_y: NotRequired[Any]
    width: NotRequired[Any]
    height: NotRequired[Any]


class RecipientUpdateTemplateRecipientFields(BaseModel):
    type: RecipientUpdateTemplateRecipientType

    id: int

    secondary_id: Annotated[str, pydantic.Field(alias="secondaryId")]

    document_id: Annotated[Nullable[int], pydantic.Field(alias="documentId")]

    template_id: Annotated[Nullable[int], pydantic.Field(alias="templateId")]

    recipient_id: Annotated[int, pydantic.Field(alias="recipientId")]

    page: float
    r"""The page number of the field on the document. Starts from 1."""

    custom_text: Annotated[str, pydantic.Field(alias="customText")]

    inserted: bool

    field_meta: Annotated[
        Nullable[RecipientUpdateTemplateRecipientFieldMeta],
        pydantic.Field(alias="fieldMeta"),
    ]

    position_x: Annotated[Optional[Any], pydantic.Field(alias="positionX")] = None

    position_y: Annotated[Optional[Any], pydantic.Field(alias="positionY")] = None

    width: Optional[Any] = None

    height: Optional[Any] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = ["positionX", "positionY", "width", "height"]
        nullable_fields = ["documentId", "templateId", "fieldMeta"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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 RecipientUpdateTemplateRecipientResponseBodyTypedDict(TypedDict):
    r"""Successful response"""

    role: RecipientUpdateTemplateRecipientTemplatesRecipientsRole
    read_status: RecipientUpdateTemplateRecipientReadStatus
    signing_status: RecipientUpdateTemplateRecipientSigningStatus
    send_status: RecipientUpdateTemplateRecipientSendStatus
    id: int
    document_id: Nullable[int]
    template_id: Nullable[int]
    email: str
    name: str
    token: str
    document_deleted_at: Nullable[str]
    expired: Nullable[str]
    signed_at: Nullable[str]
    auth_options: Nullable[RecipientUpdateTemplateRecipientAuthOptionsTypedDict]
    signing_order: Nullable[float]
    r"""The order in which the recipient should sign the document. Only works if the document is set to sequential signing."""
    rejection_reason: Nullable[str]
    fields: List[RecipientUpdateTemplateRecipientFieldsTypedDict]


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

    role: RecipientUpdateTemplateRecipientTemplatesRecipientsRole

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

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

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

    id: int

    document_id: Annotated[Nullable[int], pydantic.Field(alias="documentId")]

    template_id: Annotated[Nullable[int], pydantic.Field(alias="templateId")]

    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[RecipientUpdateTemplateRecipientAuthOptions],
        pydantic.Field(alias="authOptions"),
    ]

    signing_order: Annotated[Nullable[float], pydantic.Field(alias="signingOrder")]
    r"""The order in which the recipient should sign the document. Only works if the document is set to sequential signing."""

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

    fields: List[RecipientUpdateTemplateRecipientFields]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = [
            "documentId",
            "templateId",
            "documentDeletedAt",
            "expired",
            "signedAt",
            "authOptions",
            "signingOrder",
            "rejectionReason",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in 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
