# -*- 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.external_url_object import ExternalUrlObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.linked_track_object import LinkedTrackObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.simplified_artist_object import SimplifiedArtistObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.track_restriction_object import TrackRestrictionObject


class SimplifiedTrackObject(object):

    """Implementation of the 'SimplifiedTrackObject' model.

    Attributes:
        artists (List[SimplifiedArtistObject]): The artists who performed the
            track. Each artist object includes a link in `href` to more
            detailed information about the artist.
        available_markets (List[str]): A list of the countries in which the
            track can be played, identified by their [ISO 3166-1
            alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
        disc_number (int): The disc number (usually `1` unless the album
            consists of more than one disc).
        duration_ms (int): The track length in milliseconds.
        explicit (bool): Whether or not the track has explicit lyrics ( `true`
            = yes it does; `false` = no it does not OR unknown).
        external_urls (ExternalUrlObject): External URLs for this track.
        href (str): A link to the Web API endpoint providing full details of
            the track.
        id (str): The [Spotify
            ID](/documentation/web-api/concepts/spotify-uris-ids) for the
            track.
        is_playable (bool): Part of the response when [Track
            Relinking](/documentation/web-api/concepts/track-relinking/) is
            applied. If `true`, the track is playable in the given market.
            Otherwise `false`.
        linked_from (LinkedTrackObject): Part of the response when [Track
            Relinking](/documentation/web-api/concepts/track-relinking/) is
            applied and is only part of the response if the track linking, in
            fact, exists. The requested track has been replaced with a
            different track. The track in the `linked_from` object contains
            information about the originally requested track.
        restrictions (TrackRestrictionObject): Included in the response when a
            content restriction is applied.
        name (str): The name of the track.
        preview_url (str): A URL to a 30 second preview (MP3 format) of the
            track.
        track_number (int): The number of the track. If an album has several
            discs, the track number is the number on the specified disc.
        mtype (str): The object type: "track".
        uri (str): The [Spotify
            URI](/documentation/web-api/concepts/spotify-uris-ids) for the
            track.
        is_local (bool): Whether or not the track is from a local file.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "artists": 'artists',
        "available_markets": 'available_markets',
        "disc_number": 'disc_number',
        "duration_ms": 'duration_ms',
        "explicit": 'explicit',
        "external_urls": 'external_urls',
        "href": 'href',
        "id": 'id',
        "is_playable": 'is_playable',
        "linked_from": 'linked_from',
        "restrictions": 'restrictions',
        "name": 'name',
        "preview_url": 'preview_url',
        "track_number": 'track_number',
        "mtype": 'type',
        "uri": 'uri',
        "is_local": 'is_local'
    }

    _optionals = [
        'artists',
        'available_markets',
        'disc_number',
        'duration_ms',
        'explicit',
        'external_urls',
        'href',
        'id',
        'is_playable',
        'linked_from',
        'restrictions',
        'name',
        'preview_url',
        'track_number',
        'mtype',
        'uri',
        'is_local',
    ]

    _nullables = [
        'preview_url',
    ]

    def __init__(self,
                 artists=APIHelper.SKIP,
                 available_markets=APIHelper.SKIP,
                 disc_number=APIHelper.SKIP,
                 duration_ms=APIHelper.SKIP,
                 explicit=APIHelper.SKIP,
                 external_urls=APIHelper.SKIP,
                 href=APIHelper.SKIP,
                 id=APIHelper.SKIP,
                 is_playable=APIHelper.SKIP,
                 linked_from=APIHelper.SKIP,
                 restrictions=APIHelper.SKIP,
                 name=APIHelper.SKIP,
                 preview_url=APIHelper.SKIP,
                 track_number=APIHelper.SKIP,
                 mtype=APIHelper.SKIP,
                 uri=APIHelper.SKIP,
                 is_local=APIHelper.SKIP):
        """Constructor for the SimplifiedTrackObject class"""

        # Initialize members of the class
        if artists is not APIHelper.SKIP:
            self.artists = artists 
        if available_markets is not APIHelper.SKIP:
            self.available_markets = available_markets 
        if disc_number is not APIHelper.SKIP:
            self.disc_number = disc_number 
        if duration_ms is not APIHelper.SKIP:
            self.duration_ms = duration_ms 
        if explicit is not APIHelper.SKIP:
            self.explicit = explicit 
        if external_urls is not APIHelper.SKIP:
            self.external_urls = external_urls 
        if href is not APIHelper.SKIP:
            self.href = href 
        if id is not APIHelper.SKIP:
            self.id = id 
        if is_playable is not APIHelper.SKIP:
            self.is_playable = is_playable 
        if linked_from is not APIHelper.SKIP:
            self.linked_from = linked_from 
        if restrictions is not APIHelper.SKIP:
            self.restrictions = restrictions 
        if name is not APIHelper.SKIP:
            self.name = name 
        if preview_url is not APIHelper.SKIP:
            self.preview_url = preview_url 
        if track_number is not APIHelper.SKIP:
            self.track_number = track_number 
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype 
        if uri is not APIHelper.SKIP:
            self.uri = uri 
        if is_local is not APIHelper.SKIP:
            self.is_local = is_local 

    @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
        artists = None
        if dictionary.get('artists') is not None:
            artists = [SimplifiedArtistObject.from_dictionary(x) for x in dictionary.get('artists')]
        else:
            artists = APIHelper.SKIP
        available_markets = dictionary.get("available_markets") if dictionary.get("available_markets") else APIHelper.SKIP
        disc_number = dictionary.get("disc_number") if dictionary.get("disc_number") else APIHelper.SKIP
        duration_ms = dictionary.get("duration_ms") if dictionary.get("duration_ms") else APIHelper.SKIP
        explicit = dictionary.get("explicit") if "explicit" in dictionary.keys() else APIHelper.SKIP
        external_urls = ExternalUrlObject.from_dictionary(dictionary.get('external_urls')) if 'external_urls' in dictionary.keys() else APIHelper.SKIP
        href = dictionary.get("href") if dictionary.get("href") else APIHelper.SKIP
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        is_playable = dictionary.get("is_playable") if "is_playable" in dictionary.keys() else APIHelper.SKIP
        linked_from = LinkedTrackObject.from_dictionary(dictionary.get('linked_from')) if 'linked_from' in dictionary.keys() else APIHelper.SKIP
        restrictions = TrackRestrictionObject.from_dictionary(dictionary.get('restrictions')) if 'restrictions' in dictionary.keys() else APIHelper.SKIP
        name = dictionary.get("name") if dictionary.get("name") else APIHelper.SKIP
        preview_url = dictionary.get("preview_url") if "preview_url" in dictionary.keys() else APIHelper.SKIP
        track_number = dictionary.get("track_number") if dictionary.get("track_number") else APIHelper.SKIP
        mtype = dictionary.get("type") if dictionary.get("type") else APIHelper.SKIP
        uri = dictionary.get("uri") if dictionary.get("uri") else APIHelper.SKIP
        is_local = dictionary.get("is_local") if "is_local" in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(artists,
                   available_markets,
                   disc_number,
                   duration_ms,
                   explicit,
                   external_urls,
                   href,
                   id,
                   is_playable,
                   linked_from,
                   restrictions,
                   name,
                   preview_url,
                   track_number,
                   mtype,
                   uri,
                   is_local)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'artists={(self.artists if hasattr(self, "artists") else None)!r}, '
                f'available_markets={(self.available_markets if hasattr(self, "available_markets") else None)!r}, '
                f'disc_number={(self.disc_number if hasattr(self, "disc_number") else None)!r}, '
                f'duration_ms={(self.duration_ms if hasattr(self, "duration_ms") else None)!r}, '
                f'explicit={(self.explicit if hasattr(self, "explicit") else None)!r}, '
                f'external_urls={(self.external_urls if hasattr(self, "external_urls") else None)!r}, '
                f'href={(self.href if hasattr(self, "href") else None)!r}, '
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'is_playable={(self.is_playable if hasattr(self, "is_playable") else None)!r}, '
                f'linked_from={(self.linked_from if hasattr(self, "linked_from") else None)!r}, '
                f'restrictions={(self.restrictions if hasattr(self, "restrictions") else None)!r}, '
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'preview_url={(self.preview_url if hasattr(self, "preview_url") else None)!r}, '
                f'track_number={(self.track_number if hasattr(self, "track_number") else None)!r}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!r}, '
                f'uri={(self.uri if hasattr(self, "uri") else None)!r}, '
                f'is_local={(self.is_local if hasattr(self, "is_local") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'artists={(self.artists if hasattr(self, "artists") else None)!s}, '
                f'available_markets={(self.available_markets if hasattr(self, "available_markets") else None)!s}, '
                f'disc_number={(self.disc_number if hasattr(self, "disc_number") else None)!s}, '
                f'duration_ms={(self.duration_ms if hasattr(self, "duration_ms") else None)!s}, '
                f'explicit={(self.explicit if hasattr(self, "explicit") else None)!s}, '
                f'external_urls={(self.external_urls if hasattr(self, "external_urls") else None)!s}, '
                f'href={(self.href if hasattr(self, "href") else None)!s}, '
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'is_playable={(self.is_playable if hasattr(self, "is_playable") else None)!s}, '
                f'linked_from={(self.linked_from if hasattr(self, "linked_from") else None)!s}, '
                f'restrictions={(self.restrictions if hasattr(self, "restrictions") else None)!s}, '
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'preview_url={(self.preview_url if hasattr(self, "preview_url") else None)!s}, '
                f'track_number={(self.track_number if hasattr(self, "track_number") else None)!s}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!s}, '
                f'uri={(self.uri if hasattr(self, "uri") else None)!s}, '
                f'is_local={(self.is_local if hasattr(self, "is_local") else None)!s})')
