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

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class GetInvoiceRequestTypedDict(TypedDict):
    id: str
    r"""The invoice ID"""
    expand: NotRequired[str]
    r"""Comma-separated list of fields to expand. Currently supports: lineItems"""
    line_items_limit: NotRequired[int]
    r"""Page size for line items when expand=lineItems"""
    line_items_page_token: NotRequired[str]
    r"""Pagination token for line items when expand=lineItems"""


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

    expand: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Comma-separated list of fields to expand. Currently supports: lineItems"""

    line_items_limit: Annotated[
        Optional[int],
        pydantic.Field(alias="lineItemsLimit"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 100
    r"""Page size for line items when expand=lineItems"""

    line_items_page_token: Annotated[
        Optional[str],
        pydantic.Field(alias="lineItemsPageToken"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Pagination token for line items when expand=lineItems"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["expand", "lineItemsLimit", "lineItemsPageToken"])
        serialized = handler(self)
        m = {}

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

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
