"""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.platform_fee import (
    PlatformFee,
)


class CapturePaymentInstruction(object):
    """Implementation of the 'Capture Payment Instruction' model.

    Any additional payment instructions to be consider during payment processing.
    This processing instruction is applicable for Capturing an order or Authorizing
    an Order.

    Attributes:
        platform_fees (List[PlatformFee]): An array of platform or partner fees,
            commissions, or brokerage fees that associated with the captured payment.
        disbursement_mode (DisbursementMode): The funds that are held on behalf of
            the merchant.
        payee_receivable_fx_rate_id (str): FX identifier generated returned by PayPal
            to be used for payment processing in order to honor FX rate (for eligible
            integrations) to be used when amount is settled/received into the payee
            account.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "platform_fees": "platform_fees",
        "disbursement_mode": "disbursement_mode",
        "payee_receivable_fx_rate_id": "payee_receivable_fx_rate_id",
    }

    _optionals = [
        "platform_fees",
        "disbursement_mode",
        "payee_receivable_fx_rate_id",
    ]

    def __init__(
        self,
        platform_fees=APIHelper.SKIP,
        disbursement_mode="INSTANT",
        payee_receivable_fx_rate_id=APIHelper.SKIP):
        """Initialize a CapturePaymentInstruction instance."""
        # Initialize members of the class
        if platform_fees is not APIHelper.SKIP:
            self.platform_fees = platform_fees
        self.disbursement_mode = disbursement_mode
        if payee_receivable_fx_rate_id is not APIHelper.SKIP:
            self.payee_receivable_fx_rate_id = payee_receivable_fx_rate_id

    @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
        platform_fees = None
        if dictionary.get("platform_fees") is not None:
            platform_fees = [
                PlatformFee.from_dictionary(x)
                    for x in dictionary.get("platform_fees")
            ]
        else:
            platform_fees = APIHelper.SKIP
        disbursement_mode =\
            dictionary.get("disbursement_mode")\
            if dictionary.get("disbursement_mode")\
                else "INSTANT"
        payee_receivable_fx_rate_id =\
            dictionary.get("payee_receivable_fx_rate_id")\
            if dictionary.get("payee_receivable_fx_rate_id")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(platform_fees,
                   disbursement_mode,
                   payee_receivable_fx_rate_id)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _platform_fees=(
            self.platform_fees
            if hasattr(self, "platform_fees")
            else None
        )
        _disbursement_mode=(
            self.disbursement_mode
            if hasattr(self, "disbursement_mode")
            else None
        )
        _payee_receivable_fx_rate_id=(
            self.payee_receivable_fx_rate_id
            if hasattr(self, "payee_receivable_fx_rate_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"platform_fees={_platform_fees!r}, "
            f"disbursement_mode={_disbursement_mode!r}, "
            f"payee_receivable_fx_rate_id={_payee_receivable_fx_rate_id!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _platform_fees=(
            self.platform_fees
            if hasattr(self, "platform_fees")
            else None
        )
        _disbursement_mode=(
            self.disbursement_mode
            if hasattr(self, "disbursement_mode")
            else None
        )
        _payee_receivable_fx_rate_id=(
            self.payee_receivable_fx_rate_id
            if hasattr(self, "payee_receivable_fx_rate_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"platform_fees={_platform_fees!s}, "
            f"disbursement_mode={_disbursement_mode!s}, "
            f"payee_receivable_fx_rate_id={_payee_receivable_fx_rate_id!s}, "
            f")"
        )
