delivery-tracker
Advanced tools
Comparing version 2.7.0 to 2.7.1
@@ -0,1 +1,7 @@ | ||
# 2.7.1 | ||
* fixed an issue in JNT is not working | ||
# 2.7.0 | ||
* add canada post | ||
# 2.6.1 | ||
@@ -2,0 +8,0 @@ * add courier namespace for DHL. |
@@ -10,11 +10,23 @@ 'use strict' | ||
return { | ||
method: 'POST', | ||
url: 'https://www.jtexpress.ph/index/router/index.html', | ||
json: true, | ||
body: { | ||
method: 'app.findTrack', | ||
data: { | ||
billcode: number, | ||
lang: 'en', | ||
source: 3 | ||
cookie: { | ||
url: 'https://www.jtexpress.ph/index/query/gzquery.html', | ||
method: 'GET' | ||
}, | ||
track: { | ||
method: 'POST', | ||
url: 'https://www.jtexpress.ph/index/router/index.html', | ||
json: true, | ||
headers: { | ||
'X-SimplyPost-Id': 'testtesttest', | ||
'X-SimplyPost-Signature': '712d5af47cd24adf54fe39ebc4ed0aea' | ||
}, | ||
body: { | ||
method: 'app.findTrack', | ||
data: { | ||
billcode: number, | ||
lang: 'en', | ||
source: 3 | ||
}, | ||
pId: 'testtesttest', | ||
pst: '712d5af47cd24adf54fe39ebc4ed0aea' | ||
} | ||
@@ -71,19 +83,25 @@ } | ||
var tracking = trackingInfo(number) | ||
var req = request.defaults({ jar: true }) | ||
request(tracking, function (err, res, body) { | ||
req(tracking.cookie, function (err, res, body) { | ||
if (err) { | ||
return cb(err) | ||
} | ||
req(tracking.track, function (err, res, body) { | ||
if (err) { | ||
return cb(err) | ||
} | ||
try { | ||
if (res.statusCode !== 200) { | ||
return cb(tracker.error(res.statusMessage)) | ||
} else if (body.code !== 20000) { | ||
return cb(tracker.error(body.code, body.desc)) | ||
try { | ||
if (res.statusCode !== 200) { | ||
return cb(tracker.error(res.statusMessage)) | ||
} else if (body.code !== 20000) { | ||
return cb(tracker.error(body.code, body.desc)) | ||
} | ||
var result = parser.trace(JSON.parse(body.data)) | ||
cb(result ? null : tracker.error(tracker.ERROR.INVALID_NUMBER), result) | ||
} catch (e) { | ||
cb(tracker.error(e.message)) | ||
} | ||
var result = parser.trace(JSON.parse(body.data)) | ||
cb(result ? null : tracker.error(tracker.ERROR.INVALID_NUMBER), result) | ||
} catch (e) { | ||
cb(tracker.error(e.message)) | ||
} | ||
}) | ||
}) | ||
@@ -90,0 +108,0 @@ } |
{ | ||
"name": "delivery-tracker", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "egg", |
87657
2484