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

from __future__ import annotations
from .walletstatus import WalletStatus
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class PatchWalletTypedDict(TypedDict):
    name: NotRequired[str]
    status: NotRequired[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.
    """
    description: NotRequired[str]
    metadata: NotRequired[Dict[str, str]]
    r"""Free-form key-value pair list. Useful for storing information that is not captured elsewhere."""


class PatchWallet(BaseModel):
    name: Optional[str] = None

    status: Optional[WalletStatus] = None
    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.
    """

    description: Optional[str] = None

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

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["name", "status", "description", "metadata"])
        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
