Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tride/grab-handler

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tride/grab-handler - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

35

index.js
const { create } = require("axios");
const ms = require("ms");

@@ -41,2 +42,6 @@ const ARBITRARY_STR = "ARBITRARY";

this.getCurrentRides = this.getCurrentRides.bind(this);
this.getEstimate = this.getMotorBikePrice;
this.requestRide = this.requestRide.bind(this);
this.cancelRide = this.cancelRide.bind(this);
}

@@ -80,2 +85,3 @@

const { fixed, lowerBound, upperBound, signature } = unsanitized[0];
// console.log(unsanitized[0]);
return {

@@ -87,3 +93,6 @@ price: {

},
requestKey: signature
requestKey: {
key: signature,
expiresAt: Date.now() + ms("5 minutes")
}
};

@@ -124,8 +133,16 @@ }

return await this.grabBase("/api/passenger/v3/rides", payload, {
headers: {
"User-Agent": "Grab/4.38.3 (Android 5.1.1)",
"Content-Type": "application/json; charset=UTF-8"
const { data } = await this.grabBase.post(
"/api/passenger/v3/rides",
payload,
{
headers: {
"User-Agent": "Grab/4.38.3 (Android 5.1.1)",
"Content-Type": "application/json; charset=UTF-8"
}
}
});
);
return {
requestId: data.code
};
}

@@ -142,4 +159,10 @@

}
async cancelRide(requestId) {
const url = `/api/passenger/v3/rides/${requestId}`;
const method = "delete";
return await this.fetch({ url, method });
}
}
module.exports = Grab;

5

package.json
{
"name": "@tride/grab-handler",
"version": "0.3.1",
"version": "0.4.0",
"main": "index.js",

@@ -9,3 +9,4 @@ "repository": "git@github.com:trride/grab-handler.git",

"dependencies": {
"axios": "^0.17.0"
"axios": "^0.17.0",
"ms": "^2.0.0"
},

@@ -12,0 +13,0 @@ "devDependencies": {

@@ -7,3 +7,9 @@ import test from "ava";

const exampleToken = process.env.GRAB_TOKEN;
const { getMotorBikePrice, getCurrentRides } = new Grab(exampleToken);
const {
getMotorBikePrice,
getCurrentRides,
getEstimate,
requestRide,
cancelRide
} = new Grab(exampleToken);

@@ -19,2 +25,5 @@ const TYPE = {

const TEST_START = { lat: -6.2266195, long: 106.8073293 };
const TEST_END = { lat: -6.2266182, long: 106.8073293 };
test("Sanity check", t => {

@@ -45,1 +54,16 @@ t.pass();

});
test("Book and Cancel", async t => {
const { price: { high }, requestKey: { key } } = await getEstimate(
TEST_START,
TEST_END
);
t.is(typeof key, TYPE.STRING);
t.is(typeof high, TYPE.NUMBER);
const { requestId } = await requestRide(key, TEST_START, TEST_END);
t.is(typeof requestId, TYPE.STRING);
const data = await cancelRide(requestId);
t.is(data, "");
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc