@tride/grab-handler
Advanced tools
Comparing version 0.4.3 to 0.4.4
63
index.js
@@ -0,1 +1,2 @@ | ||
require('dotenv').config() | ||
const { create } = require("axios"); | ||
@@ -15,4 +16,7 @@ const ms = require("ms"); | ||
} | ||
this.baseURL = process.env.NODE_ENV == 'development' ? process.env.DEV_BASE_URL + '/grab' : 'https://p.grabtaxi.com' | ||
this.grabBase = create({ | ||
baseURL: "https://p.grabtaxi.com", | ||
baseURL: this.baseURL, | ||
responseType: "json", | ||
@@ -145,3 +149,58 @@ timeout: 10000, | ||
async rideStatus(rideId) { | ||
return await this.grabBase.get(`/api/passenger/v3/rides/${rideId}/status`); | ||
return this.grabBase | ||
.get(`/api/passenger/v3/rides/${rideId}/status`) | ||
.then(response => { | ||
const { data } = response | ||
const driver = { | ||
name: "Dummy Driver", | ||
rating: 4.8, | ||
pictureUrl: "http://google.com", | ||
phoneNumber: "081234567890", | ||
vehicle: { | ||
plate: "B 1234 AA", | ||
name: "Honda Vario" | ||
} | ||
} | ||
const payload = { | ||
service: 'grab', | ||
requestId: rideId, | ||
driver | ||
} | ||
let status = data.status ? data.status.toLowerCase() : data.reason.toLowerCase() | ||
if (status == 'allocated' && data.activeStepIndex > 0) | ||
status = 'on_the_way' | ||
const result = { | ||
'allocating': { | ||
status: 'processing', | ||
...payload | ||
}, | ||
'unallocated': { | ||
status: 'not_found', | ||
...payload | ||
}, | ||
'allocated': { | ||
status: 'accepted', | ||
...payload | ||
}, | ||
'cancelled': { | ||
status: 'canceled', | ||
...payload | ||
}, | ||
'on_the_way': { | ||
status: 'on_the_way', | ||
...payload | ||
}, | ||
'completed': { | ||
status: 'completed', | ||
...payload | ||
} | ||
} | ||
return result[status] | ||
}) | ||
} | ||
@@ -148,0 +207,0 @@ |
{ | ||
"name": "@tride/grab-handler", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:trride/grab-handler.git", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
118484
311
0
5