"""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.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):
        """Initialize a SubscriptionCollection instance."""
        # 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):
        """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
        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 a unambiguous string representation."""
        _subscriptions=(
            self.subscriptions
            if hasattr(self, "subscriptions")
            else None
        )
        _links=(
            self.links
            if hasattr(self, "links")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"subscriptions={_subscriptions!r}, "
            f"links={_links!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _subscriptions=(
            self.subscriptions
            if hasattr(self, "subscriptions")
            else None
        )
        _links=(
            self.links
            if hasattr(self, "links")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"subscriptions={_subscriptions!s}, "
            f"links={_links!s}, "
            f")"
        )
