"""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 Any, Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


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

    ORIGINAL = "original"
    SIGNED = "signed"


class EnvelopeItemDownloadRequestTypedDict(TypedDict):
    envelope_item_id: str
    r"""The ID of the envelope item to download."""
    version: NotRequired[EnvelopeItemDownloadVersion]
    r"""The version of the envelope item to download. \"signed\" returns the completed document with signatures, \"original\" returns the original uploaded document."""


class EnvelopeItemDownloadRequest(BaseModel):
    envelope_item_id: Annotated[
        str,
        pydantic.Field(alias="envelopeItemId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The ID of the envelope item to download."""

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


class EnvelopeItemDownloadInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class EnvelopeItemDownloadInternalServerErrorIssue(BaseModel):
    message: str


class EnvelopeItemDownloadInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemDownloadInternalServerErrorIssue]] = None


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

    data: EnvelopeItemDownloadInternalServerErrorData = field(hash=False)

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


class EnvelopeItemDownloadNotFoundIssue(BaseModel):
    message: str


class EnvelopeItemDownloadNotFoundErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemDownloadNotFoundIssue]] = None


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

    data: EnvelopeItemDownloadNotFoundErrorData = field(hash=False)

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


class EnvelopeItemDownloadForbiddenIssue(BaseModel):
    message: str


class EnvelopeItemDownloadForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemDownloadForbiddenIssue]] = None


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

    data: EnvelopeItemDownloadForbiddenErrorData = field(hash=False)

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


class EnvelopeItemDownloadUnauthorizedIssue(BaseModel):
    message: str


class EnvelopeItemDownloadUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemDownloadUnauthorizedIssue]] = None


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

    data: EnvelopeItemDownloadUnauthorizedErrorData = field(hash=False)

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


class EnvelopeItemDownloadBadRequestIssue(BaseModel):
    message: str


class EnvelopeItemDownloadBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemDownloadBadRequestIssue]] = None


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

    data: EnvelopeItemDownloadBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: EnvelopeItemDownloadBadRequestErrorData,
        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 EnvelopeItemDownloadResponseTypedDict(TypedDict):
    headers: Dict[str, List[str]]
    result: Any


class EnvelopeItemDownloadResponse(BaseModel):
    headers: Dict[str, List[str]]

    result: Any
