Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Code is easier to understand than words, so let us dive right in ::
# Returned places from a query are place summaries.
print place.name
print place.geo_location
print place.reference
print place.place_id

# The following method has to make a further API call.
place.get_details()
Expand Down Expand Up @@ -91,11 +91,11 @@ Code is easier to understand than words, so let us dive right in ::
accuracy=100,
types=types.TYPE_HOME_GOODS_STORE,
language=lang.ENGLISH_GREAT_BRITAIN)
print added_place.reference # The Google Places reference - Important!
print added_place.place_id # The Google Places identifier - Important!
print added_place.id

# Delete the place that you've just added.
google_places.delete_place(added_place.reference)
google_places.delete_place(added_place.place_id)
except GooglePlacesError as error_detail:
# You've passed in parameter values that the Places API doesn't like..
print error_detail
Expand Down Expand Up @@ -220,7 +220,7 @@ Reference

get_place(**kwargs)
Returns a detailed instance of googleplaces.Place
reference -- The unique Google reference for the required place.
place_id -- The unique Google identifier for the required place.

language -- The language code, indicating in which language the results
should be returned, if possble. (default en)
Expand All @@ -229,17 +229,17 @@ Reference
device using a location sensor (default False).


checkin(reference, sensor=False)
Checks in an anonymous user in to the Place that matches the reference.
checkin(place_id, sensor=False)
Checks in an anonymous user in to the Place that matches the place_id.
kwargs:
reference -- The unique Google reference for the required place.
place_id -- The unique Google identifier for the required place.

sensor -- Boolean flag denoting if the location came from a device
using its location sensor (default False).


add_place(**kwargs)
Returns a dict containing the following keys: reference, id.
Returns a dict containing the following keys: place_id, id.
kwargs:
name -- The full text name of the Place. Limited to 255
characters.
Expand All @@ -260,10 +260,10 @@ Reference
using its location sensor (default False).


delete_place(reference, sensor=False)
delete_place(place_id, sensor=False)
Deletes a place from the Google Places database.
kwargs:
reference -- The unique Google reference for the required place.
place_id -- The unique Google identifier for the required place.

sensor -- Boolean flag denoting if the location came from a
device using its location sensor (default False).
Expand Down Expand Up @@ -318,9 +318,6 @@ Reference
Returns a unique identifier for the Place that can be used to fetch full
details about it. It is recommended that stored references for Places be
regularly updated. A Place may have many valid reference tokens.
Returns a unique identifier for the Place that can be used to fetch full
details about it. It is recommended that stored references for Places be
regularly updated. A Place may have many valid reference tokens.

terms
A list of terms which build up the description string
Expand Down Expand Up @@ -424,7 +421,7 @@ Reference
Checks in an anonynomous user in.

get_details(**kwargs)
Retrieves full information on the place matching the reference.
Retrieves full information on the place matching the place_id.
kwargs:
language -- The language code, indicating in which language the
results should be returned, if possible. This value defaults
Expand Down
38 changes: 19 additions & 19 deletions googleplaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

__all__ = ['GooglePlaces', 'GooglePlacesError', 'GooglePlacesAttributeError',
'geocode_location']
__version__ = '0.13.0'
__version__ = '1.0.0'
__author__ = 'Samuel Adu'
__email__ = 'sam@slimkrazy.com'

Expand Down Expand Up @@ -108,15 +108,15 @@ def geocode_location(location, sensor=False):
raise GooglePlacesError(error_detail)
return geo_response['results'][0]['geometry']['location']

def _get_place_details(reference, api_key, sensor=False,
def _get_place_details(place_id, api_key, sensor=False,
language=lang.ENGLISH):
"""Gets a detailed place response.

keyword arguments:
reference -- The unique Google reference for the required place.
place_id -- The unique identifier for the required place.
"""
url, detail_response = _fetch_remote_json(GooglePlaces.DETAIL_API_URL,
{'reference': reference,
{'placeid': place_id,
'sensor': str(sensor).lower(),
'key': api_key,
'language': language})
Expand Down Expand Up @@ -169,7 +169,7 @@ class GooglePlacesAttributeError(AttributeError):

A search query from the places API returns only a summary of the Place.
in order to get full details, a further API call must be made using
the place reference. This exception will be thrown when a property made
the place_id. This exception will be thrown when a property made
available by only the detailed API call is looked up against the summary
object.

Expand Down Expand Up @@ -419,39 +419,39 @@ def radar_search(self, sensor=False, keyword=None, name=None,
_validate_response(url, places_response)
return GooglePlacesSearchResult(self, places_response)

def checkin(self, reference, sensor=False):
def checkin(self, place_id, sensor=False):
"""Checks in a user to a place.

keyword arguments:
reference -- The unique Google reference for the relevant place.
place_id -- The unique Google identifier for the relevant place.
sensor -- Boolean flag denoting if the location came from a
device using its location sensor (default False).
"""
data = {'reference': reference}
data = {'placeid': place_id}
url, checkin_response = _fetch_remote_json(
GooglePlaces.CHECKIN_API_URL % (str(sensor).lower(),
self.api_key), json.dumps(data), use_http_post=True)
_validate_response(url, checkin_response)

def get_place(self, reference, sensor=False, language=lang.ENGLISH):
def get_place(self, place_id, sensor=False, language=lang.ENGLISH):
"""Gets a detailed place object.

keyword arguments:
reference -- The unique Google reference for the required place.
place_id -- The unique Google identifier for the required place.
sensor -- Boolean flag denoting if the location came from a
device using its' location sensor (default False).
language -- The language code, indicating in which language the
results should be returned, if possible. (default lang.ENGLISH)
"""
place_details = _get_place_details(reference,
place_details = _get_place_details(place_id,
self.api_key, sensor, language=language)
return Place(self, place_details)

def add_place(self, **kwargs):
"""Adds a place to the Google Places database.

On a successful request, this method will return a dict containing
the the new Place's reference and id in keys 'reference' and 'id'
the the new Place's place_id and id in keys 'place_id' and 'id'
respectively.

keyword arguments:
Expand Down Expand Up @@ -513,20 +513,20 @@ def add_place(self, **kwargs):
GooglePlaces.ADD_API_URL % (str(sensor).lower(),
self.api_key), json.dumps(request_params), use_http_post=True)
_validate_response(url, add_response)
return {'reference': add_response['reference'],
return {'place_id': add_response['place_id'],
'id': add_response['id']}

def delete_place(self, reference, sensor=False):
def delete_place(self, place_id, sensor=False):
"""Deletes a place from the Google Places database.

keyword arguments:
reference -- The textual identifier that uniquely identifies this
place_id -- The textual identifier that uniquely identifies this
Place, returned from a Place Search request.
sensor -- Boolean flag denoting if the location came from a device
using its location sensor (default False).
"""

request_params = {'reference': reference}
request_params = {'place_id': place_id}
url, delete_response = _fetch_remote_json(
GooglePlaces.DELETE_API_URL % (str(sensor).lower(),
self.api_key), json.dumps(request_params), use_http_post=True)
Expand Down Expand Up @@ -685,7 +685,7 @@ def place(self):

def get_details(self, language=None):
"""
Retrieves full information on the place matching the reference.
Retrieves full information on the place matching the place_id.

Stores the response in the `place` property.
"""
Expand All @@ -696,7 +696,7 @@ def get_details(self, language=None):
except KeyError:
language = lang.ENGLISH
place = _get_place_details(
self.reference, self._query_instance.api_key,
self.place_id, self._query_instance.api_key,
self._query_instance.sensor, language=language)
self._place = Place(self._query_instance, place)

Expand Down Expand Up @@ -935,7 +935,7 @@ def checkin(self):
self._query_instance.sensor)

def get_details(self, language=None):
"""Retrieves full information on the place matching the reference.
"""Retrieves full information on the place matching the place_id.

Further attributes will be made available on the instance once this
method has been invoked.
Expand Down