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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict, deprecated


@deprecated(
    "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
)
class VolumeAmountTypedDict(TypedDict):
    r"""The total transaction volume amount. This field is deprecated and will be removed in a future release."""

    currency: str
    r"""A 3-letter ISO 4217 currency code."""
    value_decimal: str
    r"""A decimal-formatted numerical string that represents up to 9 decimal place precision.

    For example, $12.987654321 is '12.987654321'.
    """


@deprecated(
    "warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible."
)
class VolumeAmount(BaseModel):
    r"""The total transaction volume amount. This field is deprecated and will be removed in a future release."""

    currency: str
    r"""A 3-letter ISO 4217 currency code."""

    value_decimal: Annotated[str, pydantic.Field(alias="valueDecimal")]
    r"""A decimal-formatted numerical string that represents up to 9 decimal place precision.

    For example, $12.987654321 is '12.987654321'.
    """


class BillingSummaryDetailsTypedDict(TypedDict):
    volume_amount: NotRequired[VolumeAmountTypedDict]
    r"""The total transaction volume amount. This field is deprecated and will be removed in a future release."""
    volume_count: NotRequired[int]
    r"""The total number of transactions. This field is deprecated and will be removed in a future release."""
    fee_amount: NotRequired[AmountDecimalTypedDict]
    r"""The total fee amount."""
    merchant_fees_collected: NotRequired[AmountDecimalTypedDict]
    r"""Total fee revenue collected from merchants."""
    partner_fees_assessed: NotRequired[AmountDecimalTypedDict]
    r"""Total fee costs incurred by the partner."""
    net_income: NotRequired[AmountDecimalTypedDict]
    r"""Net revenue after deducting partner fee costs."""


class BillingSummaryDetails(BaseModel):
    volume_amount: Annotated[
        Optional[VolumeAmount],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
            alias="volumeAmount",
        ),
    ] = None
    r"""The total transaction volume amount. This field is deprecated and will be removed in a future release."""

    volume_count: Annotated[
        Optional[int],
        pydantic.Field(
            deprecated="warning: ** DEPRECATED ** - This will be removed in a future release, please migrate away from it as soon as possible.",
            alias="volumeCount",
        ),
    ] = None
    r"""The total number of transactions. This field is deprecated and will be removed in a future release."""

    fee_amount: Annotated[
        Optional[AmountDecimal], pydantic.Field(alias="feeAmount")
    ] = None
    r"""The total fee amount."""

    merchant_fees_collected: Annotated[
        Optional[AmountDecimal], pydantic.Field(alias="merchantFeesCollected")
    ] = None
    r"""Total fee revenue collected from merchants."""

    partner_fees_assessed: Annotated[
        Optional[AmountDecimal], pydantic.Field(alias="partnerFeesAssessed")
    ] = None
    r"""Total fee costs incurred by the partner."""

    net_income: Annotated[
        Optional[AmountDecimal], pydantic.Field(alias="netIncome")
    ] = None
    r"""Net revenue after deducting partner fee costs."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "volumeAmount",
                "volumeCount",
                "feeAmount",
                "merchantFeesCollected",
                "partnerFeesAssessed",
                "netIncome",
            ]
        )
        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:
    VolumeAmount.model_rebuild()
except NameError:
    pass
try:
    BillingSummaryDetails.model_rebuild()
except NameError:
    pass
