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

from __future__ import annotations
from .amountdecimal import AmountDecimal, AmountDecimalTypedDict
from .generatedby import GeneratedBy, GeneratedByTypedDict
from datetime import datetime
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 IncurredFeeTypedDict(TypedDict):
    r"""A fee incurred by a user."""

    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)."""
    account_id: NotRequired[str]
    r"""Account ID the fee belongs to."""
    wallet_id: NotRequired[str]
    r"""Wallet ID associated with the fee."""
    created_on: NotRequired[datetime]
    r"""Timestamp when the fee was created."""
    fee_name: NotRequired[str]
    r"""Name of the fee."""
    amount: NotRequired[AmountDecimalTypedDict]
    r"""The fee amount."""
    generated_by: NotRequired[GeneratedByTypedDict]
    r"""Object indicating what generated the fee (TransferID, CardID, DisputeID, AccountID, or BankAccountID)."""
    fee_group: NotRequired[str]
    r"""Describes the source of the fee, such as a Moov-set processing fee, a network pass-through fee, or an interchange or discount fee."""
    residual_id: NotRequired[str]
    r"""Unique identifier for this residual payment calculation."""


class IncurredFee(BaseModel):
    r"""A fee incurred by a user."""

    fee_id: Annotated[Optional[str], pydantic.Field(alias="feeID")] = 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)."""

    account_id: Annotated[Optional[str], pydantic.Field(alias="accountID")] = None
    r"""Account ID the fee belongs to."""

    wallet_id: Annotated[Optional[str], pydantic.Field(alias="walletID")] = None
    r"""Wallet ID associated with the fee."""

    created_on: Annotated[Optional[datetime], pydantic.Field(alias="createdOn")] = None
    r"""Timestamp when the fee was created."""

    fee_name: Annotated[Optional[str], pydantic.Field(alias="feeName")] = None
    r"""Name of the fee."""

    amount: Optional[AmountDecimal] = None
    r"""The fee amount."""

    generated_by: Annotated[
        Optional[GeneratedBy], pydantic.Field(alias="generatedBy")
    ] = None
    r"""Object indicating what generated the fee (TransferID, CardID, DisputeID, AccountID, or BankAccountID)."""

    fee_group: Annotated[Optional[str], pydantic.Field(alias="feeGroup")] = None
    r"""Describes the source of the fee, such as a Moov-set processing fee, a network pass-through fee, or an interchange or discount fee."""

    residual_id: Annotated[Optional[str], pydantic.Field(alias="residualID")] = None
    r"""Unique identifier for this residual payment calculation."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "feeID",
                "accountID",
                "walletID",
                "createdOn",
                "feeName",
                "amount",
                "generatedBy",
                "feeGroup",
                "residualID",
            ]
        )
        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:
    IncurredFee.model_rebuild()
except NameError:
    pass
