# 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 .account_id import AccountId
from .account_number import AccountNumber
from .bank_account_function import BankAccountFunction
from .bank_account_holder_name import BankAccountHolderName
from .bank_account_holder_type import BankAccountHolderType
from .bank_name import BankName
from .bank_nickname import BankNickname
from .routing_account import RoutingAccount
from .type_account import TypeAccount


class Bank(UniversalBaseModel):
    """
    Object that contains bank account details.
    """

    id: typing.Optional[int] = pydantic.Field(default=None)
    """
    The Payabli-assigned internal identifier for the bank account.
    """

    account_id: typing_extensions.Annotated[
        typing.Optional[AccountId],
        FieldMetadata(alias="accountId"),
        pydantic.Field(
            alias="accountId",
            description="An identifier for the bank account, used to specify which account handles payments when multiple accounts are configured. If not provided during creation or update, the system generates one in the format `acct-{first_digit}xxxxx{last_4_digits}` based on the account number. The mask always uses five `x` characters regardless of account number length. For example, account number `123456789` produces `acct-1xxxxx6789`. If a duplicate exists within the same service at the paypoint, a numeric suffix is appended, such as `acct-1xxxxx6789-2`. This value is also used as the identifier for the bank account's associated payment connector.",
        ),
    ] = None
    nickname: typing.Optional[BankNickname] = None
    bank_name: typing_extensions.Annotated[
        typing.Optional[BankName], FieldMetadata(alias="bankName"), pydantic.Field(alias="bankName")
    ] = None
    routing_account: typing_extensions.Annotated[
        typing.Optional[RoutingAccount], FieldMetadata(alias="routingAccount"), pydantic.Field(alias="routingAccount")
    ] = None
    account_number: typing_extensions.Annotated[
        typing.Optional[AccountNumber], FieldMetadata(alias="accountNumber"), pydantic.Field(alias="accountNumber")
    ] = None
    type_account: typing_extensions.Annotated[
        typing.Optional[TypeAccount], FieldMetadata(alias="typeAccount"), pydantic.Field(alias="typeAccount")
    ] = None
    bank_account_holder_name: typing_extensions.Annotated[
        typing.Optional[BankAccountHolderName],
        FieldMetadata(alias="bankAccountHolderName"),
        pydantic.Field(alias="bankAccountHolderName"),
    ] = None
    bank_account_holder_type: typing_extensions.Annotated[
        typing.Optional[BankAccountHolderType],
        FieldMetadata(alias="bankAccountHolderType"),
        pydantic.Field(alias="bankAccountHolderType"),
    ] = None
    bank_account_function: typing_extensions.Annotated[
        typing.Optional[BankAccountFunction],
        FieldMetadata(alias="bankAccountFunction"),
        pydantic.Field(alias="bankAccountFunction"),
    ] = None
    verified: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Bank account verification status. When `true`, the account has been verified to exist and be in good standing based on vendor checks or previous processing histories.
    """

    status: typing.Optional[int] = pydantic.Field(default=None)
    """
    Bank account status
    """

    services: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Array of services associated with this bank account
    """

    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
