"""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
from documenso_sdk.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from enum import Enum
import httpx
import pydantic
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class DocumentDownloadBetaVersion(str, Enum):
    r"""The version of the document to download. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document."""

    ORIGINAL = "original"
    SIGNED = "signed"


class DocumentDownloadBetaRequestTypedDict(TypedDict):
    document_id: float
    r"""The ID of the document to download."""
    version: NotRequired[DocumentDownloadBetaVersion]
    r"""The version of the document to download. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document."""


class DocumentDownloadBetaRequest(BaseModel):
    document_id: Annotated[
        float,
        pydantic.Field(alias="documentId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The ID of the document to download."""

    version: Annotated[
        Optional[DocumentDownloadBetaVersion],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = DocumentDownloadBetaVersion.SIGNED
    r"""The version of the document to download. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document."""


class DocumentDownloadBetaInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class DocumentDownloadBetaInternalServerErrorIssue(BaseModel):
    message: str


class DocumentDownloadBetaInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentDownloadBetaInternalServerErrorIssue]] = None


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

    data: DocumentDownloadBetaInternalServerErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentDownloadBetaInternalServerErrorData,
        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 DocumentDownloadBetaNotFoundIssueTypedDict(TypedDict):
    message: str


class DocumentDownloadBetaNotFoundIssue(BaseModel):
    message: str


class DocumentDownloadBetaNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentDownloadBetaNotFoundIssue]] = None


@dataclass(unsafe_hash=True)
class DocumentDownloadBetaNotFoundError(DocumensoError):
    r"""Not found"""

    data: DocumentDownloadBetaNotFoundErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentDownloadBetaNotFoundErrorData,
        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 DocumentDownloadBetaForbiddenIssueTypedDict(TypedDict):
    message: str


class DocumentDownloadBetaForbiddenIssue(BaseModel):
    message: str


class DocumentDownloadBetaForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentDownloadBetaForbiddenIssue]] = None


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

    data: DocumentDownloadBetaForbiddenErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentDownloadBetaForbiddenErrorData,
        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 DocumentDownloadBetaUnauthorizedIssueTypedDict(TypedDict):
    message: str


class DocumentDownloadBetaUnauthorizedIssue(BaseModel):
    message: str


class DocumentDownloadBetaUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentDownloadBetaUnauthorizedIssue]] = None


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

    data: DocumentDownloadBetaUnauthorizedErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentDownloadBetaUnauthorizedErrorData,
        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 DocumentDownloadBetaBadRequestIssueTypedDict(TypedDict):
    message: str


class DocumentDownloadBetaBadRequestIssue(BaseModel):
    message: str


class DocumentDownloadBetaBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[DocumentDownloadBetaBadRequestIssue]] = None


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

    data: DocumentDownloadBetaBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: DocumentDownloadBetaBadRequestErrorData,
        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 DocumentDownloadBetaResponseTypedDict(TypedDict):
    r"""Successful response"""

    download_url: str
    filename: str
    content_type: str


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

    download_url: Annotated[str, pydantic.Field(alias="downloadUrl")]

    filename: str

    content_type: Annotated[str, pydantic.Field(alias="contentType")]
