-
Notifications
You must be signed in to change notification settings - Fork 10
/
groups.js
107 lines (82 loc) · 3.63 KB
/
groups.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* Created by qeesung on 2017/4/29.
*/
const pageQueryMapping = require("./lists/pageQueryMapper");
class Groups {
constructor(client) {
this.client = client;
}
addAll(roomId, activeUsersOnly, callback) {
return this.client.request("POST", "groups.addAll", {roomId, activeUsersOnly}, callback);
}
addModerator(roomId, userId, callback) {
return this.client.request("POST", "groups.addModerator", {roomId, userId}, callback);
}
removeModerator(roomId, userId, callback) {
return this.client.request("POST", "groups.removeModerator", {roomId, userId}, callback);
}
addOwner(roomId, userId, callback) {
return this.client.request("POST", "groups.addOwner", {roomId, userId}, callback);
}
archive(roomId, callback) {
return this.client.request("POST", "groups.archive", {roomId}, callback);
}
unarchive(roomId, callback) {
return this.client.request("POST", "groups.unarchive", {roomId}, callback);
}
close(roomId, callback) {
return this.client.request("POST", "groups.close", {roomId}, callback);
}
create (name, members, callback) {
return this.client.request("POST", "groups.create", { name, members}, callback);
}
getIntegrations(roomId, { offset = 0, count = 0, sort = undefined, fields = undefined, query = undefined} ={}, callback) {
let options = {roomId};
Object.assign(options, pageQueryMapping(arguments[1]));
return this.client.request("GET", "groups.getIntegrations", options, callback);
}
history(hisOptions, { offset = 0, count = 0, sort = undefined, fields = undefined, query = undefined} ={}, callback) {
Object.assign(hisOptions, arguments[1]);
return this.client.request("GET", "groups.history", hisOptions, callback);
}
info (roomId, callback) {
return this.client.request("GET", "groups.info", {roomId}, callback);
}
kick (roomId, userId, callback) {
return this.client.request("POST", "groups.kick", {roomId, userId}, callback);
}
invite(roomId, userId, callback) {
return this.client.request("POST", "groups.invite", {roomId, userId}, callback);
}
leave(roomId, callback) {
return this.client.request("POST", "groups.leave", {roomId}, callback);
}
open(roomId, callback) {
return this.client.request("POST", "groups.open", {roomId}, callback);
}
list ({ offset = 0, count = 0, sort = undefined, fields = undefined, query = undefined} ={}, callback) {
return this.client.request("GET", "groups.list", pageQueryMapping(arguments[0]), callback);
}
removeOwner(roomId, userId, callback) {
return this.client.request("POST", "groups.removeOwner", {roomId, userId}, callback);
}
rename(roomId, name, callback) {
return this.client.request("POST", "groups.rename", {roomId, name}, callback);
}
setDescription(roomId, description, callback) {
return this.client.request("POST", "groups.setDescription", {roomId, description}, callback);
}
setPurpose(roomId, purpose, callback) {
return this.client.request("POST", "groups.setPurpose", {roomId, purpose}, callback);
}
setReadOnly(roomId, readOnly, callback) {
return this.client.request("POST", "groups.setReadOnly", {roomId, readOnly}, callback);
}
setTopic (roomId, topic, callback) {
return this.client.request("POST", "groups.setTopic", {roomId, topic}, callback);
}
setType(roomId, type, callback) {
return this.client.request("POST", "groups.setType", {roomId, type}, callback);
}
}
module.exports = Groups;