# -*- 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.subscription import Subscription


class SubscriptionCollection(object):

    """Implementation of the 'Subscription Collection' model.

    The list of subscriptions.

    Attributes:
        subscriptions (List[Subscription]): An array of subscriptions.
        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 = {
        "subscriptions": 'subscriptions',
        "links": 'links'
    }

    _optionals = [
        'subscriptions',
        'links',
    ]

    def __init__(self,
                 subscriptions=APIHelper.SKIP,
                 links=APIHelper.SKIP):
        """Constructor for the SubscriptionCollection class"""

        # Initialize members of the class
        if subscriptions is not APIHelper.SKIP:
            self.subscriptions = subscriptions 
        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
        subscriptions = None
        if dictionary.get('subscriptions') is not None:
            subscriptions = [Subscription.from_dictionary(x) for x in dictionary.get('subscriptions')]
        else:
            subscriptions = 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(subscriptions,
                   links)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'subscriptions={(self.subscriptions if hasattr(self, "subscriptions") else None)!r}, '
                f'links={(self.links if hasattr(self, "links") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'subscriptions={(self.subscriptions if hasattr(self, "subscriptions") else None)!s}, '
                f'links={(self.links if hasattr(self, "links") else None)!s})')
