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

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


class ListPricesRequestTypedDict(TypedDict):
    billable_metric_id: NotRequired[str]
    r"""Filter prices by billable metric ID"""
    limit: NotRequired[int]
    r"""Number of prices to return"""
    offset: NotRequired[int]
    r"""Number of prices to skip"""


class ListPricesRequest(BaseModel):
    billable_metric_id: Annotated[
        Optional[str],
        pydantic.Field(alias="billableMetricId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter prices by billable metric ID"""

    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 10
    r"""Number of prices to return"""

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 0
    r"""Number of prices to skip"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["billableMetricId", "limit", "offset"])
        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


class ListPricesPaginationTypedDict(TypedDict):
    limit: NotRequired[int]
    offset: NotRequired[int]
    total: NotRequired[int]


class ListPricesPagination(BaseModel):
    limit: Optional[int] = None

    offset: Optional[int] = None

    total: Optional[int] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["limit", "offset", "total"])
        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


class ListPricesResponseTypedDict(TypedDict):
    r"""List of prices"""

    data: NotRequired[List[SchemasPriceTypedDict]]
    pagination: NotRequired[ListPricesPaginationTypedDict]


class ListPricesResponse(BaseModel):
    r"""List of prices"""

    data: Optional[List[SchemasPrice]] = None

    pagination: Optional[ListPricesPagination] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["data", "pagination"])
        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
