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

from __future__ import annotations
from .billablemetric import BillableMetric, BillableMetricTypedDict
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, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListBillableMetricsRequestTypedDict(TypedDict):
    merchant_id: str
    r"""Filter billable metrics by merchant organization ID."""
    limit: NotRequired[int]
    r"""Number of billable metrics to return."""
    offset: NotRequired[int]
    r"""Number of billable metrics to skip."""
    product_id: NotRequired[str]
    r"""Filter billable metrics by product ID."""


class ListBillableMetricsRequest(BaseModel):
    merchant_id: Annotated[
        str,
        pydantic.Field(alias="merchantId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ]
    r"""Filter billable metrics by merchant organization ID."""

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

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

    product_id: Annotated[
        Optional[str],
        pydantic.Field(alias="productId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter billable metrics by product ID."""

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


ListBillableMetricsObject = Literal["list",]


class ListBillableMetricsPaginationTypedDict(TypedDict):
    limit: int
    offset: int
    total: int


class ListBillableMetricsPagination(BaseModel):
    limit: int

    offset: int

    total: int


class ListBillableMetricsResponseTypedDict(TypedDict):
    r"""List of billable metrics"""

    object: ListBillableMetricsObject
    data: List[BillableMetricTypedDict]
    pagination: ListBillableMetricsPaginationTypedDict


class ListBillableMetricsResponse(BaseModel):
    r"""List of billable metrics"""

    object: ListBillableMetricsObject

    data: List[BillableMetric]

    pagination: ListBillableMetricsPagination
