"""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, UNSET_SENTINEL
from documenso_sdk.utils import FieldMetadata, PathParamMetadata
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 RecipientGetDocumentRecipientRequestTypedDict(TypedDict):
    recipient_id: float


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


class RecipientGetDocumentRecipientDocumentsRecipientsResponseIssuesTypedDict(
    TypedDict
):
    message: str


class RecipientGetDocumentRecipientDocumentsRecipientsResponseIssues(BaseModel):
    message: str


class RecipientGetDocumentRecipientDocumentsRecipientsResponse500ResponseBodyData(
    BaseModel
):
    message: str

    code: str

    issues: Optional[
        List[RecipientGetDocumentRecipientDocumentsRecipientsResponseIssues]
    ] = None


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

    data: RecipientGetDocumentRecipientDocumentsRecipientsResponse500ResponseBodyData

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

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


class RecipientGetDocumentRecipientDocumentsRecipientsIssuesTypedDict(TypedDict):
    message: str


class RecipientGetDocumentRecipientDocumentsRecipientsIssues(BaseModel):
    message: str


class RecipientGetDocumentRecipientDocumentsRecipientsResponseResponseBodyData(
    BaseModel
):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientDocumentsRecipientsIssues]] = (
        None
    )


class RecipientGetDocumentRecipientDocumentsRecipientsResponseResponseBody(Exception):
    r"""Not found"""

    data: RecipientGetDocumentRecipientDocumentsRecipientsResponseResponseBodyData

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

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


class RecipientGetDocumentRecipientIssuesTypedDict(TypedDict):
    message: str


class RecipientGetDocumentRecipientIssues(BaseModel):
    message: str


class RecipientGetDocumentRecipientDocumentsRecipientsResponseBodyData(BaseModel):
    message: str

    code: str

    issues: Optional[List[RecipientGetDocumentRecipientIssues]] = None


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

    data: RecipientGetDocumentRecipientDocumentsRecipientsResponseBodyData

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

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


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


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


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


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


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

    ACCOUNT = "ACCOUNT"


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


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

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


class RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponseValuesTypedDict(
    TypedDict
):
    value: str


class RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponseValues(
    BaseModel
):
    value: str


class RecipientGetDocumentRecipientFieldMeta9TypedDict(TypedDict):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFields9Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[
            RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponseValuesTypedDict
        ]
    ]
    default_value: NotRequired[str]


class RecipientGetDocumentRecipientFieldMeta9(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFields9Type

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

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


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


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


class RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientGetDocumentRecipientFieldMeta8TypedDict(TypedDict):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFields8Type
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[
        List[RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsValuesTypedDict]
    ]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]


class RecipientGetDocumentRecipientFieldMeta8(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFields8Type

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

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

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


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


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


class RecipientGetDocumentRecipientFieldMetaValues(BaseModel):
    id: float

    checked: bool

    value: str


class RecipientGetDocumentRecipientFieldMeta7TypedDict(TypedDict):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFieldsType
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    values: NotRequired[List[RecipientGetDocumentRecipientFieldMetaValuesTypedDict]]


class RecipientGetDocumentRecipientFieldMeta7(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyFieldsType

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


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


class RecipientGetDocumentRecipientFieldMeta6TypedDict(TypedDict):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyType
    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 RecipientGetDocumentRecipientFieldMeta6(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONResponseBodyType

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


class RecipientGetDocumentRecipientFieldMeta5TypedDict(TypedDict):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONType
    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 RecipientGetDocumentRecipientFieldMeta5(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200ApplicationJSONType

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


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


class RecipientGetDocumentRecipientFieldMeta4(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponse200Type

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


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


class RecipientGetDocumentRecipientFieldMeta3(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsResponseType

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


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


class RecipientGetDocumentRecipientFieldMeta2(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaDocumentsRecipientsType

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


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


class RecipientGetDocumentRecipientFieldMeta1(BaseModel):
    type: RecipientGetDocumentRecipientFieldMetaType

    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


RecipientGetDocumentRecipientFieldMetaTypedDict = TypeAliasType(
    "RecipientGetDocumentRecipientFieldMetaTypedDict",
    Union[
        RecipientGetDocumentRecipientFieldMeta1TypedDict,
        RecipientGetDocumentRecipientFieldMeta2TypedDict,
        RecipientGetDocumentRecipientFieldMeta3TypedDict,
        RecipientGetDocumentRecipientFieldMeta4TypedDict,
        RecipientGetDocumentRecipientFieldMeta7TypedDict,
        RecipientGetDocumentRecipientFieldMeta9TypedDict,
        RecipientGetDocumentRecipientFieldMeta5TypedDict,
        RecipientGetDocumentRecipientFieldMeta8TypedDict,
        RecipientGetDocumentRecipientFieldMeta6TypedDict,
    ],
)


RecipientGetDocumentRecipientFieldMeta = TypeAliasType(
    "RecipientGetDocumentRecipientFieldMeta",
    Union[
        RecipientGetDocumentRecipientFieldMeta1,
        RecipientGetDocumentRecipientFieldMeta2,
        RecipientGetDocumentRecipientFieldMeta3,
        RecipientGetDocumentRecipientFieldMeta4,
        RecipientGetDocumentRecipientFieldMeta7,
        RecipientGetDocumentRecipientFieldMeta9,
        RecipientGetDocumentRecipientFieldMeta5,
        RecipientGetDocumentRecipientFieldMeta8,
        RecipientGetDocumentRecipientFieldMeta6,
    ],
)


class RecipientGetDocumentRecipientFieldsTypedDict(TypedDict):
    type: RecipientGetDocumentRecipientType
    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[RecipientGetDocumentRecipientFieldMetaTypedDict]
    position_x: NotRequired[Any]
    position_y: NotRequired[Any]
    width: NotRequired[Any]
    height: NotRequired[Any]


class RecipientGetDocumentRecipientFields(BaseModel):
    type: RecipientGetDocumentRecipientType

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

    role: RecipientGetDocumentRecipientRole
    read_status: ReadStatus
    signing_status: SigningStatus
    send_status: SendStatus
    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[RecipientGetDocumentRecipientAuthOptionsTypedDict]
    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[RecipientGetDocumentRecipientFieldsTypedDict]


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

    role: RecipientGetDocumentRecipientRole

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

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

    send_status: Annotated[SendStatus, 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[RecipientGetDocumentRecipientAuthOptions],
        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[RecipientGetDocumentRecipientFields]

    @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
