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

"""
instagramapi

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


class Position(object):

    """Implementation of the 'Position' model.

    Attributes:
        x (float): X position (horizontal)
        y (float): Y position (vertical)

    """

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

    _optionals = [
        'x',
        'y',
    ]

    def __init__(self,
                 x=APIHelper.SKIP,
                 y=APIHelper.SKIP):
        """Constructor for the Position class"""

        # Initialize members of the class
        if x is not APIHelper.SKIP:
            self.x = x 
        if y is not APIHelper.SKIP:
            self.y = y 

    @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
        x = dictionary.get("x") if dictionary.get("x") else APIHelper.SKIP
        y = dictionary.get("y") if dictionary.get("y") else APIHelper.SKIP
        # Return an object of this model
        return cls(x,
                   y)

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

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