# 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_holder_type import AchHolderType
from .ach_sec_code import AchSecCode
from .achaccount import Achaccount
from .achaccounttype import Achaccounttype
from .achrouting import Achrouting
from .device import Device


class PayMethodAch(UniversalBaseModel):
    ach_account: typing_extensions.Annotated[
        Achaccount,
        FieldMetadata(alias="achAccount"),
        pydantic.Field(
            alias="achAccount", description="Bank account number. This field is **required** when method = 'ach'."
        ),
    ]
    ach_account_type: typing_extensions.Annotated[
        typing.Optional[Achaccounttype],
        FieldMetadata(alias="achAccountType"),
        pydantic.Field(
            alias="achAccountType", description="Bank account type. This field is **required** when method = 'ach'."
        ),
    ] = None
    ach_code: typing_extensions.Annotated[
        typing.Optional[AchSecCode], FieldMetadata(alias="achCode"), pydantic.Field(alias="achCode")
    ] = None
    ach_holder: typing_extensions.Annotated[
        AchHolder, FieldMetadata(alias="achHolder"), pydantic.Field(alias="achHolder")
    ]
    ach_holder_type: typing_extensions.Annotated[
        typing.Optional[AchHolderType], FieldMetadata(alias="achHolderType"), pydantic.Field(alias="achHolderType")
    ] = None
    ach_routing: typing_extensions.Annotated[
        Achrouting,
        FieldMetadata(alias="achRouting"),
        pydantic.Field(
            alias="achRouting",
            description="ABA/routing number of bank account. This field is **required** when method = 'ach'.",
        ),
    ]
    device: typing.Optional[Device] = None
    method: typing.Literal["ach"] = "ach"

    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
