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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from spotifywebapiwithfixesandimprovementsfromsonallux.models.saved_audiobook_object import SavedAudiobookObject


class PagingSavedAudiobookObject(object):

    """Implementation of the 'PagingSavedAudiobookObject' model.

    Attributes:
        href (str): A link to the Web API endpoint returning the full result
            of the request
        limit (int): The maximum number of items in the response (as set in
            the query or by default).
        next (str): URL to the next page of items. ( `null` if none)
        offset (int): The offset of the items returned (as set in the query or
            by default)
        previous (str): URL to the previous page of items. ( `null` if none)
        total (int): The total number of items available to return.
        items (List[SavedAudiobookObject]): The model property of type
            List[SavedAudiobookObject].

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "href": 'href',
        "limit": 'limit',
        "next": 'next',
        "offset": 'offset',
        "previous": 'previous',
        "total": 'total',
        "items": 'items'
    }

    _nullables = [
        'next',
        'previous',
    ]

    def __init__(self,
                 href=None,
                 limit=None,
                 next=None,
                 offset=None,
                 previous=None,
                 total=None,
                 items=None):
        """Constructor for the PagingSavedAudiobookObject class"""

        # Initialize members of the class
        self.href = href 
        self.limit = limit 
        self.next = next 
        self.offset = offset 
        self.previous = previous 
        self.total = total 
        self.items = items 

    @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
        href = dictionary.get("href") if dictionary.get("href") else None
        limit = dictionary.get("limit") if dictionary.get("limit") else None
        next = dictionary.get("next") if dictionary.get("next") else None
        offset = dictionary.get("offset") if dictionary.get("offset") else None
        previous = dictionary.get("previous") if dictionary.get("previous") else None
        total = dictionary.get("total") if dictionary.get("total") else None
        items = None
        if dictionary.get('items') is not None:
            items = [SavedAudiobookObject.from_dictionary(x) for x in dictionary.get('items')]
        # Return an object of this model
        return cls(href,
                   limit,
                   next,
                   offset,
                   previous,
                   total,
                   items)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'href={self.href!r}, '
                f'limit={self.limit!r}, '
                f'next={self.next!r}, '
                f'offset={self.offset!r}, '
                f'previous={self.previous!r}, '
                f'total={self.total!r}, '
                f'items={self.items!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'href={self.href!s}, '
                f'limit={self.limit!s}, '
                f'next={self.next!s}, '
                f'offset={self.offset!s}, '
                f'previous={self.previous!s}, '
                f'total={self.total!s}, '
                f'items={self.items!s})')
