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

import datetime as dt
import typing

import pydantic
import typing_extensions
from ...core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ...core.serialization import FieldMetadata
from ...types.ach_holder_type import AchHolderType
from ...types.ach_sec_code import AchSecCode
from ...types.bin_data import BinData
from ...types.descriptor import Descriptor
from ...types.holdername import Holdername
from ...types.maskedaccount import Maskedaccount
from .get_method_response_response_data_customers_item import GetMethodResponseResponseDataCustomersItem
from .get_method_response_response_data_vendors_item import GetMethodResponseResponseDataVendorsItem


class GetMethodResponseResponseData(UniversalBaseModel):
    aba: typing.Optional[str] = pydantic.Field(default=None)
    """
    Bank routing number
    """

    ach_holder_type: typing_extensions.Annotated[
        typing.Optional[AchHolderType], FieldMetadata(alias="achHolderType"), pydantic.Field(alias="achHolderType")
    ] = None
    ach_sec_code: typing_extensions.Annotated[
        typing.Optional[AchSecCode], FieldMetadata(alias="achSecCode"), pydantic.Field(alias="achSecCode")
    ] = None
    bin: typing.Optional[str] = pydantic.Field(default=None)
    """
    The bank identification number (BIN)
    """

    bin_data: typing_extensions.Annotated[
        typing.Optional[BinData], FieldMetadata(alias="binData"), pydantic.Field(alias="binData")
    ] = None
    card_updated_on: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="cardUpdatedOn"),
        pydantic.Field(alias="cardUpdatedOn", description="Timestamp for when card was last updated"),
    ] = None
    customers: typing.Optional[typing.List[GetMethodResponseResponseDataCustomersItem]] = None
    descriptor: typing.Optional[Descriptor] = None
    exp_date: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="expDate"),
        pydantic.Field(alias="expDate", description="Expiration date for card in stored method in format MM/YY"),
    ] = None
    holder_name: typing_extensions.Annotated[
        typing.Optional[Holdername],
        FieldMetadata(alias="holderName"),
        pydantic.Field(alias="holderName", description="Account holder name in stored method"),
    ] = None
    id_pmethod: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="idPmethod"),
        pydantic.Field(alias="idPmethod", description="The stored payment method's identifier in Payabli"),
    ] = None
    is_validated_ach: typing_extensions.Annotated[
        typing.Optional[bool],
        FieldMetadata(alias="isValidatedACH"),
        pydantic.Field(alias="isValidatedACH", description="Whether the ACH account has been validated"),
    ] = None
    last_updated: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="lastUpdated"),
        pydantic.Field(alias="lastUpdated", description="Timestamp for last update of stored method, in UTC"),
    ] = None
    masked_account: typing_extensions.Annotated[
        typing.Optional[Maskedaccount], FieldMetadata(alias="maskedAccount"), pydantic.Field(alias="maskedAccount")
    ] = None
    method: typing.Optional[str] = pydantic.Field(default=None)
    """
    The saved method's type: `card` or `ach`.
    """

    method_type: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="methodType"),
        pydantic.Field(alias="methodType", description="The payment method's token type"),
    ] = None
    postal_code: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="postalCode"),
        pydantic.Field(alias="postalCode", description="The payment method postal code"),
    ] = None
    vendors: typing.Optional[typing.List[GetMethodResponseResponseDataVendorsItem]] = 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
