-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 935 Bytes
/
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
const client = require('./client')
// api
const chats = require('./api/chats')
const message = require('./api/message')
const user = require('./api/user')
const image = require('./api/image')
const event = require('./api/event')
const bitable = require('./api/bitable')
const spreadsheets = require('./api/spreadsheets')
// tools
const tools = require('./tools')
module.exports = async function (app_id, app_secret, config = {}) {
let token
if (!config.noCache) {
token = await client.getTenantToken(app_id, app_secret)
}
function FAPI(app_id, app_secret) {
this.app_id = app_id
this.app_secret = app_secret
if (!config.noCache) {
client.setToken(token)
}
return {
...this,
...client,
chats,
message,
user,
image,
event,
bitable,
spreadsheets,
tools,
}
}
return new FAPI(app_id, app_secret)
}
module.exports.tools = tools