-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tracker.js
28 lines (24 loc) · 816 Bytes
/
Tracker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* Magic Mirror
* Module: MMM-ShipmentTracking
*
* By fewieden https://github.com/fewieden/MMM-ShipmentTracking
* MIT Licensed.
*/
/* eslint-env node */
const carriers = ['DHL', 'Landmark', '17track'];
module.exports = () => ({
track(carrier, ids, language) {
if (carriers.includes(carrier)) {
// eslint-disable-next-line global-require, import/no-dynamic-require
const track = require(`./carriers/${carrier}.js`).track;
return new Promise((resolve, reject) => {
track(ids, language)
.then((res) => { resolve(res); })
.catch((res) => { reject(res); });
});
}
return new Promise((resolve, reject) => {
reject({ error: 'Carrier is not supported!' });
});
}
});