"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.order_confirm_application_context import (
    OrderConfirmApplicationContext,
)
from paypalserversdk.models.payment_source import (
    PaymentSource,
)


class ConfirmOrderRequest(object):
    """Implementation of the 'Confirm Order Request' model.

    Payer confirms the intent to pay for the Order using the provided payment source.

    Attributes:
        payment_source (PaymentSource): The payment source definition.
        application_context (OrderConfirmApplicationContext): Customizes the payer
            confirmation experience.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "payment_source": "payment_source",
        "application_context": "application_context",
    }

    _optionals = [
        "application_context",
    ]

    def __init__(
        self,
        payment_source=None,
        application_context=APIHelper.SKIP):
        """Initialize a ConfirmOrderRequest instance."""
        # Initialize members of the class
        self.payment_source = payment_source
        if application_context is not APIHelper.SKIP:
            self.application_context = application_context

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        payment_source =\
            PaymentSource.from_dictionary(
                dictionary.get("payment_source"))\
                if dictionary.get("payment_source") else None
        application_context =\
            OrderConfirmApplicationContext.from_dictionary(
                dictionary.get("application_context"))\
                if "application_context" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(payment_source,
                   application_context)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _payment_source=self.payment_source
        _application_context=(
            self.application_context
            if hasattr(self, "application_context")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"payment_source={_payment_source!r}, "
            f"application_context={_application_context!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _payment_source=self.payment_source
        _application_context=(
            self.application_context
            if hasattr(self, "application_context")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"payment_source={_payment_source!s}, "
            f"application_context={_application_context!s}, "
            f")"
        )
