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

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


FeePriceModel = Literal["standard",]
r"""The pricing model. Fees only support standard pricing."""


FeePricePaymentTerm = Union[
    Literal[
        "in_advance",
        "in_arrears",
    ],
    UnrecognizedStr,
]
r"""When the fee is charged relative to the billing period."""


class PropertiesTypedDict(TypedDict):
    unit_price: str
    r"""The unit price in dollars (e.g., '10.00')."""


class Properties(BaseModel):
    unit_price: Annotated[str, pydantic.Field(alias="unitPrice")]
    r"""The unit price in dollars (e.g., '10.00')."""


class FeePriceTypedDict(TypedDict):
    r"""The price configuration for a fee within a subscription context."""

    id: str
    r"""The unique identifier of the price."""
    fee_id: str
    r"""The unique identifier of the fee."""
    model: FeePriceModel
    r"""The pricing model. Fees only support standard pricing."""
    payment_term: FeePricePaymentTerm
    r"""When the fee is charged relative to the billing period."""
    invoice_display_name: str
    r"""The name to display on invoices for this fee."""
    properties: PropertiesTypedDict
    tax_rate: NotRequired[float]
    r"""The tax rate as a percentage (e.g., 10 for 10%)."""


class FeePrice(BaseModel):
    r"""The price configuration for a fee within a subscription context."""

    id: str
    r"""The unique identifier of the price."""

    fee_id: Annotated[str, pydantic.Field(alias="feeId")]
    r"""The unique identifier of the fee."""

    model: FeePriceModel
    r"""The pricing model. Fees only support standard pricing."""

    payment_term: Annotated[FeePricePaymentTerm, pydantic.Field(alias="paymentTerm")]
    r"""When the fee is charged relative to the billing period."""

    invoice_display_name: Annotated[str, pydantic.Field(alias="invoiceDisplayName")]
    r"""The name to display on invoices for this fee."""

    properties: Properties

    tax_rate: Annotated[Optional[float], pydantic.Field(alias="taxRate")] = None
    r"""The tax rate as a percentage (e.g., 10 for 10%)."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["taxRate"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    Properties.model_rebuild()
except NameError:
    pass
try:
    FeePrice.model_rebuild()
except NameError:
    pass
