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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

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


class DeviceObject(object):

    """Implementation of the 'DeviceObject' model.

    Attributes:
        id (str): The device ID. This ID is unique and persistent to some
            extent. However, this is not guaranteed and any cached `device_id`
            should periodically be cleared out and refetched as necessary.
        is_active (bool): If this device is the currently active device.
        is_private_session (bool): If this device is currently in a private
            session.
        is_restricted (bool): Whether controlling this device is restricted.
            At present if this is "true" then no Web API commands will be
            accepted by this device.
        name (str): A human-readable name for the device. Some devices have a
            name that the user can configure (e.g. \"Loudest speaker\") and
            some devices have a generic name associated with the manufacturer
            or device model.
        mtype (str): Device type, such as "computer", "smartphone" or
            "speaker".
        volume_percent (int): The current volume in percent.
        supports_volume (bool): If this device can be used to set the volume.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": 'id',
        "is_active": 'is_active',
        "is_private_session": 'is_private_session',
        "is_restricted": 'is_restricted',
        "name": 'name',
        "mtype": 'type',
        "volume_percent": 'volume_percent',
        "supports_volume": 'supports_volume'
    }

    _optionals = [
        'id',
        'is_active',
        'is_private_session',
        'is_restricted',
        'name',
        'mtype',
        'volume_percent',
        'supports_volume',
    ]

    _nullables = [
        'id',
        'volume_percent',
    ]

    def __init__(self,
                 id=APIHelper.SKIP,
                 is_active=APIHelper.SKIP,
                 is_private_session=APIHelper.SKIP,
                 is_restricted=APIHelper.SKIP,
                 name=APIHelper.SKIP,
                 mtype=APIHelper.SKIP,
                 volume_percent=APIHelper.SKIP,
                 supports_volume=APIHelper.SKIP):
        """Constructor for the DeviceObject class"""

        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id 
        if is_active is not APIHelper.SKIP:
            self.is_active = is_active 
        if is_private_session is not APIHelper.SKIP:
            self.is_private_session = is_private_session 
        if is_restricted is not APIHelper.SKIP:
            self.is_restricted = is_restricted 
        if name is not APIHelper.SKIP:
            self.name = name 
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype 
        if volume_percent is not APIHelper.SKIP:
            self.volume_percent = volume_percent 
        if supports_volume is not APIHelper.SKIP:
            self.supports_volume = supports_volume 

    @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
        id = dictionary.get("id") if "id" in dictionary.keys() else APIHelper.SKIP
        is_active = dictionary.get("is_active") if "is_active" in dictionary.keys() else APIHelper.SKIP
        is_private_session = dictionary.get("is_private_session") if "is_private_session" in dictionary.keys() else APIHelper.SKIP
        is_restricted = dictionary.get("is_restricted") if "is_restricted" in dictionary.keys() else APIHelper.SKIP
        name = dictionary.get("name") if dictionary.get("name") else APIHelper.SKIP
        mtype = dictionary.get("type") if dictionary.get("type") else APIHelper.SKIP
        volume_percent = dictionary.get("volume_percent") if "volume_percent" in dictionary.keys() else APIHelper.SKIP
        supports_volume = dictionary.get("supports_volume") if "supports_volume" in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(id,
                   is_active,
                   is_private_session,
                   is_restricted,
                   name,
                   mtype,
                   volume_percent,
                   supports_volume)

    @classmethod
    def validate(cls, dictionary):
        """Validates dictionary against class required properties

        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:
            boolean : if dictionary is valid contains required properties.

        """

        if isinstance(dictionary, cls):
            return True

        if not isinstance(dictionary, dict):
            return False

        return True

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'is_active={(self.is_active if hasattr(self, "is_active") else None)!r}, '
                f'is_private_session={(self.is_private_session if hasattr(self, "is_private_session") else None)!r}, '
                f'is_restricted={(self.is_restricted if hasattr(self, "is_restricted") else None)!r}, '
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!r}, '
                f'volume_percent={(self.volume_percent if hasattr(self, "volume_percent") else None)!r}, '
                f'supports_volume={(self.supports_volume if hasattr(self, "supports_volume") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'is_active={(self.is_active if hasattr(self, "is_active") else None)!s}, '
                f'is_private_session={(self.is_private_session if hasattr(self, "is_private_session") else None)!s}, '
                f'is_restricted={(self.is_restricted if hasattr(self, "is_restricted") else None)!s}, '
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!s}, '
                f'volume_percent={(self.volume_percent if hasattr(self, "volume_percent") else None)!s}, '
                f'supports_volume={(self.supports_volume if hasattr(self, "supports_volume") else None)!s})')
