forked from adamlawrencium/UberLens
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UberWrapper.py
29 lines (23 loc) · 865 Bytes
/
UberWrapper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
import json
class UberWrapper(object):
"""
Wrapper for address-lookup api endpoint
"""
def __init__(self):
self.url_AL = "https://www.uber.com/api/address-lookup?lat="
self.url_FE = "https://www.uber.com/api/fare-estimate?"
def address_lookup(self, lat, lng):
req = requests.get(self.url_AL + str(lat) + "&lng=" + str(lng))
return req.json()
def fare_estimator(self, pickupID, destID):
fares = []
req = self.url_FE + 'pickupRef=' + pickupID + '&destinationRef=' + destID
req = requests.get(req)
return req.json()
def get_UberX_from_fares(self, blob):
fares = blob['prices']
for vehicle in fares:
if vehicle['vehicleViewDisplayName'] == 'uberX':
return vehicle['fareString']
return 'PRICE NOT FOUND'