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


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

    ACCOUNT = "ACCOUNT"


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


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

    email: Optional[str] = None

    name: Optional[str] = None

    role: Optional[RecipientUpdateDocumentRecipientsRole] = None

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

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

    action_auth: Annotated[
        OptionalNullable[RecipientUpdateDocumentRecipientsActionAuth],
        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 RecipientUpdateDocumentRecipientsRequestBodyTypedDict(TypedDict):
    document_id: float
    recipients: List[RecipientUpdateDocumentRecipientsRecipientsTypedDict]


class RecipientUpdateDocumentRecipientsRequestBody(BaseModel):
    document_id: Annotated[float, pydantic.Field(alias="documentId")]

    recipients: List[RecipientUpdateDocumentRecipientsRecipients]


class RecipientUpdateDocumentRecipientsDocumentsRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsDocumentsRecipientsIssues(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsDocumentsRecipientsResponseResponseBodyData(
    BaseModel
):
    message: str

    code: str

    issues: Optional[
        List[RecipientUpdateDocumentRecipientsDocumentsRecipientsIssues]
    ] = None


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

    data: RecipientUpdateDocumentRecipientsDocumentsRecipientsResponseResponseBodyData

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

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


class RecipientUpdateDocumentRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientUpdateDocumentRecipientsIssues(BaseModel):
    message: str


class RecipientUpdateDocumentRecipientsDocumentsRecipientsResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientUpdateDocumentRecipientsIssues]] = None


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

    data: RecipientUpdateDocumentRecipientsDocumentsRecipientsResponseBodyData

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

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


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


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


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


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


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

    ACCOUNT = "ACCOUNT"


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


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

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


class RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponseValuesTypedDict(
    TypedDict
):
    value: str


class RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponseValues(
    BaseModel
):
    value: str


class RecipientUpdateDocumentRecipientsFieldMeta9TypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponseValuesTypedDict
        ]
    ]
    default_value: NotRequired[str]


class RecipientUpdateDocumentRecipientsFieldMeta9(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsFields9Type

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

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


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


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


class RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateDocumentRecipientsFieldMeta8TypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsValuesTypedDict
        ]
    ]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class RecipientUpdateDocumentRecipientsFieldMeta8(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsFieldsType

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

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

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


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


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


class RecipientUpdateDocumentRecipientsFieldMetaValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientUpdateDocumentRecipientsFieldMeta7TypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[RecipientUpdateDocumentRecipientsFieldMetaValuesTypedDict]]


class RecipientUpdateDocumentRecipientsFieldMeta7(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyRecipientsType

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


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


class RecipientUpdateDocumentRecipientsFieldMeta6TypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyType
    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 RecipientUpdateDocumentRecipientsFieldMeta6(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyType

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


class RecipientUpdateDocumentRecipientsFieldMeta5TypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONType
    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 RecipientUpdateDocumentRecipientsFieldMeta5(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200ApplicationJSONType

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


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


class RecipientUpdateDocumentRecipientsFieldMeta4(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponse200Type

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


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


class RecipientUpdateDocumentRecipientsFieldMeta3(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsResponseType

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


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


class RecipientUpdateDocumentRecipientsFieldMeta2(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaDocumentsRecipientsType

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


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


class RecipientUpdateDocumentRecipientsFieldMeta1(BaseModel):
    type: RecipientUpdateDocumentRecipientsFieldMetaType

    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


RecipientUpdateDocumentRecipientsFieldMetaTypedDict = TypeAliasType(
    "RecipientUpdateDocumentRecipientsFieldMetaTypedDict",
    Union[
        RecipientUpdateDocumentRecipientsFieldMeta1TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta2TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta3TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta4TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta7TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta9TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta5TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta8TypedDict,
        RecipientUpdateDocumentRecipientsFieldMeta6TypedDict,
    ],
)


RecipientUpdateDocumentRecipientsFieldMeta = TypeAliasType(
    "RecipientUpdateDocumentRecipientsFieldMeta",
    Union[
        RecipientUpdateDocumentRecipientsFieldMeta1,
        RecipientUpdateDocumentRecipientsFieldMeta2,
        RecipientUpdateDocumentRecipientsFieldMeta3,
        RecipientUpdateDocumentRecipientsFieldMeta4,
        RecipientUpdateDocumentRecipientsFieldMeta7,
        RecipientUpdateDocumentRecipientsFieldMeta9,
        RecipientUpdateDocumentRecipientsFieldMeta5,
        RecipientUpdateDocumentRecipientsFieldMeta8,
        RecipientUpdateDocumentRecipientsFieldMeta6,
    ],
)


class RecipientUpdateDocumentRecipientsFieldsTypedDict(TypedDict):
    type: RecipientUpdateDocumentRecipientsType
    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[RecipientUpdateDocumentRecipientsFieldMetaTypedDict]
    position_x: NotRequired[Any]
    position_y: NotRequired[Any]
    width: NotRequired[Any]
    height: NotRequired[Any]


class RecipientUpdateDocumentRecipientsFields(BaseModel):
    type: RecipientUpdateDocumentRecipientsType

    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[RecipientUpdateDocumentRecipientsFieldMeta],
        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 RecipientUpdateDocumentRecipientsDocumentsRecipientsRecipientsTypedDict(
    TypedDict
):
    role: RecipientUpdateDocumentRecipientsDocumentsRecipientsRole
    read_status: RecipientUpdateDocumentRecipientsReadStatus
    signing_status: RecipientUpdateDocumentRecipientsSigningStatus
    send_status: RecipientUpdateDocumentRecipientsSendStatus
    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[RecipientUpdateDocumentRecipientsAuthOptionsTypedDict]
    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[RecipientUpdateDocumentRecipientsFieldsTypedDict]


class RecipientUpdateDocumentRecipientsDocumentsRecipientsRecipients(BaseModel):
    role: RecipientUpdateDocumentRecipientsDocumentsRecipientsRole

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

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

    send_status: Annotated[
        RecipientUpdateDocumentRecipientsSendStatus, 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[RecipientUpdateDocumentRecipientsAuthOptions],
        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[RecipientUpdateDocumentRecipientsFields]

    @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 RecipientUpdateDocumentRecipientsResponseBodyTypedDict(TypedDict):
    r"""Successful response"""

    recipients: List[
        RecipientUpdateDocumentRecipientsDocumentsRecipientsRecipientsTypedDict
    ]


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

    recipients: List[RecipientUpdateDocumentRecipientsDocumentsRecipientsRecipients]
