"""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.payment_method_preference import (
    PaymentMethodPreference,
)
from paypalserversdk.models.stored_payment_source import (
    StoredPaymentSource,
)


class OrderApplicationContext(object):
    """Implementation of the 'Order Application Context' model.

    Customizes the payer experience during the approval process for the payment with
    PayPal. Note: Partners and Marketplaces might configure brand_name and
    shipping_preference during partner account setup, which overrides the request
    values.

    Attributes:
        brand_name (str): DEPRECATED. The label that overrides the business name in
            the PayPal account on the PayPal site. The fields in
            `application_context` are now available in the `experience_context`
            object under the `payment_source` which supports them (eg.
            `payment_source.paypal.experience_context.brand_name`). Please specify
            this field in the `experience_context` object instead of the
            `application_context` object.
        locale (str): DEPRECATED. The BCP 47-formatted locale of pages that the
            PayPal payment experience shows. PayPal supports a five-character code.
            For example, `da-DK`, `he-IL`, `id-ID`, `ja-JP`, `no-NO`, `pt-BR`,
            `ru-RU`, `sv-SE`, `th-TH`, `zh-CN`, `zh-HK`, or `zh-TW`.  The fields in
            `application_context` are now available in the `experience_context`
            object under the `payment_source` which supports them (eg.
            `payment_source.paypal.experience_context.locale`). Please specify this
            field in the `experience_context` object instead of the
            `application_context` object.
        landing_page (OrderApplicationContextLandingPage): DEPRECATED. DEPRECATED.
            The type of landing page to show on the PayPal site for customer
            checkout.  The fields in `application_context` are now available in the
            `experience_context` object under the `payment_source` which supports
            them (eg. `payment_source.paypal.experience_context.landing_page`).
            Please specify this field in the `experience_context` object instead of
            the `application_context` object.
        shipping_preference (OrderApplicationContextShippingPreference): DEPRECATED.
            DEPRECATED. The shipping preference: Displays the shipping address to the
            customer. Enables the customer to choose an address on the PayPal site.
            Restricts the customer from changing the address during the
            payment-approval process. .  The fields in `application_context` are now
            available in the `experience_context` object under the `payment_source`
            which supports them (eg.
            `payment_source.paypal.experience_context.shipping_preference`). Please
            specify this field in the `experience_context` object instead of the
            `application_context` object.
        user_action (OrderApplicationContextUserAction): DEPRECATED. Configures a
            Continue or Pay Now checkout flow.  The fields in `application_context`
            are now available in the `experience_context` object under the
            `payment_source` which supports them (eg.
            `payment_source.paypal.experience_context.user_action`). Please specify
            this field in the `experience_context` object instead of the
            `application_context` object.
        payment_method (PaymentMethodPreference): DEPRECATED. The customer and
            merchant payment preferences. The fields in `application_context` are now
            available in the `experience_context` object under the `payment_source`
            which supports them (eg.
            `payment_source.paypal.experience_context.payment_method_selected`).
            Please specify this field in the `experience_context` object instead of
            the `application_context` object..
        return_url (str): DEPRECATED. The URL where the customer is redirected after
            the customer approves the payment. The fields in `application_context`
            are now available in the `experience_context` object under the
            `payment_source` which supports them (eg.
            `payment_source.paypal.experience_context.return_url`). Please specify
            this field in the `experience_context` object instead of the
            `application_context` object.
        cancel_url (str): DEPRECATED. The URL where the customer is redirected after
            the customer cancels the payment. The fields in `application_context` are
            now available in the `experience_context` object under the
            `payment_source` which supports them (eg.
            `payment_source.paypal.experience_context.cancel_url`). Please specify
            this field in the `experience_context` object instead of the
            `application_context` object.
        stored_payment_source (StoredPaymentSource): DEPRECATED. Provides additional
            details to process a payment using a `payment_source` that has been
            stored or is intended to be stored (also referred to as stored_credential
            or card-on-file). Parameter compatibility: `payment_type=ONE_TIME` is
            compatible only with `payment_initiator=CUSTOMER`. `usage=FIRST` is
            compatible only with `payment_initiator=CUSTOMER`.
            `previous_transaction_reference` or
            `previous_network_transaction_reference` is compatible only with
            `payment_initiator=MERCHANT`. Only one of the parameters -
            `previous_transaction_reference` and
            `previous_network_transaction_reference` - can be present in the request.
            .  The fields in `stored_payment_source` are now available in the
            `stored_credential` object under the `payment_source` which supports them
            (eg. `payment_source.card.stored_credential.payment_initiator`). Please
            specify this field in the `payment_source` object instead of the
            `application_context` object.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "brand_name": "brand_name",
        "locale": "locale",
        "landing_page": "landing_page",
        "shipping_preference": "shipping_preference",
        "user_action": "user_action",
        "payment_method": "payment_method",
        "return_url": "return_url",
        "cancel_url": "cancel_url",
        "stored_payment_source": "stored_payment_source",
    }

    _optionals = [
        "brand_name",
        "locale",
        "landing_page",
        "shipping_preference",
        "user_action",
        "payment_method",
        "return_url",
        "cancel_url",
        "stored_payment_source",
    ]

    def __init__(
        self,
        brand_name=APIHelper.SKIP,
        locale=APIHelper.SKIP,
        landing_page="NO_PREFERENCE",
        shipping_preference="GET_FROM_FILE",
        user_action="CONTINUE",
        payment_method=APIHelper.SKIP,
        return_url=APIHelper.SKIP,
        cancel_url=APIHelper.SKIP,
        stored_payment_source=APIHelper.SKIP):
        """Initialize a OrderApplicationContext instance."""
        # Initialize members of the class
        if brand_name is not APIHelper.SKIP:
            self.brand_name = brand_name
        if locale is not APIHelper.SKIP:
            self.locale = locale
        self.landing_page = landing_page
        self.shipping_preference = shipping_preference
        self.user_action = user_action
        if payment_method is not APIHelper.SKIP:
            self.payment_method = payment_method
        if return_url is not APIHelper.SKIP:
            self.return_url = return_url
        if cancel_url is not APIHelper.SKIP:
            self.cancel_url = cancel_url
        if stored_payment_source is not APIHelper.SKIP:
            self.stored_payment_source = stored_payment_source

    @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
        brand_name =\
            dictionary.get("brand_name")\
            if dictionary.get("brand_name")\
                else APIHelper.SKIP
        locale =\
            dictionary.get("locale")\
            if dictionary.get("locale")\
                else APIHelper.SKIP
        landing_page =\
            dictionary.get("landing_page")\
            if dictionary.get("landing_page")\
                else "NO_PREFERENCE"
        shipping_preference =\
            dictionary.get("shipping_preference")\
            if dictionary.get("shipping_preference")\
                else "GET_FROM_FILE"
        user_action =\
            dictionary.get("user_action")\
            if dictionary.get("user_action")\
                else "CONTINUE"
        payment_method =\
            PaymentMethodPreference.from_dictionary(
                dictionary.get("payment_method"))\
                if "payment_method" in dictionary.keys()\
                else APIHelper.SKIP
        return_url =\
            dictionary.get("return_url")\
            if dictionary.get("return_url")\
                else APIHelper.SKIP
        cancel_url =\
            dictionary.get("cancel_url")\
            if dictionary.get("cancel_url")\
                else APIHelper.SKIP
        stored_payment_source =\
            StoredPaymentSource.from_dictionary(
                dictionary.get("stored_payment_source"))\
                if "stored_payment_source" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(brand_name,
                   locale,
                   landing_page,
                   shipping_preference,
                   user_action,
                   payment_method,
                   return_url,
                   cancel_url,
                   stored_payment_source)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _brand_name=(
            self.brand_name
            if hasattr(self, "brand_name")
            else None
        )
        _locale=(
            self.locale
            if hasattr(self, "locale")
            else None
        )
        _landing_page=(
            self.landing_page
            if hasattr(self, "landing_page")
            else None
        )
        _shipping_preference=(
            self.shipping_preference
            if hasattr(self, "shipping_preference")
            else None
        )
        _user_action=(
            self.user_action
            if hasattr(self, "user_action")
            else None
        )
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _return_url=(
            self.return_url
            if hasattr(self, "return_url")
            else None
        )
        _cancel_url=(
            self.cancel_url
            if hasattr(self, "cancel_url")
            else None
        )
        _stored_payment_source=(
            self.stored_payment_source
            if hasattr(self, "stored_payment_source")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"brand_name={_brand_name!r}, "
            f"locale={_locale!r}, "
            f"landing_page={_landing_page!r}, "
            f"shipping_preference={_shipping_preference!r}, "
            f"user_action={_user_action!r}, "
            f"payment_method={_payment_method!r}, "
            f"return_url={_return_url!r}, "
            f"cancel_url={_cancel_url!r}, "
            f"stored_payment_source={_stored_payment_source!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _brand_name=(
            self.brand_name
            if hasattr(self, "brand_name")
            else None
        )
        _locale=(
            self.locale
            if hasattr(self, "locale")
            else None
        )
        _landing_page=(
            self.landing_page
            if hasattr(self, "landing_page")
            else None
        )
        _shipping_preference=(
            self.shipping_preference
            if hasattr(self, "shipping_preference")
            else None
        )
        _user_action=(
            self.user_action
            if hasattr(self, "user_action")
            else None
        )
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _return_url=(
            self.return_url
            if hasattr(self, "return_url")
            else None
        )
        _cancel_url=(
            self.cancel_url
            if hasattr(self, "cancel_url")
            else None
        )
        _stored_payment_source=(
            self.stored_payment_source
            if hasattr(self, "stored_payment_source")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"brand_name={_brand_name!s}, "
            f"locale={_locale!s}, "
            f"landing_page={_landing_page!s}, "
            f"shipping_preference={_shipping_preference!s}, "
            f"user_action={_user_action!s}, "
            f"payment_method={_payment_method!s}, "
            f"return_url={_return_url!s}, "
            f"cancel_url={_cancel_url!s}, "
            f"stored_payment_source={_stored_payment_source!s}, "
            f")"
        )
