Closed attibalazs closed 4 years ago
I would say that we stub all these types of endpoints (the ones we need) based on the earth911 model and fake the results
Not sure how we can find a quick answer for this one other than deploying some sort of reverse proxy - but even that is not quite straight forward for 3rd party services... (ie Extensible Service Proxy)
The other issue we will face with google functions is that it needs billing to be enabled...
lets just call the location service from the app directly
Example
headers = {
'api_key': api_key,
'latitude': 34.09,
'longitude': -118.41,
'material_id': [1, 4],
'max_distance': 10
}
url = base_url + 'earth911.searchLocations'
print(url)
r = requests.get(url, headers)
body = r.json()
{'search_time': '00.351127', 'num_results': 59, 'result': [{'curbside': False, 'description': 'UCLA S.A.F.E. Collection Center', 'distance': 2.6, 'longitude': -118.4476222831746, 'latitude': 34.068414273155824, 'location_type_id': 3, 'location_id': 'Q1RQNVJfUltDVg', 'municipal': True}, {'curbside': False, 'description': "O'Reilly Auto Parts", 'distance': 8.2, 'longitude': -118.30925297565051, 'latitude': 34.005045141014364, 'location_type_id': 28, 'location_id': 'Q1RQNVVeWFpBUA', 'municipal': False}, {'curbside': False, 'description': 'Firestone Complete Auto Care ', 'distance': 8.2, 'longitude': -118.52239327543917, 'latitude': 34.163353379809, 'location_type_id': 28, 'location_id': 'Q1RQNVRQU15HVQ', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 8.3, 'longitude': -118.27075021181773, 'latitude': 34.05712700459175, 'location_type_id': 28, 'location_id': 'Q1RQNVBQWV5EVg', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 8.4, 'longitude': -118.29905432689718, 'latitude': 34.16977050711447, 'location_type_id': 28, 'location_id': 'Q1RQNVBQWV1DVw', 'municipal': False}, {'curbside': False, 'description': 'AutoZone', 'distance': 8.5, 'longitude': -118.26095263352097, 'latitude': 34.08262362647507, 'location_type_id': 28, 'location_id': 'Q1RQNVBfXV9FVg', 'municipal': False}, {'curbside': False, 'description': 'Los Angeles-Glendale Treatment Plant S.A.F.E. Collection Center', 'distance': 8.5, 'longitude': -118.27390147969093, 'latitude': 34.13911726507497, 'location_type_id': 3, 'location_id': 'Q1RQNVJfUlxKXA', 'municipal': True}, {'curbside': False, 'description': 'South Coast Fibers, Inc.', 'distance': 8.8, 'longitude': -118.2764224939895, 'latitude': 34.15292554793762, 'location_type_id': 0, 'location_id': 'Q1RQNVJYUllBUw', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 8.8, 'longitude': -118.44567422667116, 'latitude': 34.21394555311905, 'location_type_id': 28, 'location_id': 'Q1RQNVJaWVpEVA', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 8.9, 'longitude': -118.26863026797572, 'latitude': 34.143758223215535, 'location_type_id': 28, 'location_id': 'Q1RQNVBQWV5GXQ', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 9.1, 'longitude': -118.31131562371299, 'latitude': 33.98751263248336, 'location_type_id': 28, 'location_id': 'Q1RQNVJaWVpCVg', 'municipal': False}, {'curbside': False, 'description': 'Firestone Complete Auto Care ', 'distance': 9.1, 'longitude': -118.39227456016496, 'latitude': 33.95955229208097, 'location_type_id': 28, 'location_id': 'Q1RQNVRQU11DVw', 'municipal': False}, {'curbside': False, 'description': "O'Reilly Auto Parts", 'distance': 9.2, 'longitude': -118.35067782423846, 'latitude': 33.966198602504484, 'location_type_id': 28, 'location_id': 'Q1RQNVVeWFlBUA', 'municipal': False}, {'curbside': False, 'description': 'Home Depot', 'distance': 9.4, 'longitude': -118.3709605301861, 'latitude': 33.95743234823899, 'location_type_id': 28, 'location_id': 'Q1RQNVJaWFZLVA', 'municipal': False}, {'curbside': False, 'description': 'Walmart', 'distance': 9.4, 'longitude': -118.44951304389852, 'latitude': 34.22265451160504, 'location_type_id': 28, 'location_id': 'Q1RQNVJfW1xKUA', 'municipal': False}, {'curbside': False, 'description': "O'Reilly Auto Parts", 'distance': 9.5, 'longitude': -118.26083804196195, 'latitude': 34.028708297953266, 'location_type_id': 28, 'location_id': 'Q1RQNVVeWFlDVg', 'municipal': False}, {'curbside': False, 'description': 'Firestone Complete Auto Care ', 'distance': 9.5, 'longitude': -118.25556683024675, 'latitude': 34.14117991313744, 'location_type_id': 28, 'location_id': 'Q1RQNVRQU15FVQ', 'municipal': False}, {'curbside': False, 'description': 'AutoZone', 'distance': 9.6, 'longitude': -118.24536818149342, 'latitude': 34.11419360098678, 'location_type_id': 28, 'location_id': 'Q1RQNVVfXVlDUA', 'municipal': False}, {'curbside': False, 'description': 'Firestone Complete Auto Care ', 'distance': 9.9, 'longitude': -118.44985681857563, 'latitude': 34.22918623046954, 'location_type_id': 28, 'location_id': 'Q1RQNVRQU11HUQ', 'municipal': False}]}
will create stub queries for a few location and material combos
we need a secure way to manage the api key from earh911 and make queries for finding nearby recycling centres
https://api.earth911.com/docs/chapter/2.3/