-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
92 lines (77 loc) · 1.93 KB
/
index.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
const OAuth2 = require('oauth20');
const { streamlabsAPI } = require('./lib/utils/urls');
const { get: getCredentials, set: setCredentials, setUser } = require('./lib/credentials');
const donations = require('./lib/donations');
const alerts = require('./lib/alerts');
const alertsActions = require('./lib/alerts/actions');
const { types: alertsTypes } = require('./lib/alerts/types');
const points = require('./lib/loyalty');
const pointsTypes = require('./lib/loyalty/types');
const user = require('./lib/user');
const credits = require('./lib/credits');
const jar = require('./lib/jar');
const wheel = require('./lib/wheel');
const webSocket = require('./lib/socket');
/**
* Object param ->
* @param {string} clientId
* @param {string} clientSecret
* @param {string} redirectUrl
* @param {string} scopes
* @param {string} socketToken
* @param {string} accessToken
*/
class Streamlabs extends OAuth2 {
constructor({
clientId, clientSecret, redirectUrl, scopes, socketToken = '', accessToken = '',
}) {
super(clientId, clientSecret, redirectUrl, scopes, accessToken, streamlabsAPI);
this.socketToken = socketToken;
this.donations = {
...donations,
};
this.alerts = {
...alerts,
actions: {
...alertsActions,
},
types: {
...alertsTypes,
},
};
this.loyalty = {
...points,
types: {
...pointsTypes,
},
};
this.credits = {
...credits,
};
this.jar = {
...jar,
};
this.wheel = {
...wheel,
};
}
/**
* @param {string} code
*/
async connect(code) {
await super.connect(code);
setCredentials({
...super.getCredentials(),
socketToken: this.socketToken,
});
setUser(await user());
return getCredentials();
}
credentials() {
return getCredentials();
}
connectWebSocket() {
return webSocket();
}
}
module.exports = Streamlabs;