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

"""
spotifywebapiwithfixesandimprovementsfromsonallux

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


class SectionObject(object):

    """Implementation of the 'SectionObject' model.

    Attributes:
        start (float): The starting point (in seconds) of the section.
        duration (float): The duration (in seconds) of the section.
        confidence (float): The confidence, from 0.0 to 1.0, of the
            reliability of the section's "designation".
        loudness (float): The overall loudness of the section in decibels
            (dB). Loudness values are useful for comparing relative loudness
            of sections within tracks.
        tempo (float): The overall estimated tempo of the section 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. Some tracks contain tempo changes or
            sounds which don't contain tempo (like pure speech) which would
            correspond to a low value in this field.
        key (int): The estimated overall key of the section. The values in
            this field ranging from 0 to 11 mapping to pitches using standard
            Pitch Class notation (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. Songs with many key changes may correspond
            to low values in this field.
        mode (ModeEnum): Indicates the modality (major or minor) of a section,
            the type of scale from which its melodic content is derived. This
            field will contain a 0 for "minor", a 1 for "major", or a -1 for
            no result. Note that the major key (e.g. C major) could more
            likely be confused with the minor key at 3 semitones lower (e.g. A
            minor) as both keys carry the same pitches.
        mode_confidence (float): The confidence, from 0.0 to 1.0, of the
            reliability of the `mode`.
        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`. Sections with time
            signature changes may correspond to low values in this field.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "start": 'start',
        "duration": 'duration',
        "confidence": 'confidence',
        "loudness": 'loudness',
        "tempo": 'tempo',
        "tempo_confidence": 'tempo_confidence',
        "key": 'key',
        "key_confidence": 'key_confidence',
        "mode": 'mode',
        "mode_confidence": 'mode_confidence',
        "time_signature": 'time_signature',
        "time_signature_confidence": 'time_signature_confidence'
    }

    _optionals = [
        'start',
        'duration',
        'confidence',
        'loudness',
        'tempo',
        'tempo_confidence',
        'key',
        'key_confidence',
        'mode',
        'mode_confidence',
        'time_signature',
        'time_signature_confidence',
    ]

    def __init__(self,
                 start=APIHelper.SKIP,
                 duration=APIHelper.SKIP,
                 confidence=APIHelper.SKIP,
                 loudness=APIHelper.SKIP,
                 tempo=APIHelper.SKIP,
                 tempo_confidence=APIHelper.SKIP,
                 key=APIHelper.SKIP,
                 key_confidence=APIHelper.SKIP,
                 mode=APIHelper.SKIP,
                 mode_confidence=APIHelper.SKIP,
                 time_signature=APIHelper.SKIP,
                 time_signature_confidence=APIHelper.SKIP):
        """Constructor for the SectionObject class"""

        # Initialize members of the class
        if start is not APIHelper.SKIP:
            self.start = start 
        if duration is not APIHelper.SKIP:
            self.duration = duration 
        if confidence is not APIHelper.SKIP:
            self.confidence = confidence 
        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 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 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 

    @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
        start = dictionary.get("start") if dictionary.get("start") else APIHelper.SKIP
        duration = dictionary.get("duration") if dictionary.get("duration") else APIHelper.SKIP
        confidence = dictionary.get("confidence") if dictionary.get("confidence") 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
        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
        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
        # Return an object of this model
        return cls(start,
                   duration,
                   confidence,
                   loudness,
                   tempo,
                   tempo_confidence,
                   key,
                   key_confidence,
                   mode,
                   mode_confidence,
                   time_signature,
                   time_signature_confidence)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'start={(self.start if hasattr(self, "start") else None)!r}, '
                f'duration={(self.duration if hasattr(self, "duration") else None)!r}, '
                f'confidence={(self.confidence if hasattr(self, "confidence") 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'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'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})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'start={(self.start if hasattr(self, "start") else None)!s}, '
                f'duration={(self.duration if hasattr(self, "duration") else None)!s}, '
                f'confidence={(self.confidence if hasattr(self, "confidence") 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'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'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})')
