-
Notifications
You must be signed in to change notification settings - Fork 0
/
LaMetricApi.js
66 lines (56 loc) · 1.93 KB
/
LaMetricApi.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
66
module.exports = {
/**
* Method: buildResponse
* @return json
* returns LaMetric readable Json
*/
buildResponse: function(req, data) {
// Building object for LaMetric. We will return it
var responseObj = {};
responseObj.frames = [];
index = 0;
var leagues = req.query.leagues.split(',');
var spaceLessLeagues = [];
// Removing white spaces
leagues.forEach(element => {
element = element.replace(/\s+/g, '');
spaceLessLeagues.push(element);
});
if (!data) {
return false;
} else {
data.LeaderboardRankings.forEach(element => {
if (spaceLessLeagues.indexOf(element.GameMode) >= 0) {
var frame = {
'index': index,
'text': element.GameMode,
'icon': 'i280',
};
index++;
switch (element.LeagueID) {
case 0:
frame.icon = "i635"; // Master icon
break;
case 1:
frame.icon = "i5273"; // Diams icon
break;
case 2:
frame.icon = "i5271"; // Plat icon
break;
case 3:
frame.icon = "i5274"; // Gold icon
break;
case 4:
frame.icon = "i5270"; // Silver icon
break;
case 5:
frame.icon = "i5269"; // Bronze icon
break;
}
responseObj.frames.push(frame);
}
});
return responseObj;
}
},
}