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

from __future__ import annotations
from .feecategory import FeeCategory
from .feemodel import FeeModel
from .feeproperties import FeeProperties, FeePropertiesTypedDict
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Any, Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class BillableFeeTypedDict(TypedDict):
    fee_model: FeeModel
    r"""Specifies the pricing model used for the calculation of the final fee."""
    fee_category: FeeCategory
    billable_fee_id: NotRequired[str]
    r"""A unique identifier for a Moov resource. Supports UUID format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) or typed format with base32-encoded UUID and type suffix (e.g., kuoaydiojf7uszaokc2ggnaaaa_xfer)."""
    billable_event: NotRequired[str]
    r"""A unique code identifying a charge."""
    fee_name: NotRequired[str]
    r"""Specifies the name of the fee that will be billed."""
    fee_properties: NotRequired[FeePropertiesTypedDict]
    r"""Defines the specific parameters used for fee calculation."""
    fee_conditions: NotRequired[Dict[str, Any]]
    r"""Defines the specific conditions that must be met for the fee to be applied."""


class BillableFee(BaseModel):
    fee_model: Annotated[FeeModel, pydantic.Field(alias="feeModel")]
    r"""Specifies the pricing model used for the calculation of the final fee."""

    fee_category: Annotated[FeeCategory, pydantic.Field(alias="feeCategory")]

    billable_fee_id: Annotated[Optional[str], pydantic.Field(alias="billableFeeID")] = (
        None
    )
    r"""A unique identifier for a Moov resource. Supports UUID format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) or typed format with base32-encoded UUID and type suffix (e.g., kuoaydiojf7uszaokc2ggnaaaa_xfer)."""

    billable_event: Annotated[Optional[str], pydantic.Field(alias="billableEvent")] = (
        None
    )
    r"""A unique code identifying a charge."""

    fee_name: Annotated[Optional[str], pydantic.Field(alias="feeName")] = None
    r"""Specifies the name of the fee that will be billed."""

    fee_properties: Annotated[
        Optional[FeeProperties], pydantic.Field(alias="feeProperties")
    ] = None
    r"""Defines the specific parameters used for fee calculation."""

    fee_conditions: Annotated[
        Optional[Dict[str, Any]], pydantic.Field(alias="feeConditions")
    ] = None
    r"""Defines the specific conditions that must be met for the fee to be applied."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "billableFeeID",
                "billableEvent",
                "feeName",
                "feeProperties",
                "feeConditions",
            ]
        )
        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:
    BillableFee.model_rebuild()
except NameError:
    pass
