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

from __future__ import annotations
from .walletavailablebalance import (
    WalletAvailableBalance,
    WalletAvailableBalanceTypedDict,
)
from .walletstatus import WalletStatus
from .wallettype import WalletType
from datetime import datetime
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class WalletTypedDict(TypedDict):
    r"""A Moov wallet to store funds for transfers."""

    wallet_id: str
    available_balance: WalletAvailableBalanceTypedDict
    partner_account_id: str
    name: str
    r"""Name of the wallet"""
    status: WalletStatus
    r"""Status of a wallet.
    - `active`: The wallet is available for use and has an enabled payment method.
    - `closed`: The wallet is no longer active and the corresponding payment method has been disabled.
    """
    wallet_type: WalletType
    r"""Type of a wallet.
    - `default`: The system-generated wallet automatically created when an account is granted the wallet capability.
    - `general`: An additional, user-defined wallet created via API or Dashboard.
    """
    description: str
    r"""Description of the wallet"""
    created_on: datetime
    metadata: NotRequired[Dict[str, str]]
    r"""Free-form key-value pair list. Useful for storing information that is not captured elsewhere."""
    closed_on: NotRequired[datetime]


class Wallet(BaseModel):
    r"""A Moov wallet to store funds for transfers."""

    wallet_id: Annotated[str, pydantic.Field(alias="walletID")]

    available_balance: Annotated[
        WalletAvailableBalance, pydantic.Field(alias="availableBalance")
    ]

    partner_account_id: Annotated[str, pydantic.Field(alias="partnerAccountID")]

    name: str
    r"""Name of the wallet"""

    status: WalletStatus
    r"""Status of a wallet.
    - `active`: The wallet is available for use and has an enabled payment method.
    - `closed`: The wallet is no longer active and the corresponding payment method has been disabled.
    """

    wallet_type: Annotated[WalletType, pydantic.Field(alias="walletType")]
    r"""Type of a wallet.
    - `default`: The system-generated wallet automatically created when an account is granted the wallet capability.
    - `general`: An additional, user-defined wallet created via API or Dashboard.
    """

    description: str
    r"""Description of the wallet"""

    created_on: Annotated[datetime, pydantic.Field(alias="createdOn")]

    metadata: Optional[Dict[str, str]] = None
    r"""Free-form key-value pair list. Useful for storing information that is not captured elsewhere."""

    closed_on: Annotated[Optional[datetime], pydantic.Field(alias="closedOn")] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["metadata", "closedOn"])
        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:
    Wallet.model_rebuild()
except NameError:
    pass
