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

from __future__ import annotations
from dataclasses import dataclass, field
from documenso_sdk.models import DocumensoError
from documenso_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from documenso_sdk.utils import FieldMetadata, MultipartFormMetadata
from enum import Enum
import httpx
import io
import pydantic
from pydantic import model_serializer
from typing import Dict, IO, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


class DocumentCreateVisibility(str, Enum):
    EVERYONE = "EVERYONE"
    MANAGER_AND_ABOVE = "MANAGER_AND_ABOVE"
    ADMIN = "ADMIN"


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


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


DocumentCreateFormValuesTypedDict = TypeAliasType(
    "DocumentCreateFormValuesTypedDict", Union[str, bool, float]
)


DocumentCreateFormValues = TypeAliasType(
    "DocumentCreateFormValues", Union[str, bool, float]
)


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


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


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


class DocumentCreateTypeDropdown1(str, Enum):
    DROPDOWN = "DROPDOWN"


class DocumentCreateTypeDropdown2(str, Enum):
    DROPDOWN = "dropdown"


class DocumentCreateValueDropdownTypedDict(TypedDict):
    value: str


class DocumentCreateValueDropdown(BaseModel):
    value: str


class DocumentCreateFieldMetaDropdownTypedDict(TypedDict):
    type: DocumentCreateTypeDropdown2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentCreateValueDropdownTypedDict]]
    default_value: NotRequired[str]


class DocumentCreateFieldMetaDropdown(BaseModel):
    type: DocumentCreateTypeDropdown2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[DocumentCreateValueDropdown]] = None

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


class DocumentCreateFieldDropdownTypedDict(TypedDict):
    type: DocumentCreateTypeDropdown1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaDropdownTypedDict]


class DocumentCreateFieldDropdown(BaseModel):
    type: DocumentCreateTypeDropdown1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaDropdown], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeCheckbox1(str, Enum):
    CHECKBOX = "CHECKBOX"


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


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


class DocumentCreateValueCheckbox(BaseModel):
    id: float

    checked: bool

    value: str


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


class DocumentCreateFieldMetaCheckboxTypedDict(TypedDict):
    type: DocumentCreateTypeCheckbox2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentCreateValueCheckboxTypedDict]]
    validation_rule: NotRequired[str]
    validation_length: NotRequired[float]
    direction: NotRequired[DocumentCreateDirectionCheckbox]


class DocumentCreateFieldMetaCheckbox(BaseModel):
    type: DocumentCreateTypeCheckbox2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[DocumentCreateValueCheckbox]] = None

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

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

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


class DocumentCreateFieldCheckboxTypedDict(TypedDict):
    type: DocumentCreateTypeCheckbox1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaCheckboxTypedDict]


class DocumentCreateFieldCheckbox(BaseModel):
    type: DocumentCreateTypeCheckbox1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaCheckbox], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeRadio1(str, Enum):
    RADIO = "RADIO"


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


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


class DocumentCreateValueRadio(BaseModel):
    id: float

    checked: bool

    value: str


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


class DocumentCreateFieldMetaRadioTypedDict(TypedDict):
    type: DocumentCreateTypeRadio2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    values: NotRequired[List[DocumentCreateValueRadioTypedDict]]
    direction: NotRequired[DocumentCreateDirectionRadio]


class DocumentCreateFieldMetaRadio(BaseModel):
    type: DocumentCreateTypeRadio2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    values: Optional[List[DocumentCreateValueRadio]] = None

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


class DocumentCreateFieldRadioTypedDict(TypedDict):
    type: DocumentCreateTypeRadio1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaRadioTypedDict]


class DocumentCreateFieldRadio(BaseModel):
    type: DocumentCreateTypeRadio1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaRadio], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeNumber1(str, Enum):
    NUMBER = "NUMBER"


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


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


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


class DocumentCreateFieldMetaNumberTypedDict(TypedDict):
    type: DocumentCreateTypeNumber2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    number_format: NotRequired[Nullable[str]]
    value: NotRequired[str]
    min_value: NotRequired[Nullable[float]]
    max_value: NotRequired[Nullable[float]]
    text_align: NotRequired[DocumentCreateTextAlignNumber]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[DocumentCreateVerticalAlignNumber]]


class DocumentCreateFieldMetaNumber(BaseModel):
    type: DocumentCreateTypeNumber2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

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

    value: Optional[str] = None

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

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignNumber], pydantic.Field(alias="textAlign")
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[DocumentCreateVerticalAlignNumber],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "numberFormat",
            "value",
            "minValue",
            "maxValue",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = [
            "numberFormat",
            "minValue",
            "maxValue",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class DocumentCreateFieldNumberTypedDict(TypedDict):
    type: DocumentCreateTypeNumber1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaNumberTypedDict]


class DocumentCreateFieldNumber(BaseModel):
    type: DocumentCreateTypeNumber1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaNumber], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeText1(str, Enum):
    TEXT = "TEXT"


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


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


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


class DocumentCreateFieldMetaTextTypedDict(TypedDict):
    type: DocumentCreateTypeText2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text: NotRequired[str]
    character_limit: NotRequired[float]
    text_align: NotRequired[DocumentCreateTextAlignText]
    line_height: NotRequired[Nullable[float]]
    letter_spacing: NotRequired[Nullable[float]]
    vertical_align: NotRequired[Nullable[DocumentCreateVerticalAlignText]]


class DocumentCreateFieldMetaText(BaseModel):
    type: DocumentCreateTypeText2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text: Optional[str] = None

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignText], pydantic.Field(alias="textAlign")
    ] = None

    line_height: Annotated[
        OptionalNullable[float], pydantic.Field(alias="lineHeight")
    ] = UNSET

    letter_spacing: Annotated[
        OptionalNullable[float], pydantic.Field(alias="letterSpacing")
    ] = UNSET

    vertical_align: Annotated[
        OptionalNullable[DocumentCreateVerticalAlignText],
        pydantic.Field(alias="verticalAlign"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "label",
            "placeholder",
            "required",
            "readOnly",
            "fontSize",
            "text",
            "characterLimit",
            "textAlign",
            "lineHeight",
            "letterSpacing",
            "verticalAlign",
        ]
        nullable_fields = ["lineHeight", "letterSpacing", "verticalAlign"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class DocumentCreateFieldTextTypedDict(TypedDict):
    type: DocumentCreateTypeText1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaTextTypedDict]


class DocumentCreateFieldText(BaseModel):
    type: DocumentCreateTypeText1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaText], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeDate1(str, Enum):
    DATE = "DATE"


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


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


class DocumentCreateFieldMetaDateTypedDict(TypedDict):
    type: DocumentCreateTypeDate2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentCreateTextAlignDate]


class DocumentCreateFieldMetaDate(BaseModel):
    type: DocumentCreateTypeDate2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignDate], pydantic.Field(alias="textAlign")
    ] = None


class DocumentCreateFieldDateTypedDict(TypedDict):
    type: DocumentCreateTypeDate1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaDateTypedDict]


class DocumentCreateFieldDate(BaseModel):
    type: DocumentCreateTypeDate1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaDate], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeEmail1(str, Enum):
    EMAIL = "EMAIL"


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


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


class DocumentCreateFieldMetaEmailTypedDict(TypedDict):
    type: DocumentCreateTypeEmail2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentCreateTextAlignEmail]


class DocumentCreateFieldMetaEmail(BaseModel):
    type: DocumentCreateTypeEmail2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignEmail], pydantic.Field(alias="textAlign")
    ] = None


class DocumentCreateFieldEmailTypedDict(TypedDict):
    type: DocumentCreateTypeEmail1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaEmailTypedDict]


class DocumentCreateFieldEmail(BaseModel):
    type: DocumentCreateTypeEmail1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaEmail], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeName1(str, Enum):
    NAME = "NAME"


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


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


class DocumentCreateFieldMetaNameTypedDict(TypedDict):
    type: DocumentCreateTypeName2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentCreateTextAlignName]


class DocumentCreateFieldMetaName(BaseModel):
    type: DocumentCreateTypeName2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignName], pydantic.Field(alias="textAlign")
    ] = None


class DocumentCreateFieldNameTypedDict(TypedDict):
    type: DocumentCreateTypeName1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaNameTypedDict]


class DocumentCreateFieldName(BaseModel):
    type: DocumentCreateTypeName1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaName], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeInitials1(str, Enum):
    INITIALS = "INITIALS"


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


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


class DocumentCreateFieldMetaInitialsTypedDict(TypedDict):
    type: DocumentCreateTypeInitials2
    label: NotRequired[str]
    placeholder: NotRequired[str]
    required: NotRequired[bool]
    read_only: NotRequired[bool]
    font_size: NotRequired[float]
    text_align: NotRequired[DocumentCreateTextAlignInitials]


class DocumentCreateFieldMetaInitials(BaseModel):
    type: DocumentCreateTypeInitials2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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

    text_align: Annotated[
        Optional[DocumentCreateTextAlignInitials], pydantic.Field(alias="textAlign")
    ] = None


class DocumentCreateFieldInitialsTypedDict(TypedDict):
    type: DocumentCreateTypeInitials1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaInitialsTypedDict]


class DocumentCreateFieldInitials(BaseModel):
    type: DocumentCreateTypeInitials1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaInitials], pydantic.Field(alias="fieldMeta")
    ] = None


class DocumentCreateTypeFreeSignature(str, Enum):
    FREE_SIGNATURE = "FREE_SIGNATURE"


class DocumentCreateFieldFreeSignatureTypedDict(TypedDict):
    type: DocumentCreateTypeFreeSignature
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float


class DocumentCreateFieldFreeSignature(BaseModel):
    type: DocumentCreateTypeFreeSignature

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float


class DocumentCreateTypeSignature1(str, Enum):
    SIGNATURE = "SIGNATURE"


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


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


class DocumentCreateFieldMetaSignature(BaseModel):
    type: DocumentCreateTypeSignature2

    label: Optional[str] = None

    placeholder: Optional[str] = None

    required: Optional[bool] = None

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

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


class DocumentCreateFieldSignatureTypedDict(TypedDict):
    type: DocumentCreateTypeSignature1
    page_number: float
    page_x: float
    page_y: float
    width: float
    height: float
    field_meta: NotRequired[DocumentCreateFieldMetaSignatureTypedDict]


class DocumentCreateFieldSignature(BaseModel):
    type: DocumentCreateTypeSignature1

    page_number: Annotated[float, pydantic.Field(alias="pageNumber")]

    page_x: Annotated[float, pydantic.Field(alias="pageX")]

    page_y: Annotated[float, pydantic.Field(alias="pageY")]

    width: float

    height: float

    field_meta: Annotated[
        Optional[DocumentCreateFieldMetaSignature], pydantic.Field(alias="fieldMeta")
    ] = None


DocumentCreateFieldUnionTypedDict = TypeAliasType(
    "DocumentCreateFieldUnionTypedDict",
    Union[
        DocumentCreateFieldFreeSignatureTypedDict,
        DocumentCreateFieldSignatureTypedDict,
        DocumentCreateFieldInitialsTypedDict,
        DocumentCreateFieldNameTypedDict,
        DocumentCreateFieldEmailTypedDict,
        DocumentCreateFieldDateTypedDict,
        DocumentCreateFieldTextTypedDict,
        DocumentCreateFieldNumberTypedDict,
        DocumentCreateFieldRadioTypedDict,
        DocumentCreateFieldCheckboxTypedDict,
        DocumentCreateFieldDropdownTypedDict,
    ],
)


DocumentCreateFieldUnion = TypeAliasType(
    "DocumentCreateFieldUnion",
    Union[
        DocumentCreateFieldFreeSignature,
        DocumentCreateFieldSignature,
        DocumentCreateFieldInitials,
        DocumentCreateFieldName,
        DocumentCreateFieldEmail,
        DocumentCreateFieldDate,
        DocumentCreateFieldText,
        DocumentCreateFieldNumber,
        DocumentCreateFieldRadio,
        DocumentCreateFieldCheckbox,
        DocumentCreateFieldDropdown,
    ],
)


class DocumentCreateRecipientTypedDict(TypedDict):
    email: str
    name: str
    role: DocumentCreateRole
    signing_order: NotRequired[float]
    access_auth: NotRequired[List[DocumentCreateAccessAuth]]
    action_auth: NotRequired[List[DocumentCreateActionAuth]]
    fields: NotRequired[List[DocumentCreateFieldUnionTypedDict]]


class DocumentCreateRecipient(BaseModel):
    email: str

    name: str

    role: DocumentCreateRole

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

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

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

    fields: Optional[List[DocumentCreateFieldUnion]] = None


class DocumentCreateTypeLink(str, Enum):
    LINK = "link"


class DocumentCreateAttachmentTypedDict(TypedDict):
    label: str
    data: str
    type: NotRequired[DocumentCreateTypeLink]


class DocumentCreateAttachment(BaseModel):
    label: str

    data: str

    type: Optional[DocumentCreateTypeLink] = DocumentCreateTypeLink.LINK


class DocumentCreateDateFormat(str, Enum):
    YYYY_M_MDD_HH_MM_A = "yyyy-MM-dd hh:mm a"
    YYYY_M_MDD = "yyyy-MM-dd"
    DD_MM_SLASH_YYYY = "dd/MM/yyyy"
    MM_DD_SLASH_YYYY = "MM/dd/yyyy"
    YY_M_MDD = "yy-MM-dd"
    MMMM_DD_COMMA_YYYY = "MMMM dd, yyyy"
    EEEE_MMMM_DD_COMMA_YYYY = "EEEE, MMMM dd, yyyy"
    DD_MM_SLASH_YYYY_HH_MM_A = "dd/MM/yyyy hh:mm a"
    DD_MM_SLASH_YYYY_H_HMM = "dd/MM/yyyy HH:mm"
    MM_DD_SLASH_YYYY_HH_MM_A = "MM/dd/yyyy hh:mm a"
    MM_DD_SLASH_YYYY_H_HMM = "MM/dd/yyyy HH:mm"
    DD_DOT_MM_DOT_YYYY = "dd.MM.yyyy"
    DD_DOT_MM_DOT_YYYY_H_HMM = "dd.MM.yyyy HH:mm"
    YYYY_M_MDD_H_HMM = "yyyy-MM-dd HH:mm"
    YY_M_MDD_HH_MM_A = "yy-MM-dd hh:mm a"
    YY_M_MDD_H_HMM = "yy-MM-dd HH:mm"
    YYYY_M_MDD_H_HMMSS = "yyyy-MM-dd HH:mm:ss"
    MMMM_DD_COMMA_YYYY_HH_MM_A = "MMMM dd, yyyy hh:mm a"
    MMMM_DD_COMMA_YYYY_H_HMM = "MMMM dd, yyyy HH:mm"
    EEEE_MMMM_DD_COMMA_YYYY_HH_MM_A = "EEEE, MMMM dd, yyyy hh:mm a"
    EEEE_MMMM_DD_COMMA_YYYY_H_HMM = "EEEE, MMMM dd, yyyy HH:mm"
    ISO8601_FULL = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"


class DocumentCreateDistributionMethod(str, Enum):
    EMAIL = "EMAIL"
    NONE = "NONE"


class DocumentCreateSigningOrder(str, Enum):
    PARALLEL = "PARALLEL"
    SEQUENTIAL = "SEQUENTIAL"


class DocumentCreateLanguage(str, Enum):
    DE = "de"
    EN = "en"
    FR = "fr"
    ES = "es"
    IT = "it"
    PL = "pl"


class DocumentCreateEmailSettingsTypedDict(TypedDict):
    recipient_signing_request: NotRequired[bool]
    recipient_removed: NotRequired[bool]
    recipient_signed: NotRequired[bool]
    document_pending: NotRequired[bool]
    document_completed: NotRequired[bool]
    document_deleted: NotRequired[bool]
    owner_document_completed: NotRequired[bool]


class DocumentCreateEmailSettings(BaseModel):
    recipient_signing_request: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigningRequest")
    ] = True

    recipient_removed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientRemoved")
    ] = True

    recipient_signed: Annotated[
        Optional[bool], pydantic.Field(alias="recipientSigned")
    ] = True

    document_pending: Annotated[
        Optional[bool], pydantic.Field(alias="documentPending")
    ] = True

    document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="documentCompleted")
    ] = True

    document_deleted: Annotated[
        Optional[bool], pydantic.Field(alias="documentDeleted")
    ] = True

    owner_document_completed: Annotated[
        Optional[bool], pydantic.Field(alias="ownerDocumentCompleted")
    ] = True


class DocumentCreateMetaTypedDict(TypedDict):
    subject: NotRequired[str]
    message: NotRequired[str]
    timezone: NotRequired[str]
    date_format: NotRequired[DocumentCreateDateFormat]
    distribution_method: NotRequired[DocumentCreateDistributionMethod]
    signing_order: NotRequired[DocumentCreateSigningOrder]
    allow_dictate_next_signer: NotRequired[bool]
    redirect_url: NotRequired[str]
    language: NotRequired[DocumentCreateLanguage]
    typed_signature_enabled: NotRequired[bool]
    upload_signature_enabled: NotRequired[bool]
    draw_signature_enabled: NotRequired[bool]
    email_id: NotRequired[Nullable[str]]
    email_reply_to: NotRequired[Nullable[str]]
    email_settings: NotRequired[Nullable[DocumentCreateEmailSettingsTypedDict]]


class DocumentCreateMeta(BaseModel):
    subject: Optional[str] = None

    message: Optional[str] = None

    timezone: Optional[str] = None

    date_format: Annotated[
        Optional[DocumentCreateDateFormat], pydantic.Field(alias="dateFormat")
    ] = None

    distribution_method: Annotated[
        Optional[DocumentCreateDistributionMethod],
        pydantic.Field(alias="distributionMethod"),
    ] = None

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

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

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

    language: Optional[DocumentCreateLanguage] = None

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

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

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

    email_id: Annotated[OptionalNullable[str], pydantic.Field(alias="emailId")] = UNSET

    email_reply_to: Annotated[
        OptionalNullable[str], pydantic.Field(alias="emailReplyTo")
    ] = UNSET

    email_settings: Annotated[
        OptionalNullable[DocumentCreateEmailSettings],
        pydantic.Field(alias="emailSettings"),
    ] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "subject",
            "message",
            "timezone",
            "dateFormat",
            "distributionMethod",
            "signingOrder",
            "allowDictateNextSigner",
            "redirectUrl",
            "language",
            "typedSignatureEnabled",
            "uploadSignatureEnabled",
            "drawSignatureEnabled",
            "emailId",
            "emailReplyTo",
            "emailSettings",
        ]
        nullable_fields = ["emailId", "emailReplyTo", "emailSettings"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            serialized.pop(k, None)

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class DocumentCreatePayloadTypedDict(TypedDict):
    title: str
    external_id: NotRequired[str]
    visibility: NotRequired[DocumentCreateVisibility]
    global_access_auth: NotRequired[List[DocumentCreateGlobalAccessAuth]]
    global_action_auth: NotRequired[List[DocumentCreateGlobalActionAuth]]
    form_values: NotRequired[Dict[str, DocumentCreateFormValuesTypedDict]]
    folder_id: NotRequired[str]
    recipients: NotRequired[List[DocumentCreateRecipientTypedDict]]
    attachments: NotRequired[List[DocumentCreateAttachmentTypedDict]]
    meta: NotRequired[DocumentCreateMetaTypedDict]


class DocumentCreatePayload(BaseModel):
    title: str

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

    visibility: Optional[DocumentCreateVisibility] = None

    global_access_auth: Annotated[
        Optional[List[DocumentCreateGlobalAccessAuth]],
        pydantic.Field(alias="globalAccessAuth"),
    ] = None

    global_action_auth: Annotated[
        Optional[List[DocumentCreateGlobalActionAuth]],
        pydantic.Field(alias="globalActionAuth"),
    ] = None

    form_values: Annotated[
        Optional[Dict[str, DocumentCreateFormValues]],
        pydantic.Field(alias="formValues"),
    ] = None

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

    recipients: Optional[List[DocumentCreateRecipient]] = None

    attachments: Optional[List[DocumentCreateAttachment]] = None

    meta: Optional[DocumentCreateMeta] = None


class DocumentCreateFileTypedDict(TypedDict):
    file_name: str
    content: Union[bytes, IO[bytes], io.BufferedReader]
    content_type: NotRequired[str]


class DocumentCreateFile(BaseModel):
    file_name: Annotated[
        str, pydantic.Field(alias="fileName"), FieldMetadata(multipart=True)
    ]

    content: Annotated[
        Union[bytes, IO[bytes], io.BufferedReader],
        pydantic.Field(alias=""),
        FieldMetadata(multipart=MultipartFormMetadata(content=True)),
    ]

    content_type: Annotated[
        Optional[str],
        pydantic.Field(alias="Content-Type"),
        FieldMetadata(multipart=True),
    ] = None


class DocumentCreateRequestTypedDict(TypedDict):
    payload: DocumentCreatePayloadTypedDict
    file: DocumentCreateFileTypedDict


class DocumentCreateRequest(BaseModel):
    payload: Annotated[
        DocumentCreatePayload, FieldMetadata(multipart=MultipartFormMetadata(json=True))
    ]

    file: Annotated[
        DocumentCreateFile, FieldMetadata(multipart=MultipartFormMetadata(file=True))
    ]


class DocumentCreateInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class DocumentCreateInternalServerErrorIssue(BaseModel):
    message: str


class DocumentCreateInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentCreateInternalServerErrorIssue]] = None


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

    data: DocumentCreateInternalServerErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentCreateInternalServerErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class DocumentCreateForbiddenIssueTypedDict(TypedDict):
    message: str


class DocumentCreateForbiddenIssue(BaseModel):
    message: str


class DocumentCreateForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentCreateForbiddenIssue]] = None


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

    data: DocumentCreateForbiddenErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentCreateForbiddenErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class DocumentCreateUnauthorizedIssueTypedDict(TypedDict):
    message: str


class DocumentCreateUnauthorizedIssue(BaseModel):
    message: str


class DocumentCreateUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentCreateUnauthorizedIssue]] = None


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

    data: DocumentCreateUnauthorizedErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentCreateUnauthorizedErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


class DocumentCreateBadRequestIssueTypedDict(TypedDict):
    message: str


class DocumentCreateBadRequestIssue(BaseModel):
    message: str


class DocumentCreateBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentCreateBadRequestIssue]] = None


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

    data: DocumentCreateBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentCreateBadRequestErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.message) or fallback
        super().__init__(message, raw_response, body)
        object.__setattr__(self, "data", data)


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

    envelope_id: str
    id: float


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

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

    id: float
