# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .ach_holder import AchHolder
from .ach_sec_code import AchSecCode
from .achaccount import Achaccount
from .achaccounttype import Achaccounttype
from .achrouting import Achrouting
from .cardcvv import Cardcvv
from .cardexp import Cardexp
from .cardholder import Cardholder
from .cardnumber import Cardnumber
from .cardzip import Cardzip
from .device import Device
from .initiator import Initiator
from .methodall import Methodall
from .save_if_success import SaveIfSuccess
from .stored_method_usage_type import StoredMethodUsageType
from .storedmethodid import Storedmethodid


class PayMethodBodyAllFields(UniversalBaseModel):
    """
    Model for the PaymentMethod object, includes all method types.
    """

    ach_account: typing_extensions.Annotated[Achaccount, FieldMetadata(alias="achAccount")] = pydantic.Field()
    """
    Bank account number. This field is **required** when method = 'ach'.
    """

    ach_account_type: typing_extensions.Annotated[
        typing.Optional[Achaccounttype], FieldMetadata(alias="achAccountType")
    ] = None
    ach_code: typing_extensions.Annotated[typing.Optional[AchSecCode], FieldMetadata(alias="achCode")] = None
    ach_holder: typing_extensions.Annotated[AchHolder, FieldMetadata(alias="achHolder")]
    ach_routing: typing_extensions.Annotated[Achrouting, FieldMetadata(alias="achRouting")] = pydantic.Field()
    """
    ABA/routing number of Bank account. This field is **required** when method = 'ach'.
    """

    cardcvv: typing.Optional[Cardcvv] = None
    cardexp: typing.Optional[Cardexp] = None
    card_holder: typing_extensions.Annotated[typing.Optional[Cardholder], FieldMetadata(alias="cardHolder")] = None
    cardnumber: typing.Optional[Cardnumber] = None
    cardzip: typing.Optional[Cardzip] = None
    device: typing.Optional[Device] = None
    initator: typing.Optional[Initiator] = None
    method: typing.Optional[Methodall] = None
    save_if_success: typing_extensions.Annotated[
        typing.Optional[SaveIfSuccess], FieldMetadata(alias="saveIfSuccess")
    ] = None
    stored_method_id: typing_extensions.Annotated[
        typing.Optional[Storedmethodid], FieldMetadata(alias="storedMethodId")
    ] = None
    stored_method_usage_type: typing_extensions.Annotated[
        typing.Optional[StoredMethodUsageType], FieldMetadata(alias="storedMethodUsageType")
    ] = None

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
