A Node.js wrapper for Uber API
0.0.4 Mocha tests
0.0.3 Error handling
0.0.2 Support User Profile
0.0.1 Support Product Types, Time Estimates & Price Estimates
MIT
npm install node-uber
npm test
var Uber = require('node-uber');
var uber = new Uber({
client_id: 'CLIENT_ID',
client_secret: 'CLIENT_SECRET',
server_token: 'SERVER_TOKEN',
redirect_uri: 'REDIRECT URL',
name: 'APP_NAME'
});
After getting the authorize url, the user will be redirected to the redirect url with authorization code used in the next function.
uber.getAuthorizeUrl(params);
- scope (array)
NOTE: history
scope is still not working
uber.getAuthorizeUrl(['profile']);
Used to convert authorization code or refresh token into access token.
uber.authorization(params, callback);
- authorization_code OR
- refresh_token
uber.authorization({ refresh_token: 'REFRESH_TOKEN' },
function (err, access_token, refresh_token) {
if (err) console.error(err);
else {
console.log(access_token);
console.log(refresh_token);
}
});
uber.products.list(params, callback);
- latitude
- longitude
uber.products.list({ latitude: 3.1357, longitude: 101.6880 }, function (err, res) {
if (err) console.error(err);
else console.log(res);
});
uber.estimates.price(params, callback);
- start_latitude
- start_longitude
- end_latitude
- end_longitude
uber.estimates.price({
start_latitude: 3.1357, start_longitude: 101.6880,
end_latitude: 3.0833, end_longitude: 101.6500
}, function (err, res) {
if (err) console.error(err);
else console.log(res);
});
uber.estimates.time(params, callback);
- start_latitude
- start_longitude
- customer_uuid (not implemented)
- product_id (not implemented)
uber.estimates.time({
start_latitude: 3.1357, start_longitude: 101.6880
}, function (err, res) {
if (err) console.error(err);
else console.log(res);
});
NOTE: Have not tested yet because unable to get history
scope
uber.user.profile(params, callback);
- access_token
If this params is unable, the object will try to retrieve access_token
inside
uber.user.profile(params, function (err, res) {
if (err) console.log(err);
else console.log(res);
});