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

"""
instagramapi

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


class CommentEntry(object):

    """Implementation of the 'CommentEntry' model.

    Attributes:
        created_time (str): Comment creation UNIX timestamp
        mfrom (UserShortInfo): The model property of type UserShortInfo.
        id (str): ID of this comment
        text (str): Text of the comment

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "created_time": 'created_time',
        "mfrom": 'from',
        "id": 'id',
        "text": 'text'
    }

    _optionals = [
        'created_time',
        'mfrom',
        'id',
        'text',
    ]

    def __init__(self,
                 created_time=APIHelper.SKIP,
                 mfrom=APIHelper.SKIP,
                 id=APIHelper.SKIP,
                 text=APIHelper.SKIP):
        """Constructor for the CommentEntry class"""

        # Initialize members of the class
        if created_time is not APIHelper.SKIP:
            self.created_time = created_time 
        if mfrom is not APIHelper.SKIP:
            self.mfrom = mfrom 
        if id is not APIHelper.SKIP:
            self.id = id 
        if text is not APIHelper.SKIP:
            self.text = text 

    @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
        created_time = dictionary.get("created_time") if dictionary.get("created_time") else APIHelper.SKIP
        mfrom = UserShortInfo.from_dictionary(dictionary.get('from')) if 'from' in dictionary.keys() else APIHelper.SKIP
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        text = dictionary.get("text") if dictionary.get("text") else APIHelper.SKIP
        # Return an object of this model
        return cls(created_time,
                   mfrom,
                   id,
                   text)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'created_time={(self.created_time if hasattr(self, "created_time") else None)!r}, '
                f'mfrom={(self.mfrom if hasattr(self, "mfrom") else None)!r}, '
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'text={(self.text if hasattr(self, "text") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'created_time={(self.created_time if hasattr(self, "created_time") else None)!s}, '
                f'mfrom={(self.mfrom if hasattr(self, "mfrom") else None)!s}, '
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'text={(self.text if hasattr(self, "text") else None)!s})')
