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

from __future__ import annotations
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Dict, Literal, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


CreateFeatureType = Literal[
    "metered",
    "static",
    "boolean",
]
r"""Feature type: 'metered' for usage-based features, 'static' for fixed allocations, 'boolean' for on/off features"""


class CreateFeatureRequestTypedDict(TypedDict):
    key: str
    r"""Unique slug identifier for the feature within the product. Must be lowercase letters, numbers, and hyphens only."""
    name: str
    r"""Human-readable feature name shown to customers."""
    merchant_id: str
    r"""Unique identifier for an organization"""
    product_id: str
    r"""Unique identifier for a product"""
    type: NotRequired[CreateFeatureType]
    r"""Feature type: 'metered' for usage-based features, 'static' for fixed allocations, 'boolean' for on/off features"""
    metadata: NotRequired[Dict[str, str]]
    r"""Optional key-value metadata storage for feature information."""


class CreateFeatureRequest(BaseModel):
    key: str
    r"""Unique slug identifier for the feature within the product. Must be lowercase letters, numbers, and hyphens only."""

    name: str
    r"""Human-readable feature name shown to customers."""

    merchant_id: Annotated[str, pydantic.Field(alias="merchantId")]
    r"""Unique identifier for an organization"""

    product_id: Annotated[str, pydantic.Field(alias="productId")]
    r"""Unique identifier for a product"""

    type: Optional[CreateFeatureType] = "boolean"
    r"""Feature type: 'metered' for usage-based features, 'static' for fixed allocations, 'boolean' for on/off features"""

    metadata: Optional[Dict[str, str]] = None
    r"""Optional key-value metadata storage for feature information."""

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


try:
    CreateFeatureRequest.model_rebuild()
except NameError:
    pass
