# -*- 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.track_object import TrackObject


class SavedTrackObject(object):

    """Implementation of the 'SavedTrackObject' model.

    Attributes:
        added_at (datetime): The date and time the track was saved. Timestamps
            are returned in ISO 8601 format as Coordinated Universal Time
            (UTC) with a zero offset: YYYY-MM-DDTHH:MM:SSZ. If the time is
            imprecise (for example, the date/time of an album release), an
            additional field indicates the precision; see for example,
            release_date in an album object.
        track (TrackObject): Information about the track.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "added_at": 'added_at',
        "track": 'track'
    }

    _optionals = [
        'added_at',
        'track',
    ]

    def __init__(self,
                 added_at=APIHelper.SKIP,
                 track=APIHelper.SKIP):
        """Constructor for the SavedTrackObject class"""

        # Initialize members of the class
        if added_at is not APIHelper.SKIP:
            self.added_at = APIHelper.apply_datetime_converter(added_at, APIHelper.RFC3339DateTime) if added_at else None 
        if track is not APIHelper.SKIP:
            self.track = track 

    @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
        added_at = APIHelper.RFC3339DateTime.from_value(dictionary.get("added_at")).datetime if dictionary.get("added_at") else APIHelper.SKIP
        track = TrackObject.from_dictionary(dictionary.get('track')) if 'track' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(added_at,
                   track)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'added_at={(self.added_at if hasattr(self, "added_at") else None)!r}, '
                f'track={(self.track if hasattr(self, "track") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'added_at={(self.added_at if hasattr(self, "added_at") else None)!s}, '
                f'track={(self.track if hasattr(self, "track") else None)!s})')
