# -*- 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.comment_entry import CommentEntry


class CommentsCollection(object):

    """Implementation of the 'CommentsCollection' model.

    Attributes:
        count (int): Nember of comments available, data does not necessary
            contain all comments
        data (List[CommentEntry]): Collection of comment entries; **warning:**
            deprecated for Apps [created on or after Nov 17,
            2015](http://instagram.com/developer/changelog/)

    """

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

    _optionals = [
        'count',
        'data',
    ]

    def __init__(self,
                 count=APIHelper.SKIP,
                 data=APIHelper.SKIP):
        """Constructor for the CommentsCollection class"""

        # Initialize members of the class
        if count is not APIHelper.SKIP:
            self.count = count 
        if data is not APIHelper.SKIP:
            self.data = data 

    @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
        count = dictionary.get("count") if dictionary.get("count") else APIHelper.SKIP
        data = None
        if dictionary.get('data') is not None:
            data = [CommentEntry.from_dictionary(x) for x in dictionary.get('data')]
        else:
            data = APIHelper.SKIP
        # Return an object of this model
        return cls(count,
                   data)

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

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