-
Notifications
You must be signed in to change notification settings - Fork 662
/
Copy pathgroups.js
302 lines (251 loc) · 9.26 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
/**
* API Facet to make calls to methods in the groups namespace.
*
* This provides functions to call:
* - archive: {@link https://api.slack.com/methods/groups.archive|groups.archive}
* - close: {@link https://api.slack.com/methods/groups.close|groups.close}
* - create: {@link https://api.slack.com/methods/groups.create|groups.create}
* - createChild: {@link https://api.slack.com/methods/groups.createChild|groups.createChild}
* - history: {@link https://api.slack.com/methods/groups.history|groups.history}
* - info: {@link https://api.slack.com/methods/groups.info|groups.info}
* - invite: {@link https://api.slack.com/methods/groups.invite|groups.invite}
* - kick: {@link https://api.slack.com/methods/groups.kick|groups.kick}
* - leave: {@link https://api.slack.com/methods/groups.leave|groups.leave}
* - list: {@link https://api.slack.com/methods/groups.list|groups.list}
* - mark: {@link https://api.slack.com/methods/groups.mark|groups.mark}
* - open: {@link https://api.slack.com/methods/groups.open|groups.open}
* - rename: {@link https://api.slack.com/methods/groups.rename|groups.rename}
* - setPurpose: {@link https://api.slack.com/methods/groups.setPurpose|groups.setPurpose}
* - setTopic: {@link https://api.slack.com/methods/groups.setTopic|groups.setTopic}
* - unarchive: {@link https://api.slack.com/methods/groups.unarchive|groups.unarchive}
*
*/
function GroupsFacet(makeAPICall) {
this.name = 'groups';
this.makeAPICall = makeAPICall;
}
/**
* Archives a private channel.
* @see {@link https://api.slack.com/methods/groups.archive|groups.archive}
*
* @param {?} channel - Private channel to archive
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.archive = function archive(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.archive', requiredArgs, null, optCb);
};
/**
* Closes a private channel.
* @see {@link https://api.slack.com/methods/groups.close|groups.close}
*
* @param {?} channel - Private channel to close.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.close = function close(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.close', requiredArgs, null, optCb);
};
/**
* Creates a private channel.
* @see {@link https://api.slack.com/methods/groups.create|groups.create}
*
* @param {?} name - Name of private channel to create
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.create = function create(name, optCb) {
var requiredArgs = {
name: name
};
return this.makeAPICall('groups.create', requiredArgs, null, optCb);
};
/**
* Clones and archives a private channel.
* @see {@link https://api.slack.com/methods/groups.createChild|groups.createChild}
*
* @param {?} channel - Private channel to clone and archive.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.createChild = function createChild(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.createChild', requiredArgs, null, optCb);
};
/**
* Fetches history of messages and events from a private channel.
* @see {@link https://api.slack.com/methods/groups.history|groups.history}
*
* @param {?} channel - Private channel to fetch history for.
* @param {Object=} opts
* @param {?} opts.latest - End of time range of messages to include in results.
* @param {?} opts.oldest - Start of time range of messages to include in results.
* @param {?} opts.inclusive - Include messages with latest or oldest timestamp in results.
* @param {?} opts.count - Number of messages to return, between 1 and 1000.
* @param {?} opts.unreads - Include `unread_count_display` in the output?
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.history = function history(channel, opts, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.history', requiredArgs, opts, optCb);
};
/**
* Gets information about a private channel.
* @see {@link https://api.slack.com/methods/groups.info|groups.info}
*
* @param {?} channel - Private channel to get info on
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.info = function info(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.info', requiredArgs, null, optCb);
};
/**
* Invites a user to a private channel.
* @see {@link https://api.slack.com/methods/groups.invite|groups.invite}
*
* @param {?} channel - Private channel to invite user to.
* @param {?} user - User to invite.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.invite = function invite(channel, user, optCb) {
var requiredArgs = {
channel: channel,
user: user
};
return this.makeAPICall('groups.invite', requiredArgs, null, optCb);
};
/**
* Removes a user from a private channel.
* @see {@link https://api.slack.com/methods/groups.kick|groups.kick}
*
* @param {?} channel - Private channel to remove user from.
* @param {?} user - User to remove from private channel.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.kick = function kick(channel, user, optCb) {
var requiredArgs = {
channel: channel,
user: user
};
return this.makeAPICall('groups.kick', requiredArgs, null, optCb);
};
/**
* Leaves a private channel.
* @see {@link https://api.slack.com/methods/groups.leave|groups.leave}
*
* @param {?} channel - Private channel to leave
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.leave = function leave(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.leave', requiredArgs, null, optCb);
};
/**
* Lists private channels that the calling user has access to.
* @see {@link https://api.slack.com/methods/groups.list|groups.list}
*
* @param {Object=} opts
* @param {?} opts.exclude_archived - Don't return archived private channels.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.list = function list(opts, optCb) {
return this.makeAPICall('groups.list', null, opts, optCb);
};
/**
* Sets the read cursor in a private channel.
* @see {@link https://api.slack.com/methods/groups.mark|groups.mark}
*
* @param {?} channel - Private channel to set reading cursor in.
* @param {?} ts - Timestamp of the most recently seen message.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.mark = function mark(channel, ts, optCb) {
var requiredArgs = {
channel: channel,
ts: ts
};
return this.makeAPICall('groups.mark', requiredArgs, null, optCb);
};
/**
* Opens a private channel.
* @see {@link https://api.slack.com/methods/groups.open|groups.open}
*
* @param {?} channel - Private channel to open.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.open = function open(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.open', requiredArgs, null, optCb);
};
/**
* Renames a private channel.
* @see {@link https://api.slack.com/methods/groups.rename|groups.rename}
*
* @param {?} channel - Private channel to rename
* @param {?} name - New name for private channel.
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.rename = function rename(channel, name, optCb) {
var requiredArgs = {
channel: channel,
name: name
};
return this.makeAPICall('groups.rename', requiredArgs, null, optCb);
};
/**
* Sets the purpose for a private channel.
* @see {@link https://api.slack.com/methods/groups.setPurpose|groups.setPurpose}
*
* @param {?} channel - Private channel to set the purpose of
* @param {?} purpose - The new purpose
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.setPurpose = function setPurpose(channel, purpose, optCb) {
var requiredArgs = {
channel: channel,
purpose: purpose
};
return this.makeAPICall('groups.setPurpose', requiredArgs, null, optCb);
};
/**
* Sets the topic for a private channel.
* @see {@link https://api.slack.com/methods/groups.setTopic|groups.setTopic}
*
* @param {?} channel - Private channel to set the topic of
* @param {?} topic - The new topic
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.setTopic = function setTopic(channel, topic, optCb) {
var requiredArgs = {
channel: channel,
topic: topic
};
return this.makeAPICall('groups.setTopic', requiredArgs, null, optCb);
};
/**
* Unarchives a private channel.
* @see {@link https://api.slack.com/methods/groups.unarchive|groups.unarchive}
*
* @param {?} channel - Private channel to unarchive
* @param {function=} optCb Optional callback, if not using promises.
*/
GroupsFacet.prototype.unarchive = function unarchive(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('groups.unarchive', requiredArgs, null, optCb);
};
module.exports = GroupsFacet;