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

from __future__ import annotations
from .activeentitlement import ActiveEntitlement, ActiveEntitlementTypedDict
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 GetActiveEntitlementsRequestTypedDict(TypedDict):
    customer_id: str
    r"""The customer ID to get active entitlements for."""
    product_id: NotRequired[str]
    r"""The product ID to get active entitlements for."""
    subscription_id: NotRequired[str]
    r"""The subscription ID to get active entitlements for."""


class GetActiveEntitlementsRequest(BaseModel):
    customer_id: Annotated[
        str,
        pydantic.Field(alias="customerId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ]
    r"""The customer ID to get active entitlements for."""

    product_id: Annotated[
        Optional[str],
        pydantic.Field(alias="productId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The product ID to get active entitlements for."""

    subscription_id: Annotated[
        Optional[str],
        pydantic.Field(alias="subscriptionId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The subscription ID to get active entitlements for."""

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


GetActiveEntitlementsObject = Literal["list",]


class GetActiveEntitlementsPaginationTypedDict(TypedDict):
    offset: NotRequired[float]
    limit: NotRequired[float]
    total: NotRequired[float]


class GetActiveEntitlementsPagination(BaseModel):
    offset: Optional[float] = None

    limit: Optional[float] = None

    total: Optional[float] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["offset", "limit", "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 GetActiveEntitlementsResponseTypedDict(TypedDict):
    r"""List of active entitlements"""

    object: NotRequired[GetActiveEntitlementsObject]
    data: NotRequired[List[ActiveEntitlementTypedDict]]
    pagination: NotRequired[GetActiveEntitlementsPaginationTypedDict]


class GetActiveEntitlementsResponse(BaseModel):
    r"""List of active entitlements"""

    object: Optional[GetActiveEntitlementsObject] = "list"

    data: Optional[List[ActiveEntitlement]] = None

    pagination: Optional[GetActiveEntitlementsPagination] = None

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