Skip to content

Commit db9da1a

Browse files
authored
V1.0.0 (#56)
* adding bluebird missing tests * adding tests for async methods * #33 implementation including tests and updated README.md * adding error handling to samples * resolving conflict for README * update dependency versions * remove publisher and fix gulpfile * #24 first piece with tests to come: Reindeers & Requests implementation * solving #24, #40, #41, #42 - added all methods for #24 including tests - updated READMEs & example files - reworked entire testing architecture for #41 - removed deprecated methods for #42 - added scope checks for #40 * adding tests for #40 * sync updates from master * Added mechanism for token refresh (#47) * added token refresh functionality * added unit test for oauth.js * added unit test for oauthAsync.js * added tests for complete code coverage * code cleanup * Updating dependencies and set engines * Setting tokens to fix #39 * Added implicit surge handling (#49) * added functionality for surge pricing * added implicit surge handling * Changed OAuth2 urls to v2 (#53) * Adding tests for #53 * Dropping node v.1x/iojs in favor of ES6 #30
1 parent 76d1ecc commit db9da1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4526
-1785
lines changed

Diff for: .publishrc

-13
This file was deleted.

Diff for: .travis.yml

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
language: node_js
22
node_js:
3-
- "5"
4-
- "5.1"
5-
- "4"
3+
- "6.10"
4+
- "6.9"
5+
- "4.8"
6+
- "4.4.1"
67
- "4.2"
7-
- "4.1"
8-
- "4.0"
9-
- "0.12"
10-
- "0.11"
11-
- "0.10"
12-
- "iojs"
138
addons:
149
code_climate:
1510
repo_token: 6131e0b97abea823e9a41cc90736f0c2fdbe5d6b442ce0603f7f131aea6b35c3

Diff for: README-Nodeback.md

+717
Large diffs are not rendered by default.

Diff for: README.md

+261-208
Large diffs are not rendered by default.

Diff for: examples/auth-get-products-async.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var Uber = require('node-uber');
2+
3+
// create new Uber instance
4+
var uber = new Uber({
5+
client_id: 'YOUR CLIENT ID',
6+
client_secret: 'YOUR CLIENT SECRET',
7+
server_token: 'YOUR SERVER TOKEN',
8+
redirect_uri: 'http://localhost/callback',
9+
name: 'nodejs uber wrapper',
10+
language: 'en_US',
11+
sandbox: true
12+
});
13+
14+
// get authorization URL
15+
var authURL = uber.getAuthorizeUrl(['history', 'profile', 'request', 'places']);
16+
17+
// redirect user to the authURL
18+
19+
// the authorizarion_code will be provided via the callback after logging in using the authURL
20+
uber.authorizationAsync({
21+
authorization_code: 'YOUR AUTH CODE'
22+
})
23+
.spread(function(access_token, refresh_token, authorizedScopes, tokenExpiration) {
24+
// store the user id and associated access_token, refresh_token, scopes and token expiration date
25+
console.log('New access_token retrieved: ' + access_token);
26+
console.log('... token allows access to scopes: ' + authorizedScopes);
27+
console.log('... token is valid until: ' + tokenExpiration);
28+
console.log('... after token expiration, re-authorize using refresh_token: ' + refresh_token);
29+
30+
// chain the promise to retrive all products for location
31+
return uber.products.getAllForLocationAsync(3.1357169, 101.6881501);
32+
})
33+
.then(function(res) {
34+
// response with all products
35+
console.log(res);
36+
})
37+
.error(function(err) {
38+
console.error(err);
39+
});

Diff for: examples/auth-get-products.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,25 @@ var uber = new Uber({
1212
});
1313

1414
// get authorization URL
15-
var authURL = uber.getAuthorizeUrl(['history','profile', 'request', 'places']);
15+
var authURL = uber.getAuthorizeUrl(['history', 'profile', 'request', 'places']);
1616

17+
// redirect user to the authURL
1718

19+
// the authorizarion_code will be provided via the callback after logging in using the authURL
1820
uber.authorization({
19-
// this code will be provided via the callback after logging in using the authURL
2021
authorization_code: 'YOUR AUTH CODE'
21-
}, function(err, access_token, refresh_token) {
22-
if (err) console.error(err);
23-
else {
24-
console.log('Your access_token is: ' + access_token);
25-
console.log('Your refresh_token is: ' + refresh_token);
22+
}, function(err, res) {
23+
if (err) {
24+
console.error(err);
25+
} else {
26+
// store the user id and associated properties:
27+
// access_token = res[0], refresh_token = res[1], scopes = res[2]),and token expiration date = res[3]
28+
console.log('New access_token retrieved: ' + res[0]);
29+
console.log('... token allows access to scopes: ' + res[2]);
30+
console.log('... token is valid until: ' + res[3]);
31+
console.log('... after token expiration, re-authorize using refresh_token: ' + res[1]);
2632

27-
uber.products.getAllForLocation(3.1357, 101.6880, function(err, res) {
33+
uber.products.getAllForLocation(3.1357169, 101.6881501, function(err, res) {
2834
if (err) console.error(err);
2935
else console.log(res);
3036
});

Diff for: gulpfile.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ gulp.task('pre-test', function() {
3030
.pipe(istanbul.hookRequire());
3131
});
3232

33-
gulp.task('test', function() {
33+
gulp.task('test', ['pre-test'], function() {
3434
return gulp.src(['test/**/*.js'])
3535
.pipe(mocha({
36-
reporter: 'spec'
36+
reporter: 'spec',
37+
//useColors: false,
38+
timeout: 5000
3739
}))
3840
// Creating the reports after tests ran
3941
.pipe(istanbul.writeReports())
40-
// Enforce a coverage of at least 90%
42+
// Enforce a coverage of at least 95%
4143
.pipe(istanbul.enforceThresholds({
4244
thresholds: {
4345
global: 95

0 commit comments

Comments
 (0)