-
Notifications
You must be signed in to change notification settings - Fork 662
/
users.js
92 lines (75 loc) · 2.65 KB
/
users.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
/**
* API Facet to make calls to methods in the users namespace.
*
* This provides functions to call:
* - getPresence: {@link https://api.slack.com/methods/users.getPresence|users.getPresence}
* - info: {@link https://api.slack.com/methods/users.info|users.info}
* - list: {@link https://api.slack.com/methods/users.list|users.list}
* - setActive: {@link https://api.slack.com/methods/users.setActive|users.setActive}
* - setPresence: {@link https://api.slack.com/methods/users.setPresence|users.setPresence}
*
*/
function UsersFacet(makeAPICall) {
this.name = 'users';
this.makeAPICall = makeAPICall;
}
/**
* Gets user presence information.
* @see {@link https://api.slack.com/methods/users.getPresence|users.getPresence}
*
* @param {?} user - User to get presence info on. Defaults to the authed user.
* @param {function=} optCb Optional callback, if not using promises.
*/
UsersFacet.prototype.getPresence = function getPresence(user, optCb) {
var requiredArgs = {
user: user
};
return this.makeAPICall('users.getPresence', requiredArgs, null, optCb);
};
/**
* Gets information about a user.
* @see {@link https://api.slack.com/methods/users.info|users.info}
*
* @param {?} user - User to get info on
* @param {function=} optCb Optional callback, if not using promises.
*/
UsersFacet.prototype.info = function info(user, optCb) {
var requiredArgs = {
user: user
};
return this.makeAPICall('users.info', requiredArgs, null, optCb);
};
/**
* Lists all users in a Slack team.
* @see {@link https://api.slack.com/methods/users.list|users.list}
*
* @param {Object=} opts
* @param {?} opts.presence - Whether to include presence data in the output
* @param {function=} optCb Optional callback, if not using promises.
*/
UsersFacet.prototype.list = function list(opts, optCb) {
return this.makeAPICall('users.list', null, opts, optCb);
};
/**
* Marks a user as active.
* @see {@link https://api.slack.com/methods/users.setActive|users.setActive}
*
* @param {function=} optCb Optional callback, if not using promises.
*/
UsersFacet.prototype.setActive = function setActive(optCb) {
return this.makeAPICall('users.setActive', null, null, optCb);
};
/**
* Manually sets user presence.
* @see {@link https://api.slack.com/methods/users.setPresence|users.setPresence}
*
* @param {?} presence - Either `auto` or `away`
* @param {function=} optCb Optional callback, if not using promises.
*/
UsersFacet.prototype.setPresence = function setPresence(presence, optCb) {
var requiredArgs = {
presence: presence
};
return this.makeAPICall('users.setPresence', requiredArgs, null, optCb);
};
module.exports = UsersFacet;