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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

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


class Track(object):

    """Implementation of the 'Track' model.

    Attributes:
        num_samples (int): The exact number of audio samples analyzed from
            this track. See also `analysis_sample_rate`.
        duration (float): Length of the track in seconds.
        sample_md_5 (str): This field will always contain the empty string.
        offset_seconds (int): An offset to the start of the region of the
            track that was analyzed. (As the entire track is analyzed, this
            should always be 0.)
        window_seconds (int): The length of the region of the track was
            analyzed, if a subset of the track was analyzed. (As the entire
            track is analyzed, this should always be 0.)
        analysis_sample_rate (int): The sample rate used to decode and analyze
            this track. May differ from the actual sample rate of this track
            available on Spotify.
        analysis_channels (int): The number of channels used for analysis. If
            1, all channels are summed together to mono before analysis.
        end_of_fade_in (float): The time, in seconds, at which the track's
            fade-in period ends. If the track has no fade-in, this will be 0.0.
        start_of_fade_out (float): The time, in seconds, at which the track's
            fade-out period starts. If the track has no fade-out, this should
            match the track's length.
        loudness (float): The overall loudness of a track in decibels (dB).
            Loudness values are averaged across the entire track and are
            useful for comparing relative loudness of tracks. Loudness is the
            quality of a sound that is the primary psychological correlate of
            physical strength (amplitude). Values typically range between -60
            and 0 db.
        tempo (float): The overall estimated tempo of a track in beats per
            minute (BPM). In musical terminology, tempo is the speed or pace
            of a given piece and derives directly from the average beat
            duration.
        tempo_confidence (float): The confidence, from 0.0 to 1.0, of the
            reliability of the `tempo`.
        time_signature (int): An estimated time signature. The time signature
            (meter) is a notational convention to specify how many beats are
            in each bar (or measure). The time signature ranges from 3 to 7
            indicating time signatures of "3/4", to "7/4".
        time_signature_confidence (float): The confidence, from 0.0 to 1.0, of
            the reliability of the `time_signature`.
        key (int): The key the track is in. Integers map to pitches using
            standard [Pitch Class
            notation](https://en.wikipedia.org/wiki/Pitch_class). E.g. 0 = C,
            1 = C♯/D♭, 2 = D, and so on. If no key was detected, the value is
            -1.
        key_confidence (float): The confidence, from 0.0 to 1.0, of the
            reliability of the `key`.
        mode (int): Mode indicates the modality (major or minor) of a track,
            the type of scale from which its melodic content is derived. Major
            is represented by 1 and minor is 0.
        mode_confidence (float): The confidence, from 0.0 to 1.0, of the
            reliability of the `mode`.
        codestring (str): An [Echo Nest Musical Fingerprint
            (ENMFP)](https://academiccommons.columbia.edu/doi/10.7916/D8Q248M4)
            codestring for this track.
        code_version (float): A version number for the Echo Nest Musical
            Fingerprint format used in the codestring field.
        echoprintstring (str): An
            [EchoPrint](https://github.com/spotify/echoprint-codegen)
            codestring for this track.
        echoprint_version (float): A version number for the EchoPrint format
            used in the echoprintstring field.
        synchstring (str): A
            [Synchstring](https://github.com/echonest/synchdata) for this
            track.
        synch_version (float): A version number for the Synchstring used in
            the synchstring field.
        rhythmstring (str): A Rhythmstring for this track. The format of this
            string is similar to the Synchstring.
        rhythm_version (float): A version number for the Rhythmstring used in
            the rhythmstring field.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "num_samples": 'num_samples',
        "duration": 'duration',
        "sample_md_5": 'sample_md5',
        "offset_seconds": 'offset_seconds',
        "window_seconds": 'window_seconds',
        "analysis_sample_rate": 'analysis_sample_rate',
        "analysis_channels": 'analysis_channels',
        "end_of_fade_in": 'end_of_fade_in',
        "start_of_fade_out": 'start_of_fade_out',
        "loudness": 'loudness',
        "tempo": 'tempo',
        "tempo_confidence": 'tempo_confidence',
        "time_signature": 'time_signature',
        "time_signature_confidence": 'time_signature_confidence',
        "key": 'key',
        "key_confidence": 'key_confidence',
        "mode": 'mode',
        "mode_confidence": 'mode_confidence',
        "codestring": 'codestring',
        "code_version": 'code_version',
        "echoprintstring": 'echoprintstring',
        "echoprint_version": 'echoprint_version',
        "synchstring": 'synchstring',
        "synch_version": 'synch_version',
        "rhythmstring": 'rhythmstring',
        "rhythm_version": 'rhythm_version'
    }

    _optionals = [
        'num_samples',
        'duration',
        'sample_md_5',
        'offset_seconds',
        'window_seconds',
        'analysis_sample_rate',
        'analysis_channels',
        'end_of_fade_in',
        'start_of_fade_out',
        'loudness',
        'tempo',
        'tempo_confidence',
        'time_signature',
        'time_signature_confidence',
        'key',
        'key_confidence',
        'mode',
        'mode_confidence',
        'codestring',
        'code_version',
        'echoprintstring',
        'echoprint_version',
        'synchstring',
        'synch_version',
        'rhythmstring',
        'rhythm_version',
    ]

    def __init__(self,
                 num_samples=APIHelper.SKIP,
                 duration=APIHelper.SKIP,
                 sample_md_5=APIHelper.SKIP,
                 offset_seconds=APIHelper.SKIP,
                 window_seconds=APIHelper.SKIP,
                 analysis_sample_rate=APIHelper.SKIP,
                 analysis_channels=APIHelper.SKIP,
                 end_of_fade_in=APIHelper.SKIP,
                 start_of_fade_out=APIHelper.SKIP,
                 loudness=APIHelper.SKIP,
                 tempo=APIHelper.SKIP,
                 tempo_confidence=APIHelper.SKIP,
                 time_signature=APIHelper.SKIP,
                 time_signature_confidence=APIHelper.SKIP,
                 key=APIHelper.SKIP,
                 key_confidence=APIHelper.SKIP,
                 mode=APIHelper.SKIP,
                 mode_confidence=APIHelper.SKIP,
                 codestring=APIHelper.SKIP,
                 code_version=APIHelper.SKIP,
                 echoprintstring=APIHelper.SKIP,
                 echoprint_version=APIHelper.SKIP,
                 synchstring=APIHelper.SKIP,
                 synch_version=APIHelper.SKIP,
                 rhythmstring=APIHelper.SKIP,
                 rhythm_version=APIHelper.SKIP):
        """Constructor for the Track class"""

        # Initialize members of the class
        if num_samples is not APIHelper.SKIP:
            self.num_samples = num_samples 
        if duration is not APIHelper.SKIP:
            self.duration = duration 
        if sample_md_5 is not APIHelper.SKIP:
            self.sample_md_5 = sample_md_5 
        if offset_seconds is not APIHelper.SKIP:
            self.offset_seconds = offset_seconds 
        if window_seconds is not APIHelper.SKIP:
            self.window_seconds = window_seconds 
        if analysis_sample_rate is not APIHelper.SKIP:
            self.analysis_sample_rate = analysis_sample_rate 
        if analysis_channels is not APIHelper.SKIP:
            self.analysis_channels = analysis_channels 
        if end_of_fade_in is not APIHelper.SKIP:
            self.end_of_fade_in = end_of_fade_in 
        if start_of_fade_out is not APIHelper.SKIP:
            self.start_of_fade_out = start_of_fade_out 
        if loudness is not APIHelper.SKIP:
            self.loudness = loudness 
        if tempo is not APIHelper.SKIP:
            self.tempo = tempo 
        if tempo_confidence is not APIHelper.SKIP:
            self.tempo_confidence = tempo_confidence 
        if time_signature is not APIHelper.SKIP:
            self.time_signature = time_signature 
        if time_signature_confidence is not APIHelper.SKIP:
            self.time_signature_confidence = time_signature_confidence 
        if key is not APIHelper.SKIP:
            self.key = key 
        if key_confidence is not APIHelper.SKIP:
            self.key_confidence = key_confidence 
        if mode is not APIHelper.SKIP:
            self.mode = mode 
        if mode_confidence is not APIHelper.SKIP:
            self.mode_confidence = mode_confidence 
        if codestring is not APIHelper.SKIP:
            self.codestring = codestring 
        if code_version is not APIHelper.SKIP:
            self.code_version = code_version 
        if echoprintstring is not APIHelper.SKIP:
            self.echoprintstring = echoprintstring 
        if echoprint_version is not APIHelper.SKIP:
            self.echoprint_version = echoprint_version 
        if synchstring is not APIHelper.SKIP:
            self.synchstring = synchstring 
        if synch_version is not APIHelper.SKIP:
            self.synch_version = synch_version 
        if rhythmstring is not APIHelper.SKIP:
            self.rhythmstring = rhythmstring 
        if rhythm_version is not APIHelper.SKIP:
            self.rhythm_version = rhythm_version 

    @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
        num_samples = dictionary.get("num_samples") if dictionary.get("num_samples") else APIHelper.SKIP
        duration = dictionary.get("duration") if dictionary.get("duration") else APIHelper.SKIP
        sample_md_5 = dictionary.get("sample_md5") if dictionary.get("sample_md5") else APIHelper.SKIP
        offset_seconds = dictionary.get("offset_seconds") if dictionary.get("offset_seconds") else APIHelper.SKIP
        window_seconds = dictionary.get("window_seconds") if dictionary.get("window_seconds") else APIHelper.SKIP
        analysis_sample_rate = dictionary.get("analysis_sample_rate") if dictionary.get("analysis_sample_rate") else APIHelper.SKIP
        analysis_channels = dictionary.get("analysis_channels") if dictionary.get("analysis_channels") else APIHelper.SKIP
        end_of_fade_in = dictionary.get("end_of_fade_in") if dictionary.get("end_of_fade_in") else APIHelper.SKIP
        start_of_fade_out = dictionary.get("start_of_fade_out") if dictionary.get("start_of_fade_out") else APIHelper.SKIP
        loudness = dictionary.get("loudness") if dictionary.get("loudness") else APIHelper.SKIP
        tempo = dictionary.get("tempo") if dictionary.get("tempo") else APIHelper.SKIP
        tempo_confidence = dictionary.get("tempo_confidence") if dictionary.get("tempo_confidence") else APIHelper.SKIP
        time_signature = dictionary.get("time_signature") if dictionary.get("time_signature") else APIHelper.SKIP
        time_signature_confidence = dictionary.get("time_signature_confidence") if dictionary.get("time_signature_confidence") else APIHelper.SKIP
        key = dictionary.get("key") if dictionary.get("key") else APIHelper.SKIP
        key_confidence = dictionary.get("key_confidence") if dictionary.get("key_confidence") else APIHelper.SKIP
        mode = dictionary.get("mode") if dictionary.get("mode") else APIHelper.SKIP
        mode_confidence = dictionary.get("mode_confidence") if dictionary.get("mode_confidence") else APIHelper.SKIP
        codestring = dictionary.get("codestring") if dictionary.get("codestring") else APIHelper.SKIP
        code_version = dictionary.get("code_version") if dictionary.get("code_version") else APIHelper.SKIP
        echoprintstring = dictionary.get("echoprintstring") if dictionary.get("echoprintstring") else APIHelper.SKIP
        echoprint_version = dictionary.get("echoprint_version") if dictionary.get("echoprint_version") else APIHelper.SKIP
        synchstring = dictionary.get("synchstring") if dictionary.get("synchstring") else APIHelper.SKIP
        synch_version = dictionary.get("synch_version") if dictionary.get("synch_version") else APIHelper.SKIP
        rhythmstring = dictionary.get("rhythmstring") if dictionary.get("rhythmstring") else APIHelper.SKIP
        rhythm_version = dictionary.get("rhythm_version") if dictionary.get("rhythm_version") else APIHelper.SKIP
        # Return an object of this model
        return cls(num_samples,
                   duration,
                   sample_md_5,
                   offset_seconds,
                   window_seconds,
                   analysis_sample_rate,
                   analysis_channels,
                   end_of_fade_in,
                   start_of_fade_out,
                   loudness,
                   tempo,
                   tempo_confidence,
                   time_signature,
                   time_signature_confidence,
                   key,
                   key_confidence,
                   mode,
                   mode_confidence,
                   codestring,
                   code_version,
                   echoprintstring,
                   echoprint_version,
                   synchstring,
                   synch_version,
                   rhythmstring,
                   rhythm_version)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'num_samples={(self.num_samples if hasattr(self, "num_samples") else None)!r}, '
                f'duration={(self.duration if hasattr(self, "duration") else None)!r}, '
                f'sample_md_5={(self.sample_md_5 if hasattr(self, "sample_md_5") else None)!r}, '
                f'offset_seconds={(self.offset_seconds if hasattr(self, "offset_seconds") else None)!r}, '
                f'window_seconds={(self.window_seconds if hasattr(self, "window_seconds") else None)!r}, '
                f'analysis_sample_rate={(self.analysis_sample_rate if hasattr(self, "analysis_sample_rate") else None)!r}, '
                f'analysis_channels={(self.analysis_channels if hasattr(self, "analysis_channels") else None)!r}, '
                f'end_of_fade_in={(self.end_of_fade_in if hasattr(self, "end_of_fade_in") else None)!r}, '
                f'start_of_fade_out={(self.start_of_fade_out if hasattr(self, "start_of_fade_out") else None)!r}, '
                f'loudness={(self.loudness if hasattr(self, "loudness") else None)!r}, '
                f'tempo={(self.tempo if hasattr(self, "tempo") else None)!r}, '
                f'tempo_confidence={(self.tempo_confidence if hasattr(self, "tempo_confidence") else None)!r}, '
                f'time_signature={(self.time_signature if hasattr(self, "time_signature") else None)!r}, '
                f'time_signature_confidence={(self.time_signature_confidence if hasattr(self, "time_signature_confidence") else None)!r}, '
                f'key={(self.key if hasattr(self, "key") else None)!r}, '
                f'key_confidence={(self.key_confidence if hasattr(self, "key_confidence") else None)!r}, '
                f'mode={(self.mode if hasattr(self, "mode") else None)!r}, '
                f'mode_confidence={(self.mode_confidence if hasattr(self, "mode_confidence") else None)!r}, '
                f'codestring={(self.codestring if hasattr(self, "codestring") else None)!r}, '
                f'code_version={(self.code_version if hasattr(self, "code_version") else None)!r}, '
                f'echoprintstring={(self.echoprintstring if hasattr(self, "echoprintstring") else None)!r}, '
                f'echoprint_version={(self.echoprint_version if hasattr(self, "echoprint_version") else None)!r}, '
                f'synchstring={(self.synchstring if hasattr(self, "synchstring") else None)!r}, '
                f'synch_version={(self.synch_version if hasattr(self, "synch_version") else None)!r}, '
                f'rhythmstring={(self.rhythmstring if hasattr(self, "rhythmstring") else None)!r}, '
                f'rhythm_version={(self.rhythm_version if hasattr(self, "rhythm_version") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'num_samples={(self.num_samples if hasattr(self, "num_samples") else None)!s}, '
                f'duration={(self.duration if hasattr(self, "duration") else None)!s}, '
                f'sample_md_5={(self.sample_md_5 if hasattr(self, "sample_md_5") else None)!s}, '
                f'offset_seconds={(self.offset_seconds if hasattr(self, "offset_seconds") else None)!s}, '
                f'window_seconds={(self.window_seconds if hasattr(self, "window_seconds") else None)!s}, '
                f'analysis_sample_rate={(self.analysis_sample_rate if hasattr(self, "analysis_sample_rate") else None)!s}, '
                f'analysis_channels={(self.analysis_channels if hasattr(self, "analysis_channels") else None)!s}, '
                f'end_of_fade_in={(self.end_of_fade_in if hasattr(self, "end_of_fade_in") else None)!s}, '
                f'start_of_fade_out={(self.start_of_fade_out if hasattr(self, "start_of_fade_out") else None)!s}, '
                f'loudness={(self.loudness if hasattr(self, "loudness") else None)!s}, '
                f'tempo={(self.tempo if hasattr(self, "tempo") else None)!s}, '
                f'tempo_confidence={(self.tempo_confidence if hasattr(self, "tempo_confidence") else None)!s}, '
                f'time_signature={(self.time_signature if hasattr(self, "time_signature") else None)!s}, '
                f'time_signature_confidence={(self.time_signature_confidence if hasattr(self, "time_signature_confidence") else None)!s}, '
                f'key={(self.key if hasattr(self, "key") else None)!s}, '
                f'key_confidence={(self.key_confidence if hasattr(self, "key_confidence") else None)!s}, '
                f'mode={(self.mode if hasattr(self, "mode") else None)!s}, '
                f'mode_confidence={(self.mode_confidence if hasattr(self, "mode_confidence") else None)!s}, '
                f'codestring={(self.codestring if hasattr(self, "codestring") else None)!s}, '
                f'code_version={(self.code_version if hasattr(self, "code_version") else None)!s}, '
                f'echoprintstring={(self.echoprintstring if hasattr(self, "echoprintstring") else None)!s}, '
                f'echoprint_version={(self.echoprint_version if hasattr(self, "echoprint_version") else None)!s}, '
                f'synchstring={(self.synchstring if hasattr(self, "synchstring") else None)!s}, '
                f'synch_version={(self.synch_version if hasattr(self, "synch_version") else None)!s}, '
                f'rhythmstring={(self.rhythmstring if hasattr(self, "rhythmstring") else None)!s}, '
                f'rhythm_version={(self.rhythm_version if hasattr(self, "rhythm_version") else None)!s})')
