-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuberWrapper.js
More file actions
33 lines (31 loc) · 1.17 KB
/
uberWrapper.js
File metadata and controls
33 lines (31 loc) · 1.17 KB
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
30
31
32
33
var bot = require("./bot");
var keys = require("./keys")
exports.getCost = function(data, callback){
console.log("Entered uberWrapper");
bot.getUberAPI().estimates.getPriceForRouteAsync(data.startLat,data.startLng,data.endLat,data.endLng,data.seats).then((dat) => {
var costs = dat.prices;
miles = costs[0].distance;
var uberPrices = [];
for (x in costs) {
var average = (costs[x].low_estimate+costs[x].high_estimate)/2;
//console.log(costs[x].localized_display_name + ': $' + parseFloat(average));
//console.log("Cost: " + costs);
if (costs[x].low_estimate!=null) {
uberPrices.push([costs[x].localized_display_name, parseFloat(average)]);
dName = costs[x].display_name;
rType = costs[x].localized_display_name;
spicyBoy = 'Uber';
}
}
data.uberPrice = uberPrices;
data.miles = miles;
callback(data);
}, (error) => {
console.log(error)
});
}
exports.getLink = function(data){
var link = 'https://m.uber.com/ul/?action=setPickup&client_id='+keys.uber.client_id+'&pickup=my_location&dropoff[nickname]=dropoff2C%20USA&dropoff[latitude]='+data.endLat+'&dropoff[longitude]='+data.endLng;
//console.log(link);
return link;
}