@tride/gojek-handler
Advanced tools
Comparing version 1.0.2 to 1.0.3
28
index.js
const axios = require("axios"); | ||
const ms = require("ms"); | ||
const Handler = require("@tride/basic-handler"); | ||
const handleError = err => new Promise((_, reject) => reject(err)); | ||
const authenticate = (userData, actual = false) => { | ||
@@ -66,4 +65,5 @@ let body = { | ||
class GojekHandler { | ||
class GojekHandler extends Handler { | ||
constructor(config) { | ||
super(config); | ||
this.token = config && config.token; | ||
@@ -82,20 +82,2 @@ this.Authorization = `Bearer ${this.token}`; | ||
} | ||
handleRequest(config) { | ||
return new Promise((resolve, reject) => { | ||
this.request(config) | ||
.then(({ data }) => { | ||
data.service = "gojek"; | ||
resolve(data); | ||
}) | ||
.catch(err => { | ||
let errData; | ||
if (err.response && err.response.data) { | ||
errData = err.response.data; | ||
} else { | ||
errData = err.toString(); | ||
} | ||
reject(errData); | ||
}); | ||
}); | ||
} | ||
@@ -174,3 +156,3 @@ getMotorBikePrice(start, end, actual = false) { | ||
if (!orderNo) { | ||
handleError("No order found"); | ||
this.handleError(new Error("No order found")); | ||
} | ||
@@ -232,3 +214,3 @@ | ||
if (!orderNo) { | ||
handleError("No Order Number Given"); | ||
this.handleError(new Error("No Order Number Given")); | ||
} | ||
@@ -235,0 +217,0 @@ |
{ | ||
"name": "@tride/gojek-handler", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Gojek Handler", | ||
@@ -21,2 +21,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@tride/basic-handler": "^0.0.0", | ||
"axios": "^0.17.0", | ||
@@ -23,0 +24,0 @@ "ms": "^2.0.0", |
@@ -15,4 +15,5 @@ import test from "ava"; | ||
test("Class", t => { | ||
test("Class", async t => { | ||
let g = new Gojek(); | ||
// await g.rideStatus(); | ||
t.is(g instanceof Gojek, true); | ||
@@ -19,0 +20,0 @@ }); |
Sorry, the diff of this file is not supported yet
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
124410
4
394
+ Added@tride/basic-handler@^0.0.0
+ Added@tride/basic-handler@0.0.0(transitive)