"""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, MultipartFormMetadata
import httpx
import io
import pydantic
from typing import IO, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class EnvelopeItemCreateManyPayloadTypedDict(TypedDict):
    envelope_id: str


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


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


class EnvelopeItemCreateManyFile(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 EnvelopeItemCreateManyRequestTypedDict(TypedDict):
    payload: EnvelopeItemCreateManyPayloadTypedDict
    files: NotRequired[List[EnvelopeItemCreateManyFileTypedDict]]


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

    files: Annotated[
        Optional[List[EnvelopeItemCreateManyFile]],
        FieldMetadata(multipart=MultipartFormMetadata(file=True)),
    ] = None


class EnvelopeItemCreateManyInternalServerErrorIssueTypedDict(TypedDict):
    message: str


class EnvelopeItemCreateManyInternalServerErrorIssue(BaseModel):
    message: str


class EnvelopeItemCreateManyInternalServerErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemCreateManyInternalServerErrorIssue]] = None


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

    data: EnvelopeItemCreateManyInternalServerErrorData = field(hash=False)

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


class EnvelopeItemCreateManyForbiddenIssue(BaseModel):
    message: str


class EnvelopeItemCreateManyForbiddenErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemCreateManyForbiddenIssue]] = None


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

    data: EnvelopeItemCreateManyForbiddenErrorData = field(hash=False)

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


class EnvelopeItemCreateManyUnauthorizedIssue(BaseModel):
    message: str


class EnvelopeItemCreateManyUnauthorizedErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemCreateManyUnauthorizedIssue]] = None


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

    data: EnvelopeItemCreateManyUnauthorizedErrorData = field(hash=False)

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


class EnvelopeItemCreateManyBadRequestIssue(BaseModel):
    message: str


class EnvelopeItemCreateManyBadRequestErrorData(BaseModel):
    message: str

    code: str

    issues: Optional[List[EnvelopeItemCreateManyBadRequestIssue]] = None


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

    data: EnvelopeItemCreateManyBadRequestErrorData = field(hash=False)

    def __init__(
        self,
        data: EnvelopeItemCreateManyBadRequestErrorData,
        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 EnvelopeItemCreateManyDataTypedDict(TypedDict):
    id: str
    title: str
    envelope_id: str
    order: float


class EnvelopeItemCreateManyData(BaseModel):
    id: str

    title: str

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

    order: float


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

    data: List[EnvelopeItemCreateManyDataTypedDict]


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

    data: List[EnvelopeItemCreateManyData]
