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

"""
cookiesapi

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from cookiesapi.models.address import Address
from cookiesapi.models.geo import Geo


class Location(object):

    """Implementation of the 'Location' model.

    Describes physical location info.

    Attributes:
        address (Address): Street address.
        geo (Geo): Geo point or boundary.
        hash (string): Geo hash.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "address": 'address',
        "geo": 'geo',
        "hash": 'hash'
    }

    def __init__(self,
                 address=None,
                 geo=None,
                 hash=None):
        """Constructor for the Location class"""

        # Initialize members of the class
        self.address = address
        self.geo = geo
        self.hash = hash

    @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 dictionary is None:
            return None

        # Extract variables from the dictionary
        address = Address.from_dictionary(dictionary.get('address')) if dictionary.get('address') else None
        geo = Geo.from_dictionary(dictionary.get('geo')) if dictionary.get('geo') else None
        hash = dictionary.get('hash')

        # Return an object of this model
        return cls(address,
                   geo,
                   hash)
