# -*- 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.position import Position
from instagramapi.models.user_short_info import UserShortInfo


class UserInPhoto(object):

    """Implementation of the 'UserInPhoto' model.

    Attributes:
        position (Position): The model property of type Position.
        user (UserShortInfo): The model property of type UserShortInfo.

    """

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

    _optionals = [
        'position',
        'user',
    ]

    def __init__(self,
                 position=APIHelper.SKIP,
                 user=APIHelper.SKIP):
        """Constructor for the UserInPhoto class"""

        # Initialize members of the class
        if position is not APIHelper.SKIP:
            self.position = position 
        if user is not APIHelper.SKIP:
            self.user = user 

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

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

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