# -*- 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.author_object import AuthorObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.copyright_object import CopyrightObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.external_url_object import ExternalUrlObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.image_object import ImageObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.narrator_object import NarratorObject
from spotifywebapiwithfixesandimprovementsfromsonallux.models.paging_simplified_chapter_object import PagingSimplifiedChapterObject


class AudiobookObject(object):

    """Implementation of the 'AudiobookObject' model.

    Attributes:
        authors (List[AuthorObject]): The author(s) for the audiobook.
        available_markets (List[str]): A list of the countries in which the
            audiobook can be played, identified by their [ISO 3166-1
            alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
        copyrights (List[CopyrightObject]): The copyright statements of the
            audiobook.
        description (str): A description of the audiobook. HTML tags are
            stripped away from this field, use `html_description` field in
            case HTML tags are needed.
        html_description (str): A description of the audiobook. This field may
            contain HTML tags.
        edition (str): The edition of the audiobook.
        explicit (bool): Whether or not the audiobook has explicit content
            (true = yes it does; false = no it does not OR unknown).
        external_urls (ExternalUrlObject): External URLs for this audiobook.
        href (str): A link to the Web API endpoint providing full details of
            the audiobook.
        id (str): The [Spotify
            ID](/documentation/web-api/concepts/spotify-uris-ids) for the
            audiobook.
        images (List[ImageObject]): The cover art for the audiobook in various
            sizes, widest first.
        languages (List[str]): A list of the languages used in the audiobook,
            identified by their [ISO
            639](https://en.wikipedia.org/wiki/ISO_639) code.
        media_type (str): The media type of the audiobook.
        name (str): The name of the audiobook.
        narrators (List[NarratorObject]): The narrator(s) for the audiobook.
        publisher (str): The publisher of the audiobook.
        mtype (str): The object type.
        uri (str): The [Spotify
            URI](/documentation/web-api/concepts/spotify-uris-ids) for the
            audiobook.
        total_chapters (int): The number of chapters in this audiobook.
        chapters (PagingSimplifiedChapterObject): The chapters of the
            audiobook.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "authors": 'authors',
        "available_markets": 'available_markets',
        "copyrights": 'copyrights',
        "description": 'description',
        "html_description": 'html_description',
        "explicit": 'explicit',
        "external_urls": 'external_urls',
        "href": 'href',
        "id": 'id',
        "images": 'images',
        "languages": 'languages',
        "media_type": 'media_type',
        "name": 'name',
        "narrators": 'narrators',
        "publisher": 'publisher',
        "mtype": 'type',
        "uri": 'uri',
        "total_chapters": 'total_chapters',
        "chapters": 'chapters',
        "edition": 'edition'
    }

    _optionals = [
        'edition',
    ]

    def __init__(self,
                 authors=None,
                 available_markets=None,
                 copyrights=None,
                 description=None,
                 html_description=None,
                 explicit=None,
                 external_urls=None,
                 href=None,
                 id=None,
                 images=None,
                 languages=None,
                 media_type=None,
                 name=None,
                 narrators=None,
                 publisher=None,
                 uri=None,
                 total_chapters=None,
                 chapters=None,
                 edition=APIHelper.SKIP):
        """Constructor for the AudiobookObject class"""

        # Initialize members of the class
        self.authors = authors 
        self.available_markets = available_markets 
        self.copyrights = copyrights 
        self.description = description 
        self.html_description = html_description 
        if edition is not APIHelper.SKIP:
            self.edition = edition 
        self.explicit = explicit 
        self.external_urls = external_urls 
        self.href = href 
        self.id = id 
        self.images = images 
        self.languages = languages 
        self.media_type = media_type 
        self.name = name 
        self.narrators = narrators 
        self.publisher = publisher 
        self.mtype = 'audiobook' 
        self.uri = uri 
        self.total_chapters = total_chapters 
        self.chapters = chapters 

    @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
        authors = None
        if dictionary.get('authors') is not None:
            authors = [AuthorObject.from_dictionary(x) for x in dictionary.get('authors')]
        available_markets = dictionary.get("available_markets") if dictionary.get("available_markets") else None
        copyrights = None
        if dictionary.get('copyrights') is not None:
            copyrights = [CopyrightObject.from_dictionary(x) for x in dictionary.get('copyrights')]
        description = dictionary.get("description") if dictionary.get("description") else None
        html_description = dictionary.get("html_description") if dictionary.get("html_description") else None
        explicit = dictionary.get("explicit") if "explicit" in dictionary.keys() 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')]
        languages = dictionary.get("languages") if dictionary.get("languages") else None
        media_type = dictionary.get("media_type") if dictionary.get("media_type") else None
        name = dictionary.get("name") if dictionary.get("name") else None
        narrators = None
        if dictionary.get('narrators') is not None:
            narrators = [NarratorObject.from_dictionary(x) for x in dictionary.get('narrators')]
        publisher = dictionary.get("publisher") if dictionary.get("publisher") else None
        uri = dictionary.get("uri") if dictionary.get("uri") else None
        total_chapters = dictionary.get("total_chapters") if dictionary.get("total_chapters") else None
        chapters = PagingSimplifiedChapterObject.from_dictionary(dictionary.get('chapters')) if dictionary.get('chapters') else None
        edition = dictionary.get("edition") if dictionary.get("edition") else APIHelper.SKIP
        # Return an object of this model
        return cls(authors,
                   available_markets,
                   copyrights,
                   description,
                   html_description,
                   explicit,
                   external_urls,
                   href,
                   id,
                   images,
                   languages,
                   media_type,
                   name,
                   narrators,
                   publisher,
                   uri,
                   total_chapters,
                   chapters,
                   edition)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'authors={self.authors!r}, '
                f'available_markets={self.available_markets!r}, '
                f'copyrights={self.copyrights!r}, '
                f'description={self.description!r}, '
                f'html_description={self.html_description!r}, '
                f'edition={(self.edition if hasattr(self, "edition") else None)!r}, '
                f'explicit={self.explicit!r}, '
                f'external_urls={self.external_urls!r}, '
                f'href={self.href!r}, '
                f'id={self.id!r}, '
                f'images={self.images!r}, '
                f'languages={self.languages!r}, '
                f'media_type={self.media_type!r}, '
                f'name={self.name!r}, '
                f'narrators={self.narrators!r}, '
                f'publisher={self.publisher!r}, '
                f'mtype={self.mtype!r}, '
                f'uri={self.uri!r}, '
                f'total_chapters={self.total_chapters!r}, '
                f'chapters={self.chapters!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'authors={self.authors!s}, '
                f'available_markets={self.available_markets!s}, '
                f'copyrights={self.copyrights!s}, '
                f'description={self.description!s}, '
                f'html_description={self.html_description!s}, '
                f'edition={(self.edition if hasattr(self, "edition") else None)!s}, '
                f'explicit={self.explicit!s}, '
                f'external_urls={self.external_urls!s}, '
                f'href={self.href!s}, '
                f'id={self.id!s}, '
                f'images={self.images!s}, '
                f'languages={self.languages!s}, '
                f'media_type={self.media_type!s}, '
                f'name={self.name!s}, '
                f'narrators={self.narrators!s}, '
                f'publisher={self.publisher!s}, '
                f'mtype={self.mtype!s}, '
                f'uri={self.uri!s}, '
                f'total_chapters={self.total_chapters!s}, '
                f'chapters={self.chapters!s})')
