"""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 Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class RevenueStatsTypedDict(TypedDict):
    usage_revenue: NotRequired[str]
    r"""Revenue from usage charges in dollars"""
    fee_revenue: NotRequired[str]
    r"""Revenue from fee charges in dollars"""
    refund_amount: NotRequired[str]
    r"""Total refund amount in dollars"""
    net_revenue: NotRequired[str]
    r"""Net revenue in dollars (usage + fees - refunds)"""
    usage_count: NotRequired[int]
    r"""Number of usage charge events"""
    fee_count: NotRequired[int]
    r"""Number of fee charge events"""
    usage_refund_count: NotRequired[int]
    r"""Number of usage refund events"""
    fee_refund_count: NotRequired[int]
    r"""Number of fee refund events"""


class RevenueStats(BaseModel):
    usage_revenue: Annotated[Optional[str], pydantic.Field(alias="usageRevenue")] = None
    r"""Revenue from usage charges in dollars"""

    fee_revenue: Annotated[Optional[str], pydantic.Field(alias="feeRevenue")] = None
    r"""Revenue from fee charges in dollars"""

    refund_amount: Annotated[Optional[str], pydantic.Field(alias="refundAmount")] = None
    r"""Total refund amount in dollars"""

    net_revenue: Annotated[Optional[str], pydantic.Field(alias="netRevenue")] = None
    r"""Net revenue in dollars (usage + fees - refunds)"""

    usage_count: Annotated[Optional[int], pydantic.Field(alias="usageCount")] = None
    r"""Number of usage charge events"""

    fee_count: Annotated[Optional[int], pydantic.Field(alias="feeCount")] = None
    r"""Number of fee charge events"""

    usage_refund_count: Annotated[
        Optional[int], pydantic.Field(alias="usageRefundCount")
    ] = None
    r"""Number of usage refund events"""

    fee_refund_count: Annotated[
        Optional[int], pydantic.Field(alias="feeRefundCount")
    ] = None
    r"""Number of fee refund events"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "usageRevenue",
                "feeRevenue",
                "refundAmount",
                "netRevenue",
                "usageCount",
                "feeCount",
                "usageRefundCount",
                "feeRefundCount",
            ]
        )
        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:
    RevenueStats.model_rebuild()
except NameError:
    pass
