-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnode_helper.js
39 lines (36 loc) · 1.22 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
/* Magic Mirror
* Node Helper: MMM-LOLESPORTS-SCHEDULES
*
* By xadamxk
* MIT Licensed.
*/
var NodeHelper = require("node_helper");
var LolesportsApi = require("esm")(module)("lolesports-js-sdk");
var defaultClient = LolesportsApi.ApiClient.instance;
var api = new LolesportsApi.EventsApi();
module.exports = NodeHelper.create({
// Override socketNotificationReceived method.
socketNotificationReceived: function (notification, payload) {
let self = this;
if (notification === "MMM-LOLESPORTS-SCHEDULES-GET-SCHEDULE") {
defaultClient.basePath = payload["basePath"];
defaultClient.authentications["apiKeyAuth"]["apiKey"] = payload["apiKey"];
api.getSchedule(
LolesportsApi.Locale.enUS,
{ leagueId: payload["leagueId"] },
function (error, data, response) {
if (error) {
console.error(error);
} else {
// console.log("API called successfully. Returned data: " + JSON.stringify(data));
self.sendNotificationTest(data);
}
}
);
}
},
// Example function send notification test
sendNotificationTest: function (payload) {
this.sendSocketNotification("MMM-LOLESPORTS-SCHEDULES-SCHEDULE", payload);
},
});