"""paypalserversdk.

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

# ruff: noqa: E501

class StoredPaymentSourcePaymentType(object):
    """Implementation of the 'Stored Payment Source Payment Type' enum.

    Indicates the type of the stored payment_source payment.

    Attributes:
        ONE_TIME: One Time payment such as online purchase or donation. (e.g.
            Checkout with one-click).
        RECURRING: Payment which is part of a series of payments with fixed or
            variable amounts, following a fixed time interval. (e.g. Subscription
            payments).
        UNSCHEDULED: Payment which is part of a series of payments that occur on a
            non-fixed schedule and/or have variable amounts. (e.g. Account Topup
            payments).

    """

    ONE_TIME = "ONE_TIME"

    RECURRING = "RECURRING"

    UNSCHEDULED = "UNSCHEDULED"

    @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
