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

from __future__ import annotations
from .billingcountandamount import BillingCountAndAmount, BillingCountAndAmountTypedDict
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


class InstantPaymentFeesTypedDict(TypedDict):
    r"""A detailed breakdown of instant payment fees."""

    rtp_credit_transaction: BillingCountAndAmountTypedDict
    r"""Fees for RTP credit transactions."""
    push_to_card_transaction: BillingCountAndAmountTypedDict
    r"""Fees for push-to-card transactions."""
    pull_from_card_transaction: BillingCountAndAmountTypedDict
    r"""Fees for pull-from-card transactions."""
    instant_verification: BillingCountAndAmountTypedDict
    r"""Fees for instant payment verifications."""
    total: BillingCountAndAmountTypedDict
    r"""Total instant payment fees."""
    rtp_decline: NotRequired[BillingCountAndAmountTypedDict]
    r"""Fees for RTP declines."""
    push_to_card_decline: NotRequired[BillingCountAndAmountTypedDict]
    r"""Fees for push-to-card declines."""
    pull_from_card_decline: NotRequired[BillingCountAndAmountTypedDict]
    r"""Fees for pull-from-card declines."""
    pull_from_card_refund: NotRequired[BillingCountAndAmountTypedDict]
    r"""Fees for pull-from-card refunds."""


class InstantPaymentFees(BaseModel):
    r"""A detailed breakdown of instant payment fees."""

    rtp_credit_transaction: Annotated[
        BillingCountAndAmount, pydantic.Field(alias="rtpCreditTransaction")
    ]
    r"""Fees for RTP credit transactions."""

    push_to_card_transaction: Annotated[
        BillingCountAndAmount, pydantic.Field(alias="pushToCardTransaction")
    ]
    r"""Fees for push-to-card transactions."""

    pull_from_card_transaction: Annotated[
        BillingCountAndAmount, pydantic.Field(alias="pullFromCardTransaction")
    ]
    r"""Fees for pull-from-card transactions."""

    instant_verification: Annotated[
        BillingCountAndAmount, pydantic.Field(alias="instantVerification")
    ]
    r"""Fees for instant payment verifications."""

    total: BillingCountAndAmount
    r"""Total instant payment fees."""

    rtp_decline: Annotated[
        Optional[BillingCountAndAmount], pydantic.Field(alias="rtpDecline")
    ] = None
    r"""Fees for RTP declines."""

    push_to_card_decline: Annotated[
        Optional[BillingCountAndAmount], pydantic.Field(alias="pushToCardDecline")
    ] = None
    r"""Fees for push-to-card declines."""

    pull_from_card_decline: Annotated[
        Optional[BillingCountAndAmount], pydantic.Field(alias="pullFromCardDecline")
    ] = None
    r"""Fees for pull-from-card declines."""

    pull_from_card_refund: Annotated[
        Optional[BillingCountAndAmount], pydantic.Field(alias="pullFromCardRefund")
    ] = None
    r"""Fees for pull-from-card refunds."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "rtpDecline",
                "pushToCardDecline",
                "pullFromCardDecline",
                "pullFromCardRefund",
            ]
        )
        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:
    InstantPaymentFees.model_rebuild()
except NameError:
    pass
