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

from __future__ import annotations
from .transferterminalcard import TransferTerminalCard, TransferTerminalCardTypedDict
from enum import Enum
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 CardPresentPaymentTransferPaymentMethodPaymentMethodType(str, Enum):
    CARD_PRESENT_PAYMENT = "card-present-payment"


class CardPresentPaymentTransferPaymentMethodTypedDict(TypedDict):
    r"""A card used at point of sale terminal for a card present transaction as contained within a payment method."""

    payment_method_id: str
    r"""ID of the payment method."""
    payment_method_type: CardPresentPaymentTransferPaymentMethodPaymentMethodType
    terminal_card: NotRequired[TransferTerminalCardTypedDict]
    r"""Describes payment card details captured with tap or in-person payment."""


class CardPresentPaymentTransferPaymentMethod(BaseModel):
    r"""A card used at point of sale terminal for a card present transaction as contained within a payment method."""

    payment_method_id: Annotated[str, pydantic.Field(alias="paymentMethodID")]
    r"""ID of the payment method."""

    payment_method_type: Annotated[
        CardPresentPaymentTransferPaymentMethodPaymentMethodType,
        pydantic.Field(alias="paymentMethodType"),
    ]

    terminal_card: Annotated[
        Optional[TransferTerminalCard], pydantic.Field(alias="terminalCard")
    ] = None
    r"""Describes payment card details captured with tap or in-person payment."""

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