# 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


class BinData(UniversalBaseModel):
    """
    Object containing information related to the card. This object is `null`
    unless the payment method is card. If the payment method is Apple Pay, the
    binData will be related to the DPAN (device primary account number), not
    the card connected to Apple Pay.

    Examples
    --------
    from payabli import BinData

    BinData(
        bin_matched_length="6",
        bin_card_brand="Visa",
        bin_card_type="Credit",
        bin_card_category="PLATINUM",
        bin_card_issuer="Bank of Example",
        bin_card_issuer_country="United States",
        bin_card_issuer_country_code_a_2="US",
        bin_card_issuer_country_number="840",
        bin_card_is_regulated="false",
        bin_card_use_category="Consumer",
        bin_card_issuer_country_code_a_3="USA",
    )
    """

    bin_matched_length: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="binMatchedLength")] = (
        pydantic.Field(default=None)
    )
    """
    The number of characters from the beginning of the card number that
    were matched against a Bank Identification Number (BIN) or the Card
    Range table.
    """

    bin_card_brand: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="binCardBrand")] = (
        pydantic.Field(default=None)
    )
    """
    The card brand. For example, Visa, Mastercard, American Express,
    Discover.
    """

    bin_card_type: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="binCardType")] = (
        pydantic.Field(default=None)
    )
    """
    The type of card: Credit or Debit.
    """

    bin_card_category: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="binCardCategory")] = (
        pydantic.Field(default=None)
    )
    """
    The category of the card, which indicates the card product. For example: Standard, Gold, Platinum, etc. The binCardCategory for prepaid cards is marked `PREPAID`.
    """

    bin_card_issuer: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="binCardIssuer")] = (
        pydantic.Field(default=None)
    )
    """
    The name of the financial institution that issued the card.
    """

    bin_card_issuer_country: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardIssuerCountry")
    ] = pydantic.Field(default=None)
    """
    The issuing financial institution's country name.
    """

    bin_card_issuer_country_code_a_2: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardIssuerCountryCodeA2")
    ] = pydantic.Field(default=None)
    """
    The issuing financial institution's two-character ISO country code. See [this resource](https://www.iso.org/obp/ui/#search) for a list of codes.
    """

    bin_card_issuer_country_number: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardIssuerCountryNumber")
    ] = pydantic.Field(default=None)
    """
    The issuing financial institution's ISO standard numeric country code. See [this resource](https://www.iso.org/obp/ui/#search) for a list of codes.
    """

    bin_card_is_regulated: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardIsRegulated")
    ] = pydantic.Field(default=None)
    """
    Indicates whether the card is regulated.
    """

    bin_card_use_category: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardUseCategory")
    ] = pydantic.Field(default=None)
    """
    The use category classification for the card.
    """

    bin_card_issuer_country_code_a_3: typing_extensions.Annotated[
        typing.Optional[str], FieldMetadata(alias="binCardIssuerCountryCodeA3")
    ] = pydantic.Field(default=None)
    """
    The issuing financial institution's three-character ISO country code.
    See [this resource](https://www.iso.org/obp/ui/#search) for a list of
    codes.
    """

    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
