"""paypalserversdk.

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

# ruff: noqa: E501

class OrderStatus(object):
    """Implementation of the 'Order Status' enum.

    The order status.

    Attributes:
        CREATED: The order was created with the specified context.
        SAVED: The order was saved and persisted. The order status continues to be in
            progress until a capture is made with final_capture = true for all
            purchase units within the order.
        APPROVED: The customer approved the payment through the PayPal wallet or
            another form of guest or unbranded payment. For example, a card, bank
            account, or so on.
        VOIDED: All purchase units in the order are voided.
        COMPLETED: The intent of the order was completed and a `payments` resource
            was created. Important: Check the payment status in
            `purchase_units[].payments.captures[].status` before fulfilling the
            order. A completed order can indicate a payment was authorized, an
            authorized payment was captured, or a payment was declined.
        PAYER_ACTION_REQUIRED: The order requires an action from the payer (e.g. 3DS
            authentication). Redirect the payer to the "rel":"payer-action" HATEOAS
            link returned as part of the response prior to authorizing or capturing
            the order. Some payment sources may not return a payer-action HATEOAS
            link (eg. MB WAY). For these payment sources the payer-action is managed
            by the scheme itself (eg. through SMS, email, in-app notification, etc).

    """

    CREATED = "CREATED"

    SAVED = "SAVED"

    APPROVED = "APPROVED"

    VOIDED = "VOIDED"

    COMPLETED = "COMPLETED"

    PAYER_ACTION_REQUIRED = "PAYER_ACTION_REQUIRED"

    @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
