generated from bitfocus/companion-module-template-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
59 lines (51 loc) · 1.25 KB
/
main.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
const {
InstanceBase,
runEntrypoint,
InstanceStatus,
} = require("@companion-module/base");
const { GraphQLClient } = require("graphql-request");
const UpgradeScripts = require("./upgrades");
const UpdateActions = require("./actions");
class ModuleInstance extends InstanceBase {
constructor(internal) {
super(internal);
}
async init(config) {
this.config = config;
const soundtrackURL = "https://api.soundtrackyourbrand.com/v2";
if (this.config.api_key) {
this.api_key = this.config.api_key;
this.client = new GraphQLClient(soundtrackURL, {
headers: { authorization: `Basic ${this.api_key}` },
});
this.updateStatus(InstanceStatus.Ok);
}
this.updateActions(); // export actions
}
// When module gets deleted
async destroy() {
this.log("debug", "destroy");
}
async configUpdated(config) {
this.init(config);
}
// Return config fields for web config
getConfigFields() {
return [
{
type: "textinput",
id: "api_key",
label: "API Key",
},
{
type: "textinput",
id: "zone_id",
label: "Zone ID",
},
];
}
updateActions() {
UpdateActions(this);
}
}
runEntrypoint(ModuleInstance, UpgradeScripts);