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

from __future__ import annotations
from .types_alertsettings import TypesAlertSettings, TypesAlertSettingsTypedDict
from .types_alertstate import TypesAlertState
from .types_autotopup import TypesAutoTopup, TypesAutoTopupTypedDict
from .types_creditbreakdown import TypesCreditBreakdown, TypesCreditBreakdownTypedDict
from .types_status import TypesStatus
from .types_walletconfig import TypesWalletConfig, TypesWalletConfigTypedDict
from .types_walletstatus import TypesWalletStatus
from .types_wallettype import TypesWalletType
from flexprice_py.types import BaseModel, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict


class DtoWalletResponseTypedDict(TypedDict):
    alert_settings: NotRequired[TypesAlertSettingsTypedDict]
    alert_state: NotRequired[TypesAlertState]
    auto_topup: NotRequired[TypesAutoTopupTypedDict]
    balance: NotRequired[str]
    config: NotRequired[TypesWalletConfigTypedDict]
    conversion_rate: NotRequired[str]
    r"""amount in the currency =  number of credits * conversion_rate
    ex if conversion_rate is 1, then 1 USD = 1 credit
    ex if conversion_rate is 2, then 1 USD = 0.5 credits
    ex if conversion_rate is 0.5, then 1 USD = 2 credits
    """
    created_at: NotRequired[str]
    created_by: NotRequired[str]
    credit_balance: NotRequired[str]
    credits_available_breakdown: NotRequired[TypesCreditBreakdownTypedDict]
    currency: NotRequired[str]
    customer_id: NotRequired[str]
    description: NotRequired[str]
    environment_id: NotRequired[str]
    id: NotRequired[str]
    metadata: NotRequired[Dict[str, str]]
    name: NotRequired[str]
    status: NotRequired[TypesStatus]
    tenant_id: NotRequired[str]
    topup_conversion_rate: NotRequired[str]
    r"""topup_conversion_rate is the conversion rate for the topup to the currency
    ex if topup_conversion_rate is 1, then 1 USD = 1 credit
    ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits
    ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits
    """
    updated_at: NotRequired[str]
    updated_by: NotRequired[str]
    wallet_status: NotRequired[TypesWalletStatus]
    wallet_type: NotRequired[TypesWalletType]


class DtoWalletResponse(BaseModel):
    alert_settings: Optional[TypesAlertSettings] = None

    alert_state: Optional[TypesAlertState] = None

    auto_topup: Optional[TypesAutoTopup] = None

    balance: Optional[str] = None

    config: Optional[TypesWalletConfig] = None

    conversion_rate: Optional[str] = None
    r"""amount in the currency =  number of credits * conversion_rate
    ex if conversion_rate is 1, then 1 USD = 1 credit
    ex if conversion_rate is 2, then 1 USD = 0.5 credits
    ex if conversion_rate is 0.5, then 1 USD = 2 credits
    """

    created_at: Optional[str] = None

    created_by: Optional[str] = None

    credit_balance: Optional[str] = None

    credits_available_breakdown: Optional[TypesCreditBreakdown] = None

    currency: Optional[str] = None

    customer_id: Optional[str] = None

    description: Optional[str] = None

    environment_id: Optional[str] = None

    id: Optional[str] = None

    metadata: Optional[Dict[str, str]] = None

    name: Optional[str] = None

    status: Optional[TypesStatus] = None

    tenant_id: Optional[str] = None

    topup_conversion_rate: Optional[str] = None
    r"""topup_conversion_rate is the conversion rate for the topup to the currency
    ex if topup_conversion_rate is 1, then 1 USD = 1 credit
    ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits
    ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits
    """

    updated_at: Optional[str] = None

    updated_by: Optional[str] = None

    wallet_status: Optional[TypesWalletStatus] = None

    wallet_type: Optional[TypesWalletType] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "alert_settings",
                "alert_state",
                "auto_topup",
                "balance",
                "config",
                "conversion_rate",
                "created_at",
                "created_by",
                "credit_balance",
                "credits_available_breakdown",
                "currency",
                "customer_id",
                "description",
                "environment_id",
                "id",
                "metadata",
                "name",
                "status",
                "tenant_id",
                "topup_conversion_rate",
                "updated_at",
                "updated_by",
                "wallet_status",
                "wallet_type",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m
