forked from elanic-tech/angarum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.js
65 lines (56 loc) · 1.44 KB
/
testing.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require('dotenv').config();
a = require("./index.js");
partners = [
"Pickrr",
"Pyck",
"Pigeon",
"Delhivery",
"NuvoEx",
"ShadowFax",
"XpressBees",
];
awbs = [
["2176623089901", "2176623089901"],
"",
["UNIPINC358428", "UNIPINC358428"],
["988110029595", "988110029595"],
["ELC0000900", "ELC0000900"],
["P54010228"],
["110AP04007955"],
];
var test_order = {
to_city: "a new Delhi d",
}
queue = {};
function add(type) {
return function(res, body) {
if (res)
body.add('response_code', res.statusCode);
else
body.add('response_code', "Das lakh");
queue[type] = body;
if (Object.keys(queue).length == Object.keys(partners).length * 4)
print_results();
};
};
function print_results() {
console.log("Results:");
var keys = Object.keys(queue);
keys.sort();
keys.forEach(function(elem) {
console.log(elem);
console.log(queue[elem].get());
});
};
for (ind in partners) {
var name = partners[ind];
var partner = a.Partner(name);
var order = new a.Order(test_order);
partner.order(order, add(name + " place order"));
var cancel = new a.Cancel();
partner.cancel(cancel, add(name + " cancel order"));
var track = new a.Track();
var tracking_status = new a.TrackingStatus({"awb_number" : awbs[ind]});
partner.track(track, add(name + " track order"));
partner.tracking_status(tracking_status, add(name + " tracking status order"));
}