

def add_place(self, **kwargs):
    "Adds a place to the Google Places database.\n\n        On a successful request, this method will return a dict containing\n        the the new Place's place_id and id in keys 'place_id' and 'id'\n        respectively.\n\n        keyword arguments:\n        name        -- The full text name of the Place. Limited to 255\n                       characters.\n        lat_lng     -- A dict containing the following keys: lat, lng.\n        accuracy    -- The accuracy of the location signal on which this request\n                       is based, expressed in meters.\n        types       -- The category in which this Place belongs. Only one type\n                       can currently be specified for a Place. A string or\n                       single element list may be passed in.\n        language    -- The language in which the Place's name is being reported.\n                       (defaults 'en').\n        sensor      -- Boolean flag denoting if the location came from a device\n                       using its location sensor (default False).\n        "
    required_kwargs = {
        'name': [str],
        'lat_lng': [dict],
        'accuracy': [int],
        'types': [str, list],
    }
    request_params = {
        
    }
    for key in required_kwargs:
        if ((key not in kwargs) or (kwargs[key] is None)):
            raise ValueError(('The %s argument is required.' % key))
        expected_types = required_kwargs[key]
        type_is_valid = False
        for expected_type in expected_types:
            if isinstance(kwargs[key], expected_type):
                type_is_valid = True
                break
        if (not type_is_valid):
            raise ValueError(('Invalid value for %s' % key))
        if (key is not 'lat_lng'):
            request_params[key] = kwargs[key]
    if (len(kwargs['name']) > 255):
        raise ValueError(('The place name must not exceed 255 characters ' + 'in length.'))
    try:
        kwargs['lat_lng']['lat']
        kwargs['lat_lng']['lng']
        request_params['location'] = kwargs['lat_lng']
    except KeyError:
        raise ValueError('Invalid keys for lat_lng.')
    request_params['language'] = (kwargs.get('language') if (kwargs.get('language') is not None) else lang.ENGLISH)
    sensor = (kwargs.get('sensor') if (kwargs.get('sensor') is not None) else False)
    if isinstance(kwargs['types'], str):
        request_params['types'] = [kwargs['types']]
    else:
        request_params['types'] = kwargs['types']
    (url, add_response) = _fetch_remote_json((GooglePlaces.ADD_API_URL % (str(sensor).lower(), self.api_key)), json.dumps(request_params), use_http_post=True)
    _validate_response(url, add_response)
    return {
        'place_id': add_response['place_id'],
        'id': add_response['id'],
    }

dataset/ETHPy150Open slimkrazy/python-google-places/googleplaces/__init__.py GooglePlaces.add_place/original