# -*- 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.episode_object import EpisodeObject


class SavedEpisodeObject(object):

    """Implementation of the 'SavedEpisodeObject' model.

    Attributes:
        added_at (datetime): The date and time the episode was saved.
            Timestamps are returned in ISO 8601 format as Coordinated
            Universal Time (UTC) with a zero offset: YYYY-MM-DDTHH:MM:SSZ.
        episode (EpisodeObject): Information about the episode.

    """

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

    _optionals = [
        'added_at',
        'episode',
    ]

    def __init__(self,
                 added_at=APIHelper.SKIP,
                 episode=APIHelper.SKIP):
        """Constructor for the SavedEpisodeObject 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 episode is not APIHelper.SKIP:
            self.episode = episode 

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

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