"""cellpointapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501

class PaymentField(object):
    """Implementation of the 'PaymentField' enum.

    Possible fields required for payment methods.

    Attributes:
        CARDHOLDER_FULL_NAME: The enum member of type str.
        CARD_NUMBER: The enum member of type str.
        CARD_SECURITY_CODE: The enum member of type str.
        CARD_EXPIRY: The enum member of type str.
        ADDRESS_STREET: The enum member of type str.
        ADDRESS_OFFICE_BOX_NUMBER: The enum member of type str.
        ADDRESS_LOCALITY: The enum member of type str.
        ADDRESS_REGION: The enum member of type str.
        ADDRESS_POSTAL_CODE: The enum member of type str.
        ADDRESS_COUNTRY: The enum member of type str.

    """

    CARDHOLDER_FULL_NAME = "CARDHOLDER_FULL_NAME"

    CARD_NUMBER = "CARD_NUMBER"

    CARD_SECURITY_CODE = "CARD_SECURITY_CODE"

    CARD_EXPIRY = "CARD_EXPIRY"

    ADDRESS_STREET = "ADDRESS_STREET"

    ADDRESS_OFFICE_BOX_NUMBER = "ADDRESS_OFFICE_BOX_NUMBER"

    ADDRESS_LOCALITY = "ADDRESS_LOCALITY"

    ADDRESS_REGION = "ADDRESS_REGION"

    ADDRESS_POSTAL_CODE = "ADDRESS_POSTAL_CODE"

    ADDRESS_COUNTRY = "ADDRESS_COUNTRY"

    @classmethod
    def from_value(cls, value, default=None):
        """Return the matching enum value for the given input."""
        if value is None:
            return default

        # If numeric and matches directly
        if isinstance(value, int):
            for name, val in cls.__dict__.items():
                if not name.startswith("_") and val == value:
                    return val

        # If string, perform case-insensitive match
        if isinstance(value, str):
            value_lower = value.lower()
            for name, val in cls.__dict__.items():
                if not name.startswith("_") and (
                    name.lower() == value_lower or str(val).lower() == value_lower
                ):
                    return val

        # Fallback to default
        return default
