# -*- 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.caption_data import CaptionData
from instagramapi.models.comments_collection import CommentsCollection
from instagramapi.models.images_data import ImagesData
from instagramapi.models.likes_collection import LikesCollection
from instagramapi.models.location_info import LocationInfo
from instagramapi.models.user_in_photo import UserInPhoto
from instagramapi.models.user_short_info import UserShortInfo
from instagramapi.models.videos_data import VideosData


class MediaEntry(object):

    """Implementation of the 'MediaEntry' model.

    Attributes:
        attribution (str): ??? Unknown ???
        caption (CaptionData): The model property of type CaptionData.
        comments (CommentsCollection): The model property of type
            CommentsCollection.
        created_time (str): Media creation UNIX timestamp
        filter (str): Filter of this media entry
        id (str): ID of a media entry
        images (ImagesData): The model property of type ImagesData.
        likes (LikesCollection): The model property of type LikesCollection.
        link (str): Fixed URL of this media entry
        location (LocationInfo): The model property of type LocationInfo.
        tags (List[str]): List of tags assigned to this media
        mtype (TypeEnum): Type of this media entry
        user (UserShortInfo): The model property of type UserShortInfo.
        user_has_liked (bool): Indicates whether authenticated user has liked
            this media or not
        users_in_photo (List[UserInPhoto]): Users located on this media entry
        videos (VideosData): The model property of type VideosData.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "attribution": 'attribution',
        "caption": 'caption',
        "comments": 'comments',
        "created_time": 'created_time',
        "filter": 'filter',
        "id": 'id',
        "images": 'images',
        "likes": 'likes',
        "link": 'link',
        "location": 'location',
        "tags": 'tags',
        "mtype": 'type',
        "user": 'user',
        "user_has_liked": 'user_has_liked',
        "users_in_photo": 'users_in_photo',
        "videos": 'videos'
    }

    _optionals = [
        'attribution',
        'caption',
        'comments',
        'created_time',
        'filter',
        'id',
        'images',
        'likes',
        'link',
        'location',
        'tags',
        'mtype',
        'user',
        'user_has_liked',
        'users_in_photo',
        'videos',
    ]

    def __init__(self,
                 attribution=APIHelper.SKIP,
                 caption=APIHelper.SKIP,
                 comments=APIHelper.SKIP,
                 created_time=APIHelper.SKIP,
                 filter=APIHelper.SKIP,
                 id=APIHelper.SKIP,
                 images=APIHelper.SKIP,
                 likes=APIHelper.SKIP,
                 link=APIHelper.SKIP,
                 location=APIHelper.SKIP,
                 tags=APIHelper.SKIP,
                 mtype=APIHelper.SKIP,
                 user=APIHelper.SKIP,
                 user_has_liked=APIHelper.SKIP,
                 users_in_photo=APIHelper.SKIP,
                 videos=APIHelper.SKIP):
        """Constructor for the MediaEntry class"""

        # Initialize members of the class
        if attribution is not APIHelper.SKIP:
            self.attribution = attribution 
        if caption is not APIHelper.SKIP:
            self.caption = caption 
        if comments is not APIHelper.SKIP:
            self.comments = comments 
        if created_time is not APIHelper.SKIP:
            self.created_time = created_time 
        if filter is not APIHelper.SKIP:
            self.filter = filter 
        if id is not APIHelper.SKIP:
            self.id = id 
        if images is not APIHelper.SKIP:
            self.images = images 
        if likes is not APIHelper.SKIP:
            self.likes = likes 
        if link is not APIHelper.SKIP:
            self.link = link 
        if location is not APIHelper.SKIP:
            self.location = location 
        if tags is not APIHelper.SKIP:
            self.tags = tags 
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype 
        if user is not APIHelper.SKIP:
            self.user = user 
        if user_has_liked is not APIHelper.SKIP:
            self.user_has_liked = user_has_liked 
        if users_in_photo is not APIHelper.SKIP:
            self.users_in_photo = users_in_photo 
        if videos is not APIHelper.SKIP:
            self.videos = videos 

    @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
        attribution = dictionary.get("attribution") if dictionary.get("attribution") else APIHelper.SKIP
        caption = CaptionData.from_dictionary(dictionary.get('caption')) if 'caption' in dictionary.keys() else APIHelper.SKIP
        comments = CommentsCollection.from_dictionary(dictionary.get('comments')) if 'comments' in dictionary.keys() else APIHelper.SKIP
        created_time = dictionary.get("created_time") if dictionary.get("created_time") else APIHelper.SKIP
        filter = dictionary.get("filter") if dictionary.get("filter") else APIHelper.SKIP
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        images = ImagesData.from_dictionary(dictionary.get('images')) if 'images' in dictionary.keys() else APIHelper.SKIP
        likes = LikesCollection.from_dictionary(dictionary.get('likes')) if 'likes' in dictionary.keys() else APIHelper.SKIP
        link = dictionary.get("link") if dictionary.get("link") else APIHelper.SKIP
        location = LocationInfo.from_dictionary(dictionary.get('location')) if 'location' in dictionary.keys() else APIHelper.SKIP
        tags = dictionary.get("tags") if dictionary.get("tags") else APIHelper.SKIP
        mtype = dictionary.get("type") if dictionary.get("type") else APIHelper.SKIP
        user = UserShortInfo.from_dictionary(dictionary.get('user')) if 'user' in dictionary.keys() else APIHelper.SKIP
        user_has_liked = dictionary.get("user_has_liked") if "user_has_liked" in dictionary.keys() else APIHelper.SKIP
        users_in_photo = None
        if dictionary.get('users_in_photo') is not None:
            users_in_photo = [UserInPhoto.from_dictionary(x) for x in dictionary.get('users_in_photo')]
        else:
            users_in_photo = APIHelper.SKIP
        videos = VideosData.from_dictionary(dictionary.get('videos')) if 'videos' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(attribution,
                   caption,
                   comments,
                   created_time,
                   filter,
                   id,
                   images,
                   likes,
                   link,
                   location,
                   tags,
                   mtype,
                   user,
                   user_has_liked,
                   users_in_photo,
                   videos)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'attribution={(self.attribution if hasattr(self, "attribution") else None)!r}, '
                f'caption={(self.caption if hasattr(self, "caption") else None)!r}, '
                f'comments={(self.comments if hasattr(self, "comments") else None)!r}, '
                f'created_time={(self.created_time if hasattr(self, "created_time") else None)!r}, '
                f'filter={(self.filter if hasattr(self, "filter") else None)!r}, '
                f'id={(self.id if hasattr(self, "id") else None)!r}, '
                f'images={(self.images if hasattr(self, "images") else None)!r}, '
                f'likes={(self.likes if hasattr(self, "likes") else None)!r}, '
                f'link={(self.link if hasattr(self, "link") else None)!r}, '
                f'location={(self.location if hasattr(self, "location") else None)!r}, '
                f'tags={(self.tags if hasattr(self, "tags") else None)!r}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!r}, '
                f'user={(self.user if hasattr(self, "user") else None)!r}, '
                f'user_has_liked={(self.user_has_liked if hasattr(self, "user_has_liked") else None)!r}, '
                f'users_in_photo={(self.users_in_photo if hasattr(self, "users_in_photo") else None)!r}, '
                f'videos={(self.videos if hasattr(self, "videos") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'attribution={(self.attribution if hasattr(self, "attribution") else None)!s}, '
                f'caption={(self.caption if hasattr(self, "caption") else None)!s}, '
                f'comments={(self.comments if hasattr(self, "comments") else None)!s}, '
                f'created_time={(self.created_time if hasattr(self, "created_time") else None)!s}, '
                f'filter={(self.filter if hasattr(self, "filter") else None)!s}, '
                f'id={(self.id if hasattr(self, "id") else None)!s}, '
                f'images={(self.images if hasattr(self, "images") else None)!s}, '
                f'likes={(self.likes if hasattr(self, "likes") else None)!s}, '
                f'link={(self.link if hasattr(self, "link") else None)!s}, '
                f'location={(self.location if hasattr(self, "location") else None)!s}, '
                f'tags={(self.tags if hasattr(self, "tags") else None)!s}, '
                f'mtype={(self.mtype if hasattr(self, "mtype") else None)!s}, '
                f'user={(self.user if hasattr(self, "user") else None)!s}, '
                f'user_has_liked={(self.user_has_liked if hasattr(self, "user_has_liked") else None)!s}, '
                f'users_in_photo={(self.users_in_photo if hasattr(self, "users_in_photo") else None)!s}, '
                f'videos={(self.videos if hasattr(self, "videos") else None)!s})')
