-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfg-api.js
101 lines (93 loc) · 2.26 KB
/
sfg-api.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
const request = require('request');
const baseUrl = 'http://world-cup-json.herokuapp.com';
var exports = module.exports = {};
const matches = [];
exports.getCurrentMatch = function()
{
return new Promise(function(resolve, reject) {
request(baseUrl+'/matches/current', function (error, response, body) {
if (!error && response.statusCode==200) {
resolve(JSON.parse(body));
}
else {
console.log(error);
reject(error);
}
});
});
}
exports.getAllMatches = function()
{
return new Promise(function(resolve, reject) {
request(baseUrl+'/matches/?by_date=asc',function (error, response, body) {
if(!error && response.statusCode == 200) {
let data = JSON.parse(body);
for (var i=0; i<data.length; i++) {
matches[i] = data[i];
}
resolve(matches)
} else {
reject(matches)
}
});
});
}
exports.getMatchesToday = function()
{
return new Promise(function(resolve, reject) {
request(baseUrl+'/matches/today',function (error, response, body) {
if(!error && response.statusCode == 200) {
resolve(JSON.parse(body));
} else {
reject(error);
}
});
});
}
exports.getMatch = function (fifa_id) {
console.log('getting single');
console.log(fifa_id);
return new Promise(function(resolve, reject) {
request(baseUrl+'/matches/'+fifa_id,function (error, response, body) {
if(!error && response.statusCode == 200) {
resolve(JSON.parse(body));
} else {
reject(error);
}
});
});
}
exports.emojiMapping = {
"ARG": "🇦🇷",
"ISL": "🇮🇸",
"PER": "🇵🇪",
"DEN": "🇩🇰",
"CRO": "🇭🇷",
"NGA": "🇳🇬",
"SRB": "🇷🇸",
"GER": "🇩🇪",
"MEX": "🇲🇽",
"BRA": "🇧🇷",
"SUI": "🇨🇭",
"KSA": "🇸🇦",
"URU": "🇺🇾",
"POR": "🇵🇹",
"ESP": "🇪🇸",
"MAR": "🇲🇦",
"IRN": "🇮🇷",
"FRA": "🇫🇷",
"AUS": "🇦🇺",
"SWE": "🇸🇪",
"BEL": "🇧🇪",
"PAN": "🇵🇦",
"TUN": "🇹🇳",
"ENG": "🏴",
"COL": "🇨🇴",
"JPN": "🇯🇵",
"POL": "🇵🇱",
"SEN": "🇸🇳",
"RUS": "🇷🇺",
"EGY": "🇪🇬",
"KOR": "🇰🇷",
"CRC": "🇨🇷"
}