# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.link_description import LinkDescription
from paypalserversdk.models.money import Money
from paypalserversdk.models.plan_override import PlanOverride
from paypalserversdk.models.shipping_details import ShippingDetails


class ModifySubscriptionResponse(object):

    """Implementation of the 'Modify Subscription Response' model.

    The response to a request to update the quantity of the product or service
    in a subscription. You can also use this method to switch the plan and
    update the `shipping_amount` and `shipping_address` values for the
    subscription. This type of update requires the buyer's consent.

    Attributes:
        plan_id (str): The unique PayPal-generated ID for the plan.
        quantity (str): The quantity of the product or service in the
            subscription.
        shipping_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        shipping_address (ShippingDetails): The shipping details.
        plan (PlanOverride): 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.
        plan_overridden (bool): Indicates whether the subscription has
            overridden any plan attributes.
        links (List[LinkDescription]): An array of request-related [HATEOAS
            links](/docs/api/reference/api-responses/#hateoas-links).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "plan_id": 'plan_id',
        "quantity": 'quantity',
        "shipping_amount": 'shipping_amount',
        "shipping_address": 'shipping_address',
        "plan": 'plan',
        "plan_overridden": 'plan_overridden',
        "links": 'links'
    }

    _optionals = [
        'plan_id',
        'quantity',
        'shipping_amount',
        'shipping_address',
        'plan',
        'plan_overridden',
        'links',
    ]

    def __init__(self,
                 plan_id=APIHelper.SKIP,
                 quantity=APIHelper.SKIP,
                 shipping_amount=APIHelper.SKIP,
                 shipping_address=APIHelper.SKIP,
                 plan=APIHelper.SKIP,
                 plan_overridden=APIHelper.SKIP,
                 links=APIHelper.SKIP):
        """Constructor for the ModifySubscriptionResponse class"""

        # Initialize members of the class
        if plan_id is not APIHelper.SKIP:
            self.plan_id = plan_id 
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity 
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount 
        if shipping_address is not APIHelper.SKIP:
            self.shipping_address = shipping_address 
        if plan is not APIHelper.SKIP:
            self.plan = plan 
        if plan_overridden is not APIHelper.SKIP:
            self.plan_overridden = plan_overridden 
        if links is not APIHelper.SKIP:
            self.links = links 

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates 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
        plan_id = dictionary.get("plan_id") if dictionary.get("plan_id") else APIHelper.SKIP
        quantity = dictionary.get("quantity") if dictionary.get("quantity") else APIHelper.SKIP
        shipping_amount = Money.from_dictionary(dictionary.get('shipping_amount')) if 'shipping_amount' in dictionary.keys() else APIHelper.SKIP
        shipping_address = ShippingDetails.from_dictionary(dictionary.get('shipping_address')) if 'shipping_address' in dictionary.keys() else APIHelper.SKIP
        plan = PlanOverride.from_dictionary(dictionary.get('plan')) if 'plan' in dictionary.keys() else APIHelper.SKIP
        plan_overridden = dictionary.get("plan_overridden") if "plan_overridden" in dictionary.keys() else APIHelper.SKIP
        links = None
        if dictionary.get('links') is not None:
            links = [LinkDescription.from_dictionary(x) for x in dictionary.get('links')]
        else:
            links = APIHelper.SKIP
        # Return an object of this model
        return cls(plan_id,
                   quantity,
                   shipping_amount,
                   shipping_address,
                   plan,
                   plan_overridden,
                   links)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'plan_id={(self.plan_id if hasattr(self, "plan_id") else None)!r}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!r}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!r}, '
                f'shipping_address={(self.shipping_address if hasattr(self, "shipping_address") else None)!r}, '
                f'plan={(self.plan if hasattr(self, "plan") else None)!r}, '
                f'plan_overridden={(self.plan_overridden if hasattr(self, "plan_overridden") else None)!r}, '
                f'links={(self.links if hasattr(self, "links") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'plan_id={(self.plan_id if hasattr(self, "plan_id") else None)!s}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!s}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!s}, '
                f'shipping_address={(self.shipping_address if hasattr(self, "shipping_address") else None)!s}, '
                f'plan={(self.plan if hasattr(self, "plan") else None)!s}, '
                f'plan_overridden={(self.plan_overridden if hasattr(self, "plan_overridden") else None)!s}, '
                f'links={(self.links if hasattr(self, "links") else None)!s})')
