"""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.billing_cycle_override import (
    BillingCycleOverride,
)
from paypalserversdk.models.payment_preferences_override import (
    PaymentPreferencesOverride,
)
from paypalserversdk.models.taxes_override import (
    TaxesOverride,
)


class PlanOverride(object):
    """Implementation of the 'Plan Override' model.

    An inline plan object to customise the subscription. You can override plan level
    default attributes by providing customised values for the subscription in this
    object.

    Attributes:
        billing_cycles (List[BillingCycleOverride]): An array of billing cycles for
            trial billing and regular billing. The subscription billing cycle
            definition has to adhere to the plan billing cycle definition.
        payment_preferences (PaymentPreferencesOverride): The payment preferences to
            override at subscription level.
        taxes (TaxesOverride): The tax details.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "billing_cycles": "billing_cycles",
        "payment_preferences": "payment_preferences",
        "taxes": "taxes",
    }

    _optionals = [
        "billing_cycles",
        "payment_preferences",
        "taxes",
    ]

    def __init__(
        self,
        billing_cycles=APIHelper.SKIP,
        payment_preferences=APIHelper.SKIP,
        taxes=APIHelper.SKIP):
        """Initialize a PlanOverride instance."""
        # Initialize members of the class
        if billing_cycles is not APIHelper.SKIP:
            self.billing_cycles = billing_cycles
        if payment_preferences is not APIHelper.SKIP:
            self.payment_preferences = payment_preferences
        if taxes is not APIHelper.SKIP:
            self.taxes = taxes

    @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
        billing_cycles = None
        if dictionary.get("billing_cycles") is not None:
            billing_cycles = [
                BillingCycleOverride.from_dictionary(x)
                    for x in dictionary.get("billing_cycles")
            ]
        else:
            billing_cycles = APIHelper.SKIP
        payment_preferences =\
            PaymentPreferencesOverride.from_dictionary(
                dictionary.get("payment_preferences"))\
                if "payment_preferences" in dictionary.keys()\
                else APIHelper.SKIP
        taxes =\
            TaxesOverride.from_dictionary(
                dictionary.get("taxes"))\
                if "taxes" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(billing_cycles,
                   payment_preferences,
                   taxes)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _billing_cycles=(
            self.billing_cycles
            if hasattr(self, "billing_cycles")
            else None
        )
        _payment_preferences=(
            self.payment_preferences
            if hasattr(self, "payment_preferences")
            else None
        )
        _taxes=(
            self.taxes
            if hasattr(self, "taxes")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"billing_cycles={_billing_cycles!r}, "
            f"payment_preferences={_payment_preferences!r}, "
            f"taxes={_taxes!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _billing_cycles=(
            self.billing_cycles
            if hasattr(self, "billing_cycles")
            else None
        )
        _payment_preferences=(
            self.payment_preferences
            if hasattr(self, "payment_preferences")
            else None
        )
        _taxes=(
            self.taxes
            if hasattr(self, "taxes")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"billing_cycles={_billing_cycles!s}, "
            f"payment_preferences={_payment_preferences!s}, "
            f"taxes={_taxes!s}, "
            f")"
        )
