-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_helper.js
27 lines (23 loc) · 875 Bytes
/
node_helper.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
const NodeHelper = require("node_helper");
const request = require("request");
module.exports = NodeHelper.create({
start: function() {
console.log("MMM-FieldHockey-FFH helper started...");
},
socketNotificationReceived: function(notification, payload) {
if (notification === "GET_RANKINGS") {
this.getRankings(payload);
}
},
getRankings: function(apiUrl) {
var self = this;
request(apiUrl, function(error, response, body) {
if (!error && response.statusCode == 200) {
var data = JSON.parse(body);
if (data.Response && data.Response.Classement && data.Response.Classement.ClassmentLignes) {
self.sendSocketNotification("RANKINGS_RESULT", data.Response.Classement.ClassmentLignes);
}
}
});
}
});