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


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

    ACCOUNT = "ACCOUNT"


class RecipientUpdateTemplateRecipientsActionAuth(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 RecipientUpdateTemplateRecipientsRecipientsTypedDict(TypedDict):
    id: float
    r"""The ID of the recipient to update."""
    email: NotRequired[str]
    name: NotRequired[str]
    role: NotRequired[RecipientUpdateTemplateRecipientsRole]
    signing_order: NotRequired[float]
    access_auth: NotRequired[Nullable[RecipientUpdateTemplateRecipientsAccessAuth]]
    r"""The type of authentication required for the recipient to access the document."""
    action_auth: NotRequired[Nullable[RecipientUpdateTemplateRecipientsActionAuth]]
    r"""The type of authentication required for the recipient to sign the document."""


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

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateTemplateRecipientsRole] = None

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

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

    action_auth: Annotated[
        OptionalNullable[RecipientUpdateTemplateRecipientsActionAuth],
        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 RecipientUpdateTemplateRecipientsRequestBodyTypedDict(TypedDict):
    template_id: float
    recipients: List[RecipientUpdateTemplateRecipientsRecipientsTypedDict]


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

    recipients: List[RecipientUpdateTemplateRecipientsRecipients]


class RecipientUpdateTemplateRecipientsTemplatesRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateTemplateRecipientsTemplatesRecipientsIssues(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsTemplatesRecipientsResponseResponseBodyData(
    BaseModel
):
    message: str

    code: str

    issues: Optional[
        List[RecipientUpdateTemplateRecipientsTemplatesRecipientsIssues]
    ] = None


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

    data: RecipientUpdateTemplateRecipientsTemplatesRecipientsResponseResponseBodyData

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

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


class RecipientUpdateTemplateRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateTemplateRecipientsIssues(BaseModel):
    message: str


class RecipientUpdateTemplateRecipientsTemplatesRecipientsResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateTemplateRecipientsIssues]] = None


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

    data: RecipientUpdateTemplateRecipientsTemplatesRecipientsResponseBodyData

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

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


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


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 RecipientUpdateTemplateRecipientsTemplatesRecipientsAccessAuth(str, Enum):
    r"""The type of authentication required for the recipient to access the document."""

    ACCOUNT = "ACCOUNT"


class RecipientUpdateTemplateRecipientsTemplatesRecipientsActionAuth(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 RecipientUpdateTemplateRecipientsAuthOptionsTypedDict(TypedDict):
    access_auth: Nullable[
        RecipientUpdateTemplateRecipientsTemplatesRecipientsAccessAuth
    ]
    r"""The type of authentication required for the recipient to access the document."""
    action_auth: Nullable[
        RecipientUpdateTemplateRecipientsTemplatesRecipientsActionAuth
    ]
    r"""The type of authentication required for the recipient to sign the document."""


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

    action_auth: Annotated[
        Nullable[RecipientUpdateTemplateRecipientsTemplatesRecipientsActionAuth],
        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 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 RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsFields9Type(
    str, Enum
):
    DROPDOWN = "dropdown"


class RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponseValuesTypedDict(
    TypedDict
):
    value: str


class RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponseValues(
    BaseModel
):
    value: str


class RecipientUpdateTemplateRecipientsFieldMeta9TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponseValuesTypedDict
        ]
    ]
    default_value: NotRequired[str]


class RecipientUpdateTemplateRecipientsFieldMeta9(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsFields9Type

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

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateTemplateRecipientsFieldMeta8TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsValuesTypedDict
        ]
    ]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class RecipientUpdateTemplateRecipientsFieldMeta8(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsFieldsType

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

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

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


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


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


class RecipientUpdateTemplateRecipientsFieldMetaValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateTemplateRecipientsFieldMeta7TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[RecipientUpdateTemplateRecipientsFieldMetaValuesTypedDict]]


class RecipientUpdateTemplateRecipientsFieldMeta7(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyRecipientsType

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


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


class RecipientUpdateTemplateRecipientsFieldMeta6TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyType
    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 RecipientUpdateTemplateRecipientsFieldMeta6(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONResponseBodyType

    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 RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONType(
    str, Enum
):
    TEXT = "text"


class RecipientUpdateTemplateRecipientsFieldMeta5TypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONType
    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 RecipientUpdateTemplateRecipientsFieldMeta5(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200ApplicationJSONType

    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 RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200Type(
    str, Enum
):
    DATE = "date"


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


class RecipientUpdateTemplateRecipientsFieldMeta4(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponse200Type

    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 RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponseType(
    str, Enum
):
    EMAIL = "email"


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


class RecipientUpdateTemplateRecipientsFieldMeta3(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsResponseType

    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 RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsType(str, Enum):
    NAME = "name"


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


class RecipientUpdateTemplateRecipientsFieldMeta2(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaTemplatesRecipientsType

    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 RecipientUpdateTemplateRecipientsFieldMetaType(str, Enum):
    INITIALS = "initials"


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


class RecipientUpdateTemplateRecipientsFieldMeta1(BaseModel):
    type: RecipientUpdateTemplateRecipientsFieldMetaType

    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


RecipientUpdateTemplateRecipientsFieldMetaTypedDict = TypeAliasType(
    "RecipientUpdateTemplateRecipientsFieldMetaTypedDict",
    Union[
        RecipientUpdateTemplateRecipientsFieldMeta1TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta2TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta3TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta4TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta7TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta9TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta5TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta8TypedDict,
        RecipientUpdateTemplateRecipientsFieldMeta6TypedDict,
    ],
)


RecipientUpdateTemplateRecipientsFieldMeta = TypeAliasType(
    "RecipientUpdateTemplateRecipientsFieldMeta",
    Union[
        RecipientUpdateTemplateRecipientsFieldMeta1,
        RecipientUpdateTemplateRecipientsFieldMeta2,
        RecipientUpdateTemplateRecipientsFieldMeta3,
        RecipientUpdateTemplateRecipientsFieldMeta4,
        RecipientUpdateTemplateRecipientsFieldMeta7,
        RecipientUpdateTemplateRecipientsFieldMeta9,
        RecipientUpdateTemplateRecipientsFieldMeta5,
        RecipientUpdateTemplateRecipientsFieldMeta8,
        RecipientUpdateTemplateRecipientsFieldMeta6,
    ],
)


class RecipientUpdateTemplateRecipientsFieldsTypedDict(TypedDict):
    type: RecipientUpdateTemplateRecipientsType
    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[RecipientUpdateTemplateRecipientsFieldMetaTypedDict]
    position_x: NotRequired[Any]
    position_y: NotRequired[Any]
    width: NotRequired[Any]
    height: NotRequired[Any]


class RecipientUpdateTemplateRecipientsFields(BaseModel):
    type: RecipientUpdateTemplateRecipientsType

    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[RecipientUpdateTemplateRecipientsFieldMeta],
        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 RecipientUpdateTemplateRecipientsTemplatesRecipientsRecipientsTypedDict(
    TypedDict
):
    role: RecipientUpdateTemplateRecipientsTemplatesRecipientsRole
    read_status: RecipientUpdateTemplateRecipientsReadStatus
    signing_status: RecipientUpdateTemplateRecipientsSigningStatus
    send_status: RecipientUpdateTemplateRecipientsSendStatus
    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[RecipientUpdateTemplateRecipientsAuthOptionsTypedDict]
    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[RecipientUpdateTemplateRecipientsFieldsTypedDict]


class RecipientUpdateTemplateRecipientsTemplatesRecipientsRecipients(BaseModel):
    role: RecipientUpdateTemplateRecipientsTemplatesRecipientsRole

    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: 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[RecipientUpdateTemplateRecipientsAuthOptions],
        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[RecipientUpdateTemplateRecipientsFields]

    @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


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

    recipients: List[
        RecipientUpdateTemplateRecipientsTemplatesRecipientsRecipientsTypedDict
    ]


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

    recipients: List[RecipientUpdateTemplateRecipientsTemplatesRecipientsRecipients]
