uber-handler
Advanced tools
Comparing version 0.4.4 to 0.4.5
52
index.js
@@ -6,2 +6,3 @@ const Axios = require("axios"); | ||
constructor(config) { | ||
this.service_name = "uber"; | ||
this.token = config.token || ""; | ||
@@ -32,2 +33,3 @@ this.access_token = config.access_token || ""; | ||
this.cancelCurrentRide = this.cancelCurrentRide.bind(this); | ||
this.rideStatus = this.rideStatus.bind(this); | ||
} | ||
@@ -53,2 +55,3 @@ | ||
return { | ||
service: this.service_name, | ||
price: data.fare.value, | ||
@@ -93,2 +96,3 @@ requestKey: { | ||
return { | ||
service: this.service_name, | ||
requestId: response.data.request_id | ||
@@ -99,2 +103,48 @@ } | ||
rideStatus(requestId) { | ||
return this.axios | ||
.get(`/requests/${requestId}`) | ||
.then(response => { | ||
const { data } = response | ||
const driver = data.driver && data.vehicle && { | ||
name: data.driver.name, | ||
rating: data.driver.rating, | ||
pictureUrl: data.driver.picture_url, | ||
phoneNumber: data.driver.phone_number, | ||
vehicle: { | ||
plate: data.vehicle.licence_plate, | ||
name: data.vehicle.make + data.vehicle.model | ||
} | ||
} | ||
const payload = { | ||
service: this.service_name, | ||
requestId: data.request_id, | ||
driver | ||
} | ||
const result = { | ||
'processing': { | ||
status: 'processing', | ||
...payload | ||
}, | ||
'accepted': { | ||
status: 'accepted', | ||
...payload | ||
}, | ||
'in_progress': { | ||
status: 'on_the_way', | ||
...payload | ||
}, | ||
'completed': { | ||
status: 'completed', | ||
...payload | ||
} | ||
} | ||
return result[data.status] | ||
}) | ||
} | ||
cancelCurrentRide() { | ||
@@ -105,2 +155,3 @@ return this.axios | ||
return { | ||
service: this.service_name, | ||
cancelled: true | ||
@@ -116,2 +167,3 @@ } | ||
return { | ||
service: this.service_name, | ||
cancelled: true | ||
@@ -118,0 +170,0 @@ } |
{ | ||
"name": "uber-handler", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4513
147