-
Notifications
You must be signed in to change notification settings - Fork 662
/
mpim.js
104 lines (86 loc) · 3.26 KB
/
mpim.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
/**
* API Facet to make calls to methods in the mpim namespace.
*
* This provides functions to call:
* - close: {@link https://api.slack.com/methods/mpim.close|mpim.close}
* - history: {@link https://api.slack.com/methods/mpim.history|mpim.history}
* - list: {@link https://api.slack.com/methods/mpim.list|mpim.list}
* - mark: {@link https://api.slack.com/methods/mpim.mark|mpim.mark}
* - open: {@link https://api.slack.com/methods/mpim.open|mpim.open}
*
*/
function MpimFacet(makeAPICall) {
this.name = 'mpim';
this.makeAPICall = makeAPICall;
}
/**
* Closes a multiparty direct message channel.
* @see {@link https://api.slack.com/methods/mpim.close|mpim.close}
*
* @param {?} channel - MPIM to close.
* @param {function=} optCb Optional callback, if not using promises.
*/
MpimFacet.prototype.close = function close(channel, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('mpim.close', requiredArgs, null, optCb);
};
/**
* Fetches history of messages and events from a multiparty direct message.
* @see {@link https://api.slack.com/methods/mpim.history|mpim.history}
*
* @param {?} channel - Multiparty direct message 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.
*/
MpimFacet.prototype.history = function history(channel, opts, optCb) {
var requiredArgs = {
channel: channel
};
return this.makeAPICall('mpim.history', requiredArgs, opts, optCb);
};
/**
* Lists multiparty direct message channels for the calling user.
* @see {@link https://api.slack.com/methods/mpim.list|mpim.list}
*
* @param {function=} optCb Optional callback, if not using promises.
*/
MpimFacet.prototype.list = function list(optCb) {
return this.makeAPICall('mpim.list', null, null, optCb);
};
/**
* Sets the read cursor in a multiparty direct message channel.
* @see {@link https://api.slack.com/methods/mpim.mark|mpim.mark}
*
* @param {?} channel - multiparty direct message channel to set reading cursor in.
* @param {?} ts - Timestamp of the most recently seen message.
* @param {function=} optCb Optional callback, if not using promises.
*/
MpimFacet.prototype.mark = function mark(channel, ts, optCb) {
var requiredArgs = {
channel: channel,
ts: ts
};
return this.makeAPICall('mpim.mark', requiredArgs, null, optCb);
};
/**
* This method opens a multiparty direct message.
* @see {@link https://api.slack.com/methods/mpim.open|mpim.open}
*
* @param {?} users - Comma separated lists of users. The ordering of the users is preserved
* whenever a MPIM group is returned.
* @param {function=} optCb Optional callback, if not using promises.
*/
MpimFacet.prototype.open = function open(users, optCb) {
var requiredArgs = {
users: users
};
return this.makeAPICall('mpim.open', requiredArgs, null, optCb);
};
module.exports = MpimFacet;