def getCafeDetailsGivenID(cafe_id): api_res = makeAPIRequest(buildSingleCafeDetailsRequest(cafe_id)) if api_res['status'] == 'OK': result = api_res['result'] return result else: return None
def getCafeBasicsGivenId(cafe_id): api_res = makeAPIRequest(buildCafeBasicDetailsRequest(cafe_id)) if api_res['status'] == 'OK': result = api_res['result'] return result else: return None
def geocodeCityName(city_name): success = False while not success: geocoded_city = makeAPIRequest( buildCityLocationSearchRequest(city_name)) success = geocoded_city.get('success', True) if not success: time.sleep(2) new_city_obj = { "name": geocoded_city['standard']['city'], "country": geocoded_city['standard']['prov'], "latitude": geocoded_city['latt'], "longitude": geocoded_city['longt'] } return new_city_obj
def makeRequestsWithRadius(radius): results_array = [] page_token = None for i in range(3): area_request = None if i == 0: area_request = buildAreaSearchRequest(latitude, longitude, None, radius) else: area_request = buildAreaSearchRequest(None, None, page_token, radius) response = makeAPIRequest(area_request) area_results = response['results'] results_array.extend(area_results) page_token = response.get('next_page_token', 0) if page_token == 0: break else: time.sleep(2) return results_array
def getCafeWithQueryString(query_string): api_res = makeAPIRequest(buildSinglePlaceSearchRequest(query_string)) return api_res