New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

geartrack

Package Overview
Dependencies
Maintainers
2
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geartrack - npm Package Compare versions

Comparing version

to
2.7.0

src/dhlTracker.js

4

index.js

@@ -20,2 +20,4 @@ "use strict";

module.exports.panasia = require('./src/panasiaTracker')
module.exports.parcelTracker = require('./src/parcelTracker')
module.exports.pitneybowes = require('./src/pitneybowesTracker')
module.exports.dhl = require('./src/dhlTracker')
module.exports.track24 = require('./src/track24')
{
"name": "geartrack",
"version": "2.6.1",
"version": "2.7.0",
"description": "Tracking providers for Gearbest and AliExpress Orders.",

@@ -28,2 +28,3 @@ "main": "index.js",

"moment-timezone": "^0.5.11",
"request": "^2.81.0",
"requestretry": "^1.12.0",

@@ -30,0 +31,0 @@ "sprintf": "^0.1.5"

@@ -53,138 +53,43 @@ # Geartrack

// Get Sky 56 info
// Supports these ids: PQ, NL, LV, SY, GE, SB..
geartrack.sky.getInfo(id, (err, SkyInfo) => {
// Get [Traker] info
// with exception of "adicional" tracker, all the trackers work like bellow:
geartrack.[tracker].getInfo(id, (err, TrakerInfo) => {
if(err) { return }
console.log(SkyInfo.status) // see SkyInfo entity for more fields
console.log(TrakerInfo.status) // see TrakerInfo entity for more fields
})
// Get correos express info (when the package is in spain)
// ID is the provided from Gearbest PQ4F6P07XXXXXXXX750Z
// Postalcode is 4 digit like 1785 (Portuguese)
geartrack.correos.getInfo(id, postalcode, (err, CorreosInfo) => {
if(err) { return }
console.log(CorreosInfo.state) // see CorreosInfo entity for more fields
console.log(CorreosInfo.lastUpdate)
})
You just need to replace [Tracker] for one of the following available trackers:
- correos
- correosOld
- sky
- expresso24
- singpost
- ctt
- cainiao
- correoses
- directlink
- trackchinapost
- postNL
- yanwen
- malaysiaPos
- cjah
- winit
- panasia
- parcelTracker
- dhl
- track24
// Get adicional.pt info (when the package is in portugal)
// This info is only obtained after the correos express info
// ID is the provided from the Correos Express, CorreosInfo.id
// Postalcode is 4 digit like 1785
geartrack.adicional.getInfo(id, postalcode, (err, AdicionalInfo) => {
// Get adicional info
geartrack.adicional.getInfo(id, postalcode, (err, TrakerInfo) => {
if(err) { return }
console.log(AdicionalInfo.status) // see AdicionalInfo entity for more fields
console.log(AdicionalInfo.distributor)
})
// Get expresso24.pt info (when the package is in portugal)
// This info is only obtained after the correos express info
// ID is the provided from the Correos Express, CorreosInfo.product.ref
geartrack.expresso24.getInfo(id, (err, ExpressoInfo) => {
if(err) { return }
console.log(ExpressoInfo.status) // see ExpressoInfo entity for more fields
console.log(TrakerInfo.status) // see TrakerInfo entity for more fields
})
// Get www.singpost.com info (for aliexpress)
geartrack.singpost.getInfo(id, (err, SingpostInfo) => {
if(err) { return }
console.log(SingpostInfo.status) // see SingpostInfo entity for more fields
})
// Get www.cttexpresso.pt info (used in aliexpress buys)
geartrack.ctt.getInfo(id, (err, CttInfo) => {
if(err) { return }
console.log(CttInfo.status) // see CttInfo entity for more fields
})
// Get global.cainiao.com info (used in aliexpress buys)
geartrack.cainiao.getInfo(id, (err, CainiaoInfo) => {
if(err) { return }
console.log(CainiaoInfo.status) // see CainiaoInfo entity for more fields
})
// Get correos.es info (when the package is in spain)
// ID is the provided from Gearbest PQ4F6P07XXXXXXXX750Z
geartrack.correoses.getInfo(id, (err, CorreosESInfo) => {
if(err) { return }
console.log(CorreosESInfo.state) // see CorreosESInfo entity for more fields
})
// Get directlink info
// ID is the provided from AliExpress R..SE
geartrack.directlink.getInfo(id, (err, DirectLinkInfo) => {
if(err) { return }
console.log(DirectLinkInfo.state) // see DirectLinkInfo entity for more fields
})
// Get track-chinapost.com info
// ID is the provided from AliExpress R..CN
geartrack.trackchinapost.getInfo(id, (err, TrackChinaPostInfo) => {
if(err) { return }
console.log(TrackChinaPostInfo.state) // see TrackChinaPostInfo entity for more fields
})
// Get postNL.com info
// ID is the provided from AliExpress R..NL
geartrack.postNL.getInfo(id, (err, PostNLInfo) => {
if(err) { return }
console.log(PostNLInfo.state) // see PostNLInfo entity for more fields
})
// Get Yanwen.com.cn info
// ID is the provided from Ebay
geartrack.yanwen.getInfo(id, (err, YanwenInfo) => {
if(err) { return }
console.log(YanwenInfo.state) // see YanwenInfo entity for more fields
})
// Get http://www.pos.com.my/ info
geartrack.malaysiaPos.getInfo(id, (err, MalaysiaPosInfo) => {
if(err) { return }
console.log(MalaysiaPosInfo.state) // see MalaysiaPosInfo entity for more fields
})
// Get http://pts.cjah.co/ info
geartrack.cjah.getInfo(id, (err, CjahInfo) => {
if(err) { return }
console.log(CjahInfo.state) // see CjahInfo entity for more fields
})
// Get http://pts.cjah.co/ info
geartrack.winit.getInfo(id, (err, WinitInfo) => {
if(err) { return }
console.log(WinitInfo.state) // see WinitInfo entity for more fields
})
// Get http://www.faryaa.com/user/index/package-refer/type/track
geartrack.panasia.getInfo(id, (err, PanasiaInfo) => {
if(err) { return }
console.log(PanasiaInfo.states) // see PanasiaInfo entity for more fields
})
// Get https://parceltracking.pb.com/app/#/dashboard/
geartrack.parcelTracker.getInfo(id, (err, ParcelTrackerInfo) => {
if(err) { return }
console.log(ParcelTrackerInfo.states) // see ParcelTrackerInfo entity for more fields
})
```
### Changelog
- 17/05/2017 - Added support for track24
- 17/05/2017 - Added support for DHL
- 16/05/2017 - Added support for Parcel Tracker

@@ -191,0 +96,0 @@ - 26/04/2017 - Added support for Panasia, replaces sky56 for PQ ids

'use strict';
const request = require('requestretry').defaults({timeout: 10000, maxAttempts: 3, retryDelay: 500})
const request = require('requestretry').defaults({timeout: 10000, maxAttempts: 1, retryDelay: 500})
const sprintf = require('sprintf')

@@ -5,0 +5,0 @@ const utils = require('./utils')

@@ -0,0 +0,0 @@ 'use strict';

@@ -25,3 +25,3 @@ 'use strict';

url: URL.replace('{{id}}', id),
timeout: 30000
timeout: 20000
}, function (error, response, body) {

@@ -28,0 +28,0 @@ if (error || response.statusCode != 200) {

@@ -24,4 +24,4 @@ 'use strict';

*/
correos.getInfo = function (id, postalcode, cb) {
request(sprintf(URL, postalcode, id), function (error, response, body) {
correos.getInfo = function (id, cb) {
request(sprintf(URL, utils.getPostalCode(id), id), function (error, response, body) {
if (error || response.statusCode != 200) {

@@ -40,3 +40,3 @@ cb(utils.getError('DOWN'))

try {
entity = createCorreosEntity(body, id, postalcode)
entity = createCorreosEntity(body, id)
entity.retries = response.attempts

@@ -56,3 +56,3 @@ } catch (error) {

*/
function createCorreosEntity(html, id, postalcode) {
function createCorreosEntity(html, id) {
let $ = parser.load(html)

@@ -94,4 +94,3 @@

'states': states,
'id': id,
'postalcode': postalcode
'id': id
})

@@ -98,0 +97,0 @@ }

@@ -20,7 +20,6 @@ 'use strict';

* @param id
* @param postalcode
* @param callback(Error, CorreosInfo)
*/
correos.getInfo = function (id, postalcode, callback) {
obtainInfo(URL, id, postalcode, callback)
correos.getInfo = function (id, callback) {
obtainInfo(URL, id, callback)
}

@@ -36,3 +35,3 @@

*/
function obtainInfo(action, id, postalcode, cb) {
function obtainInfo(action, id, cb) {
request.post({

@@ -39,0 +38,0 @@ url: action,

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ 'use strict';

@@ -0,0 +0,0 @@ 'use strict';

@@ -8,31 +8,31 @@ const assert = require('chai').assert

describe('#Adicional', function() {
it('should extract the messages from the website with success', function(done) {
const id = '2016122222240929', code = 1750
adicional.getInfo(id, code, (err, info) => {
assert.isNull(err)
// describe('#Adicional', function() {
// it('should extract the messages from the website with success', function(done) {
// const id = '2016122222240929', code = 1750
// adicional.getInfo(id, code, (err, info) => {
// assert.isNull(err)
//
// assert.equal(info.date_expedition, '2016-12-24T00:00:00Z')
// assert.equal(info.service_type, 'ENTREGA')
// assert.equal(info.updated, '2016-12-27T15:57:00Z')
// assert.equal(info.status, 'DESCARTADO')
//
// console.log(id + ' attempts: ' + info.retries)
// done()
// })
//
// });
//
// it('should fail to extract', function(done) {
// const id = '423423424', code = 1750
// adicional.getInfo(id, code, (err, info) => {
// assert.isNotNull(err)
//
// done()
// })
//
// });
// });
assert.equal(info.date_expedition, '2016-12-24T00:00:00Z')
assert.equal(info.service_type, 'ENTREGA')
assert.equal(info.updated, '2016-12-27T15:57:00Z')
assert.equal(info.status, 'DESCARTADO')
console.log(id + ' attempts: ' + info.retries)
done()
})
});
it('should fail to extract', function(done) {
const id = '423423424', code = 1750
adicional.getInfo(id, code, (err, info) => {
assert.isNotNull(err)
done()
})
});
});
});

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -8,60 +8,60 @@ const assert = require('chai').assert

describe('#Cjah', function() {
it('should extract the messages from the website with success', function(done) {
const id = 'SB3000050456'
cjah.getInfo(id, (err, info) => {
assert.isNull(err)
// describe('#Cjah', function() {
// it('should extract the messages from the website with success', function(done) {
// const id = 'SB3000050456'
// cjah.getInfo(id, (err, info) => {
// assert.isNull(err)
//
// assert.equal(info.id, 'SB3000050456')
// assert.equal(info.state, 'Arrived at LISBON airport on 3/25/2017 12:42:00 PM')
// assert.deepEqual(info.states, [
// {
// "id": "SB3000050456",
// "date": "2017-03-25T12:42:00+08:00",
// "state": "Arrived at LISBON airport on 3/25/2017 12:42:00 PM"
// },
// {
// "id": "SB3000050456",
// "date": "2017-03-23T09:54:14+08:00",
// "state": "Dispatch out from transit airport"
// },
// {
// "id": "SB3000050456",
// "date": "2017-03-22T10:55:58+08:00",
// "state": "Transit out from HKG"
// },
// {
// "id": "SB3000050456",
// "date": "2017-03-19T11:17:59+08:00",
// "state": "Dispatch to PORTUGAL"
// },
// {
// "id": "SB3000050456",
// "date": "2017-03-18T12:01:15+08:00",
// "state": "Posting over the counter"
// },
// {
// "id": "SB3000050456",
// "date": "2017-03-17T00:00:00+08:00",
// "state": "Pre-Check to PORTUGAL"
// }
// ])
//
// done()
// })
//
// });
//
// it('should fail to extract', function(done) {
// const id = 'AB'
// cjah.getInfo(id, (err, info) => {
// assert.isNotNull(err)
//
// done()
// })
//
// });
// });
assert.equal(info.id, 'SB3000050456')
assert.equal(info.state, 'Arrived at LISBON airport on 3/25/2017 12:42:00 PM')
assert.deepEqual(info.states, [
{
"id": "SB3000050456",
"date": "2017-03-25T12:42:00+08:00",
"state": "Arrived at LISBON airport on 3/25/2017 12:42:00 PM"
},
{
"id": "SB3000050456",
"date": "2017-03-23T09:54:14+08:00",
"state": "Dispatch out from transit airport"
},
{
"id": "SB3000050456",
"date": "2017-03-22T10:55:58+08:00",
"state": "Transit out from HKG"
},
{
"id": "SB3000050456",
"date": "2017-03-19T11:17:59+08:00",
"state": "Dispatch to PORTUGAL"
},
{
"id": "SB3000050456",
"date": "2017-03-18T12:01:15+08:00",
"state": "Posting over the counter"
},
{
"id": "SB3000050456",
"date": "2017-03-17T00:00:00+08:00",
"state": "Pre-Check to PORTUGAL"
}
])
done()
})
});
it('should fail to extract', function(done) {
const id = 'AB'
cjah.getInfo(id, (err, info) => {
assert.isNotNull(err)
done()
})
});
});
});

@@ -12,4 +12,4 @@ const assert = require('chai').assert

it('should correct company name: zambitious s¿l to zambitious sl', function(done) {
const id = 'PQ4F6P0705159770184410W', code = 4410
correos.getInfo(id, code, (err, info) => {
const id = 'PQ4F6P0705159770184410W'
correos.getInfo(id, (err, info) => {
assert.isNull(err)

@@ -27,4 +27,4 @@

it('should fail to extract', function(done) {
const id = '423423424', code = 1750
correos.getInfo(id, code, (err, info) => {
const id = '423423424'
correos.getInfo(id, (err, info) => {
assert.isNotNull(err)

@@ -31,0 +31,0 @@

@@ -11,3 +11,3 @@ const assert = require('chai').assert

const id = 'PQ4F6P0705905960188365S', code = 1750
correos.getInfo(id, code, (err, info) => {
correos.getInfo(id, (err, info) => {
assert.isNull(err)

@@ -31,3 +31,3 @@

const id = 'PQ4F6P0705248940181750G', code = 1750
correos.getInfo(id, code, (err, info) => {
correos.getInfo(id, (err, info) => {
assert.isNull(err)

@@ -91,3 +91,3 @@

const id = 'PQ4F6P070524894018175000000G', code = 1750
correos.getInfo(id, code, (err, info) => {
correos.getInfo(id, (err, info) => {
assert.isNotNull(err)

@@ -94,0 +94,0 @@

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

@@ -0,0 +0,0 @@ const assert = require('chai').assert

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet