-
Notifications
You must be signed in to change notification settings - Fork 83
/
index.js
72 lines (58 loc) · 1.53 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
const api = require('./src/api');
const callback = require('./src/callback');
const config = require('./src/config');
const connect = require('./src/connect');
const Promise = require('es6-promise').Promise;
const Recorder = require('./src/recorder/recorder');
const stream = require('./src/stream');
module.exports = global.SC = {
initialize (options = {}) {
// set tokens
config.set('oauth_token', options.oauth_token);
config.set('client_id', options.client_id);
config.set('redirect_uri', options.redirect_uri);
config.set('baseURL', options.baseURL);
config.set('connectURL', options.connectURL);
},
/** API METHODS */
get (path, params) {
return api.request('GET', path, params);
},
post (path, params) {
return api.request('POST', path, params);
},
put (path, params) {
return api.request('PUT', path, params);
},
delete (path) {
return api.request('DELETE', path);
},
upload (options) {
return api.upload(options);
},
/** CONNECT METHODS */
connect (options) {
return connect(options);
},
isConnected () {
return config.get('oauth_token') !== undefined;
},
/** OEMBED METHODS */
oEmbed (url, options) {
return api.oEmbed(url, options);
},
/** RESOLVE METHODS */
resolve (url) {
return api.resolve(url);
},
/** RECORDER */
Recorder: Recorder,
/** PROMISE **/
Promise: Promise,
stream (trackPath, secretToken) {
return stream(trackPath, secretToken);
},
connectCallback () {
callback.notifyDialog(this.location);
}
};