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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

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


class QueueObject(object):

    """Implementation of the 'QueueObject' model.

    Attributes:
        currently_playing (TrackObject | EpisodeObject | None): The currently
            playing track or episode. Can be `null`.
        queue (List[TrackObject | EpisodeObject] | None): The tracks or
            episodes in the queue. Can be empty.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "currently_playing": 'currently_playing',
        "queue": 'queue'
    }

    _optionals = [
        'currently_playing',
        'queue',
    ]

    def __init__(self,
                 currently_playing=APIHelper.SKIP,
                 queue=APIHelper.SKIP):
        """Constructor for the QueueObject class"""

        # Initialize members of the class
        if currently_playing is not APIHelper.SKIP:
            self.currently_playing = currently_playing 
        if queue is not APIHelper.SKIP:
            self.queue = queue 

    @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.

        """
        from spotifywebapiwithfixesandimprovementsfromsonallux.utilities.union_type_lookup import UnionTypeLookUp

        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        currently_playing = APIHelper.deserialize_union_type(UnionTypeLookUp.get('QueueObjectCurrentlyPlaying'), dictionary.get('currently_playing'), False) if dictionary.get('currently_playing') is not None else APIHelper.SKIP
        queue = APIHelper.deserialize_union_type(UnionTypeLookUp.get('QueueObjectQueue'), dictionary.get('queue'), False) if dictionary.get('queue') is not None else APIHelper.SKIP
        # Return an object of this model
        return cls(currently_playing,
                   queue)

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

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