Skip to content

Commit fc90880

Browse files
committed
Bug fix for #32
Also updating the README and bumping up the version to 0.96
1 parent 9840032 commit fc90880

File tree

6 files changed

+97
-72
lines changed

6 files changed

+97
-72
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ The history endpoint can be accessed ONLY with an OAuth ``access_token`` authori
279279

280280
#### [Get user activity](https://developer.uber.com/docs/v12-history)
281281
```javascript
282-
uber.user.getHistory(offset, limit [, access_token], callback);
282+
uber.user.getHistory(offset, limit, callback);
283283
```
284284

285285
``offset`` defaults to 0 and ``limit`` defaults to 5 with a maximum value of 50.
@@ -296,7 +296,7 @@ uber.user.getHistory(0, 5, function(err, res) {
296296
The me endpoint can be accessed ONLY with an OAuth ``access_token`` authorized with the ``profile`` scope.
297297
#### [Get user profile](https://developer.uber.com/docs/v1-me)
298298
```javascript
299-
uber.user.getProfile([access_token], callback);
299+
uber.user.getProfile(callback);
300300
```
301301

302302
##### Example

Diff for: lib/resources/Products.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ Products.prototype.setSurgeMultiplierByID = function setSurgeMultiplierByID(id,
4646
return callback(new Error('Invalid surge multiplier'));
4747
} else {
4848
return this._uber.put({
49-
url: this.path + '/' + id,
49+
// this is required only for the PUT method
50+
url: 'sandbox/' + this.path + '/' + id,
5051
params: {
5152
surge_multiplier: parseFloat(multiplier)
5253
},
@@ -68,7 +69,8 @@ Products.prototype.setDriversAvailabilityByID = function setDriversAvailabilityB
6869
return callback(new Error('Availability needs to be a boolean'));
6970
} else {
7071
return this._uber.put({
71-
url: this.path + '/' + id,
72+
// this is required only for the PUT method
73+
url: 'sandbox/' + this.path + '/' + id,
7274
params: {
7375
drivers_available: availability
7476
},

Diff for: lib/resources/Requests.js

+87-64
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,131 @@
11
function Requests(uber) {
2-
this._uber = uber;
3-
this.path = 'requests';
2+
this._uber = uber;
3+
this.path = 'requests';
44

5-
// deprecated
6-
this.requestRide = this._uber.deprecateMethod(function requestRide(parameters, callback) {
7-
return this.create(parameters, callback);
8-
}, this.path + '.requestRide', this.path + '.create');
5+
// deprecated
6+
this.requestRide = this._uber.deprecateMethod(function requestRide(parameters, callback) {
7+
return this.create(parameters, callback);
8+
}, this.path + '.requestRide', this.path + '.create');
99

10-
this.estimate = this._uber.deprecateMethod(function estimate(parameters, callback) {
11-
return this.getEstimates(parameters, callback);
12-
}, this.path + '.estimate', this.path + '.getEstimates');
10+
this.estimate = this._uber.deprecateMethod(function estimate(parameters, callback) {
11+
return this.getEstimates(parameters, callback);
12+
}, this.path + '.estimate', this.path + '.getEstimates');
1313
}
1414

1515
module.exports = Requests;
1616

1717
Requests.prototype.create = function create(parameters, callback) {
18-
if (!parameters) {
19-
return callback(new Error('Invalid parameters'));
20-
}
21-
22-
return this._uber.post({ url: this.path, params: parameters }, callback);
18+
if (!parameters) {
19+
return callback(new Error('Invalid parameters'));
20+
}
21+
22+
return this._uber.post({
23+
url: this.path,
24+
params: parameters
25+
}, callback);
2326
};
2427

2528
Requests.prototype.getCurrent = function getCurrent(callback) {
26-
return this.getByID('current', callback);
29+
return this.getByID('current', callback);
2730
};
2831

2932
Requests.prototype.getByID = function getByID(id, callback) {
30-
if (!id) {
31-
return callback(new Error('Invalid request_id'));
32-
}
33+
if (!id) {
34+
return callback(new Error('Invalid request_id'));
35+
}
3336

34-
return this._uber.get({ url: this.path + '/' + id }, callback);
37+
return this._uber.get({
38+
url: this.path + '/' + id
39+
}, callback);
3540
};
3641

3742
Requests.prototype.getMapByID = function getMapByID(id, callback) {
38-
if (!id) {
39-
return callback(new Error('Invalid request_id'));
40-
}
43+
if (!id) {
44+
return callback(new Error('Invalid request_id'));
45+
}
4146

42-
return this._uber.get({ url: this.path + '/' + id + '/map'}, callback);
47+
return this._uber.get({
48+
url: this.path + '/' + id + '/map'
49+
}, callback);
4350
};
4451

4552
Requests.prototype.getReceiptByID = function getReceiptByID(id, callback) {
46-
if (!id) {
47-
return callback(new Error('Invalid request_id'));
48-
}
53+
if (!id) {
54+
return callback(new Error('Invalid request_id'));
55+
}
4956

50-
return this._uber.get({ url: this.path + '/' + id + '/receipt' }, callback);
57+
return this._uber.get({
58+
url: this.path + '/' + id + '/receipt'
59+
}, callback);
5160
};
5261

5362
Requests.prototype.updateCurrent = function updateCurrent(parameters, callback) {
54-
if (!parameters) {
55-
return callback(new Error('Invalid parameters'));
56-
}
63+
if (!parameters) {
64+
return callback(new Error('Invalid parameters'));
65+
}
5766

58-
return this.updateByID('current', parameters, callback);
67+
return this.updateByID('current', parameters, callback);
5968
};
6069

6170
Requests.prototype.updateByID = function updateByID(id, parameters, callback) {
62-
if (!id) {
63-
return callback(new Error('Invalid request_id'));
64-
}
65-
66-
if (!parameters) {
67-
return callback(new Error('Invalid parameters'));
68-
}
69-
70-
return this._uber.patch({ url: this.path + '/' + id, params: parameters }, callback);
71+
if (!id) {
72+
return callback(new Error('Invalid request_id'));
73+
}
74+
75+
if (!parameters) {
76+
return callback(new Error('Invalid parameters'));
77+
}
78+
79+
return this._uber.patch({
80+
url: this.path + '/' + id,
81+
params: parameters
82+
}, callback);
7183
};
7284

7385
Requests.prototype.setStatusByID = function setStatusByID(id, newSatus, callback) {
74-
if(!this._uber.sandbox) {
75-
return callback(new Error('PUT method for requests is only allowed in Sandbox mode'));
76-
}
77-
78-
if (!id) {
79-
return callback(new Error('Invalid request_id'));
80-
}
81-
82-
if (!newSatus) {
83-
return callback(new Error('Invalid status'));
84-
}
85-
86-
return this._uber.put({ url: this.path + '/' + id, params: { status: newSatus } }, callback);
86+
if (!this._uber.sandbox) {
87+
return callback(new Error('PUT method for requests is only allowed in Sandbox mode'));
88+
}
89+
90+
if (!id) {
91+
return callback(new Error('Invalid request_id'));
92+
}
93+
94+
if (!newSatus) {
95+
return callback(new Error('Invalid status'));
96+
}
97+
98+
return this._uber.put({
99+
// this is required only for the PUT method
100+
url: 'sandbox/' + this.path + '/' + id,
101+
params: {
102+
status: newSatus
103+
}
104+
},
105+
callback);
87106
};
88107

89108
Requests.prototype.deleteCurrent = function deleteCurrent(callback) {
90-
return this.deleteByID('current', callback);
109+
return this.deleteByID('current', callback);
91110
};
92111

93112
Requests.prototype.deleteByID = function deleteByID(id, callback) {
94-
if (!id) {
95-
return callback(new Error('Invalid request_id'));
96-
}
113+
if (!id) {
114+
return callback(new Error('Invalid request_id'));
115+
}
97116

98-
return this._uber.delete({ url: this.path + '/' + id }, callback);
117+
return this._uber.delete({
118+
url: this.path + '/' + id
119+
}, callback);
99120
};
100121

101122
Requests.prototype.getEstimates = function getEstimates(parameters, callback) {
102-
if (!parameters) {
103-
return callback(new Error('Invalid parameters'));
104-
}
105-
106-
return this._uber.post({
107-
url: this.path + '/estimate', arams: parameters }, callback);
123+
if (!parameters) {
124+
return callback(new Error('Invalid parameters'));
125+
}
126+
127+
return this._uber.post({
128+
url: this.path + '/estimate',
129+
arams: parameters
130+
}, callback);
108131
};

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-uber",
3-
"version": "0.9.5",
3+
"version": "0.9.6",
44
"description": "A Node.js wrapper for Uber API",
55
"main": "index.js",
66
"scripts": {

Diff for: test/products.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('Details', function() {
107107
describe('Set surge multiplier in Sandbox mode', function() {
108108
before(function() {
109109
nock('https://sandbox-api.uber.com/')
110-
.put('/v1/products/d4abaae7-f4d6-4152-91cc-77523e8165a4', {
110+
.put('/v1/sandbox/products/d4abaae7-f4d6-4152-91cc-77523e8165a4', {
111111
surge_multiplier: 2.2
112112
})
113113
.reply(204);
@@ -145,7 +145,7 @@ describe('Set surge multiplier in Sandbox mode', function() {
145145
describe('Set driver`s availability in Sandbox mode', function() {
146146
before(function() {
147147
nock('https://sandbox-api.uber.com/')
148-
.put('/v1/products/d4abaae7-f4d6-4152-91cc-77523e8165a4', {
148+
.put('/v1/sandbox/products/d4abaae7-f4d6-4152-91cc-77523e8165a4', {
149149
drivers_available: false
150150
})
151151
.reply(204);

Diff for: test/requests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ describe('By Request ID', function() {
281281
.times(2)
282282
.reply(204);
283283
nock('https://sandbox-api.uber.com/')
284-
.put('/v1/requests/17cb78a7-b672-4d34-a288-a6c6e44d5315', {
284+
.put('/v1/sandbox/requests/17cb78a7-b672-4d34-a288-a6c6e44d5315', {
285285
status: 'accepted'
286286
})
287287
.reply(204);

0 commit comments

Comments
 (0)