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

from __future__ import annotations
from .feature import Feature, FeatureTypedDict
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 ListFeaturesRequestTypedDict(TypedDict):
    product_id: str
    r"""The product ID to filter features by"""
    key: NotRequired[str]
    r"""Optional feature key to filter by. If provided, returns only the feature matching both productId and key"""
    limit: NotRequired[int]
    r"""Number of features to return."""
    offset: NotRequired[int]
    r"""Number of features to skip."""


class ListFeaturesRequest(BaseModel):
    product_id: Annotated[
        str,
        pydantic.Field(alias="productId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ]
    r"""The product ID to filter features by"""

    key: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Optional feature key to filter by. If provided, returns only the feature matching both productId and key"""

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

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

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


ListFeaturesObject = Literal["list",]


class ListFeaturesPaginationTypedDict(TypedDict):
    limit: int
    r"""Number of items requested"""
    offset: int
    r"""Number of items skipped"""
    total: int
    r"""Total number of items matching the query"""


class ListFeaturesPagination(BaseModel):
    limit: int
    r"""Number of items requested"""

    offset: int
    r"""Number of items skipped"""

    total: int
    r"""Total number of items matching the query"""


class ListFeaturesResponseTypedDict(TypedDict):
    r"""List of features"""

    object: ListFeaturesObject
    data: List[FeatureTypedDict]
    pagination: ListFeaturesPaginationTypedDict


class ListFeaturesResponse(BaseModel):
    r"""List of features"""

    object: ListFeaturesObject

    data: List[Feature]

    pagination: ListFeaturesPagination
