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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from spotifywebapiwithfixesandimprovementsfromsonallux.api_helper import APIHelper
from spotifywebapiwithfixesandimprovementsfromsonallux.models.context_object import ContextObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.device_object import DeviceObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.disallows_object import DisallowsObject


class CurrentlyPlayingContextObject(object):

    """Implementation of the 'CurrentlyPlayingContextObject' model.

    Attributes:
        device (DeviceObject): The device that is currently active.
        repeat_state (str): off, track, context
        shuffle_state (bool): If shuffle is on or off.
        context (ContextObject): A Context Object. Can be `null`.
        timestamp (int): Unix Millisecond Timestamp when data was fetched.
        progress_ms (int): Progress into the currently playing track or
            episode. Can be `null`.
        is_playing (bool): If something is currently playing, return `true`.
        item (TrackObject | EpisodeObject | None): The currently playing track
            or episode. Can be `null`.
        currently_playing_type (str): The object type of the currently playing
            item. Can be one of `track`, `episode`, `ad` or `unknown`.
        actions (DisallowsObject): Allows to update the user interface based
            on which playback actions are available within the current context.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "device": 'device',
        "repeat_state": 'repeat_state',
        "shuffle_state": 'shuffle_state',
        "context": 'context',
        "timestamp": 'timestamp',
        "progress_ms": 'progress_ms',
        "is_playing": 'is_playing',
        "item": 'item',
        "currently_playing_type": 'currently_playing_type',
        "actions": 'actions'
    }

    _optionals = [
        'device',
        'repeat_state',
        'shuffle_state',
        'context',
        'timestamp',
        'progress_ms',
        'is_playing',
        'item',
        'currently_playing_type',
        'actions',
    ]

    def __init__(self,
                 device=APIHelper.SKIP,
                 repeat_state=APIHelper.SKIP,
                 shuffle_state=APIHelper.SKIP,
                 context=APIHelper.SKIP,
                 timestamp=APIHelper.SKIP,
                 progress_ms=APIHelper.SKIP,
                 is_playing=APIHelper.SKIP,
                 item=APIHelper.SKIP,
                 currently_playing_type=APIHelper.SKIP,
                 actions=APIHelper.SKIP):
        """Constructor for the CurrentlyPlayingContextObject class"""

        # Initialize members of the class
        if device is not APIHelper.SKIP:
            self.device = device 
        if repeat_state is not APIHelper.SKIP:
            self.repeat_state = repeat_state 
        if shuffle_state is not APIHelper.SKIP:
            self.shuffle_state = shuffle_state 
        if context is not APIHelper.SKIP:
            self.context = context 
        if timestamp is not APIHelper.SKIP:
            self.timestamp = timestamp 
        if progress_ms is not APIHelper.SKIP:
            self.progress_ms = progress_ms 
        if is_playing is not APIHelper.SKIP:
            self.is_playing = is_playing 
        if item is not APIHelper.SKIP:
            self.item = item 
        if currently_playing_type is not APIHelper.SKIP:
            self.currently_playing_type = currently_playing_type 
        if actions is not APIHelper.SKIP:
            self.actions = actions 

    @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
        device = DeviceObject.from_dictionary(dictionary.get('device')) if 'device' in dictionary.keys() else APIHelper.SKIP
        repeat_state = dictionary.get("repeat_state") if dictionary.get("repeat_state") else APIHelper.SKIP
        shuffle_state = dictionary.get("shuffle_state") if "shuffle_state" in dictionary.keys() else APIHelper.SKIP
        context = ContextObject.from_dictionary(dictionary.get('context')) if 'context' in dictionary.keys() else APIHelper.SKIP
        timestamp = dictionary.get("timestamp") if dictionary.get("timestamp") else APIHelper.SKIP
        progress_ms = dictionary.get("progress_ms") if dictionary.get("progress_ms") else APIHelper.SKIP
        is_playing = dictionary.get("is_playing") if "is_playing" in dictionary.keys() else APIHelper.SKIP
        item = APIHelper.deserialize_union_type(UnionTypeLookUp.get('CurrentlyPlayingContextObjectItem'), dictionary.get('item'), False) if dictionary.get('item') is not None else APIHelper.SKIP
        currently_playing_type = dictionary.get("currently_playing_type") if dictionary.get("currently_playing_type") else APIHelper.SKIP
        actions = DisallowsObject.from_dictionary(dictionary.get('actions')) if 'actions' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(device,
                   repeat_state,
                   shuffle_state,
                   context,
                   timestamp,
                   progress_ms,
                   is_playing,
                   item,
                   currently_playing_type,
                   actions)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'device={(self.device if hasattr(self, "device") else None)!r}, '
                f'repeat_state={(self.repeat_state if hasattr(self, "repeat_state") else None)!r}, '
                f'shuffle_state={(self.shuffle_state if hasattr(self, "shuffle_state") else None)!r}, '
                f'context={(self.context if hasattr(self, "context") else None)!r}, '
                f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!r}, '
                f'progress_ms={(self.progress_ms if hasattr(self, "progress_ms") else None)!r}, '
                f'is_playing={(self.is_playing if hasattr(self, "is_playing") else None)!r}, '
                f'item={(self.item if hasattr(self, "item") else None)!r}, '
                f'currently_playing_type={(self.currently_playing_type if hasattr(self, "currently_playing_type") else None)!r}, '
                f'actions={(self.actions if hasattr(self, "actions") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'device={(self.device if hasattr(self, "device") else None)!s}, '
                f'repeat_state={(self.repeat_state if hasattr(self, "repeat_state") else None)!s}, '
                f'shuffle_state={(self.shuffle_state if hasattr(self, "shuffle_state") else None)!s}, '
                f'context={(self.context if hasattr(self, "context") else None)!s}, '
                f'timestamp={(self.timestamp if hasattr(self, "timestamp") else None)!s}, '
                f'progress_ms={(self.progress_ms if hasattr(self, "progress_ms") else None)!s}, '
                f'is_playing={(self.is_playing if hasattr(self, "is_playing") else None)!s}, '
                f'item={(self.item if hasattr(self, "item") else None)!s}, '
                f'currently_playing_type={(self.currently_playing_type if hasattr(self, "currently_playing_type") else None)!s}, '
                f'actions={(self.actions if hasattr(self, "actions") else None)!s})')
