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

from __future__ import annotations
from .missinginvoicebillingdetails import MissingInvoiceBillingDetailsData
from .notpaidorder import NotPaidOrderData
import httpx
from polar_sdk.models import PolarError
from polar_sdk.types import BaseModel
from polar_sdk.utils import FieldMetadata, PathParamMetadata
from typing import Optional, Union
from typing_extensions import Annotated, TypeAliasType, TypedDict


class OrdersGenerateInvoiceRequestTypedDict(TypedDict):
    id: str
    r"""The order ID."""


class OrdersGenerateInvoiceRequest(BaseModel):
    id: Annotated[
        str, FieldMetadata(path=PathParamMetadata(style="simple", explode=False))
    ]
    r"""The order ID."""


OrdersGenerateInvoiceResponse422OrdersGenerateInvoiceUnion = TypeAliasType(
    "OrdersGenerateInvoiceResponse422OrdersGenerateInvoiceUnion",
    Union[MissingInvoiceBillingDetailsData, NotPaidOrderData],
)
r"""Order is not paid or is missing billing name or address."""


class OrdersGenerateInvoiceResponse422OrdersGenerateInvoice(PolarError):
    r"""Order is not paid or is missing billing name or address."""

    data: OrdersGenerateInvoiceResponse422OrdersGenerateInvoiceUnion

    def __init__(
        self,
        data: OrdersGenerateInvoiceResponse422OrdersGenerateInvoiceUnion,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        message = body or raw_response.text
        super().__init__(message, raw_response, body)
        self.data = data
