# -*- 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.album_restriction_object import AlbumRestrictionObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.external_url_object import ExternalUrlObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.image_object import ImageObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.simplified_artist_object import SimplifiedArtistObject


class ArtistDiscographyAlbumObject(object):

    """Implementation of the 'ArtistDiscographyAlbumObject' model.

    Attributes:
        album_type (AlbumTypeEnum): The type of the album.
        total_tracks (int): The number of tracks in the album.
        available_markets (List[str]): The markets in which the album is
            available: [ISO 3166-1 alpha-2 country
            codes](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
            _**NOTE**: an album is considered available in a market when at
            least 1 of its tracks is available in that market._
        external_urls (ExternalUrlObject): Known external URLs for this album.
        href (str): A link to the Web API endpoint providing full details of
            the album.
        id (str): The [Spotify
            ID](/documentation/web-api/concepts/spotify-uris-ids) for the
            album.
        images (List[ImageObject]): The cover art for the album in various
            sizes, widest first.
        name (str): The name of the album. In case of an album takedown, the
            value may be an empty string.
        release_date (str): The date the album was first released.
        release_date_precision (ReleaseDatePrecisionEnum): The precision with
            which `release_date` value is known.
        restrictions (AlbumRestrictionObject): Included in the response when a
            content restriction is applied.
        mtype (str): The object type.
        uri (str): The [Spotify
            URI](/documentation/web-api/concepts/spotify-uris-ids) for the
            album.
        artists (List[SimplifiedArtistObject]): The artists of the album. Each
            artist object includes a link in `href` to more detailed
            information about the artist.
        album_group (AlbumGroupEnum): This field describes the relationship
            between the artist and the album.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "album_type": 'album_type',
        "total_tracks": 'total_tracks',
        "available_markets": 'available_markets',
        "external_urls": 'external_urls',
        "href": 'href',
        "id": 'id',
        "images": 'images',
        "name": 'name',
        "release_date": 'release_date',
        "release_date_precision": 'release_date_precision',
        "mtype": 'type',
        "uri": 'uri',
        "artists": 'artists',
        "album_group": 'album_group',
        "restrictions": 'restrictions'
    }

    _optionals = [
        'restrictions',
    ]

    def __init__(self,
                 album_type=None,
                 total_tracks=None,
                 available_markets=None,
                 external_urls=None,
                 href=None,
                 id=None,
                 images=None,
                 name=None,
                 release_date=None,
                 release_date_precision=None,
                 uri=None,
                 artists=None,
                 album_group=None,
                 restrictions=APIHelper.SKIP):
        """Constructor for the ArtistDiscographyAlbumObject class"""

        # Initialize members of the class
        self.album_type = album_type 
        self.total_tracks = total_tracks 
        self.available_markets = available_markets 
        self.external_urls = external_urls 
        self.href = href 
        self.id = id 
        self.images = images 
        self.name = name 
        self.release_date = release_date 
        self.release_date_precision = release_date_precision 
        if restrictions is not APIHelper.SKIP:
            self.restrictions = restrictions 
        self.mtype = 'album' 
        self.uri = uri 
        self.artists = artists 
        self.album_group = album_group 

    @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
        album_type = dictionary.get("album_type") if dictionary.get("album_type") else None
        total_tracks = dictionary.get("total_tracks") if dictionary.get("total_tracks") else None
        available_markets = dictionary.get("available_markets") if dictionary.get("available_markets") else None
        external_urls = ExternalUrlObject.from_dictionary(dictionary.get('external_urls')) if dictionary.get('external_urls') else None
        href = dictionary.get("href") if dictionary.get("href") else None
        id = dictionary.get("id") if dictionary.get("id") else None
        images = None
        if dictionary.get('images') is not None:
            images = [ImageObject.from_dictionary(x) for x in dictionary.get('images')]
        name = dictionary.get("name") if dictionary.get("name") else None
        release_date = dictionary.get("release_date") if dictionary.get("release_date") else None
        release_date_precision = dictionary.get("release_date_precision") if dictionary.get("release_date_precision") else None
        uri = dictionary.get("uri") if dictionary.get("uri") else None
        artists = None
        if dictionary.get('artists') is not None:
            artists = [SimplifiedArtistObject.from_dictionary(x) for x in dictionary.get('artists')]
        album_group = dictionary.get("album_group") if dictionary.get("album_group") else None
        restrictions = AlbumRestrictionObject.from_dictionary(dictionary.get('restrictions')) if 'restrictions' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(album_type,
                   total_tracks,
                   available_markets,
                   external_urls,
                   href,
                   id,
                   images,
                   name,
                   release_date,
                   release_date_precision,
                   uri,
                   artists,
                   album_group,
                   restrictions)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'album_type={self.album_type!r}, '
                f'total_tracks={self.total_tracks!r}, '
                f'available_markets={self.available_markets!r}, '
                f'external_urls={self.external_urls!r}, '
                f'href={self.href!r}, '
                f'id={self.id!r}, '
                f'images={self.images!r}, '
                f'name={self.name!r}, '
                f'release_date={self.release_date!r}, '
                f'release_date_precision={self.release_date_precision!r}, '
                f'restrictions={(self.restrictions if hasattr(self, "restrictions") else None)!r}, '
                f'mtype={self.mtype!r}, '
                f'uri={self.uri!r}, '
                f'artists={self.artists!r}, '
                f'album_group={self.album_group!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'album_type={self.album_type!s}, '
                f'total_tracks={self.total_tracks!s}, '
                f'available_markets={self.available_markets!s}, '
                f'external_urls={self.external_urls!s}, '
                f'href={self.href!s}, '
                f'id={self.id!s}, '
                f'images={self.images!s}, '
                f'name={self.name!s}, '
                f'release_date={self.release_date!s}, '
                f'release_date_precision={self.release_date_precision!s}, '
                f'restrictions={(self.restrictions if hasattr(self, "restrictions") else None)!s}, '
                f'mtype={self.mtype!s}, '
                f'uri={self.uri!s}, '
                f'artists={self.artists!s}, '
                f'album_group={self.album_group!s})')
