-
Notifications
You must be signed in to change notification settings - Fork 662
/
dnd.js
84 lines (69 loc) · 2.62 KB
/
dnd.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
/**
* API Facet to make calls to methods in the dnd namespace.
*
* This provides functions to call:
* - endDnd: {@link https://api.slack.com/methods/dnd.endDnd|dnd.endDnd}
* - endSnooze: {@link https://api.slack.com/methods/dnd.endSnooze|dnd.endSnooze}
* - info: {@link https://api.slack.com/methods/dnd.info|dnd.info}
* - setSnooze: {@link https://api.slack.com/methods/dnd.setSnooze|dnd.setSnooze}
* - teamInfo: {@link https://api.slack.com/methods/dnd.teamInfo|dnd.teamInfo}
*
*/
function DndFacet(makeAPICall) {
this.name = 'dnd';
this.makeAPICall = makeAPICall;
}
/**
* Ends the current user's Do Not Disturb session immediately.
* @see {@link https://api.slack.com/methods/dnd.endDnd|dnd.endDnd}
*
* @param {function=} optCb Optional callback, if not using promises.
*/
DndFacet.prototype.endDnd = function endDnd(optCb) {
return this.makeAPICall('dnd.endDnd', null, null, optCb);
};
/**
* Ends the current user's snooze mode immediately.
* @see {@link https://api.slack.com/methods/dnd.endSnooze|dnd.endSnooze}
*
* @param {function=} optCb Optional callback, if not using promises.
*/
DndFacet.prototype.endSnooze = function endSnooze(optCb) {
return this.makeAPICall('dnd.endSnooze', null, null, optCb);
};
/**
* Retrieves a user's current Do Not Disturb status.
* @see {@link https://api.slack.com/methods/dnd.info|dnd.info}
*
* @param {Object=} opts
* @param {?} opts.user - User to fetch status for (defaults to current user)
* @param {function=} optCb Optional callback, if not using promises.
*/
DndFacet.prototype.info = function info(opts, optCb) {
return this.makeAPICall('dnd.info', null, opts, optCb);
};
/**
* Turns on Do Not Disturb mode for the current user, or changes its duration.
* @see {@link https://api.slack.com/methods/dnd.setSnooze|dnd.setSnooze}
*
* @param {?} num_minutes - Number of minutes, from now, to snooze until.
* @param {function=} optCb Optional callback, if not using promises.
*/
DndFacet.prototype.setSnooze = function setSnooze(numMinutes, optCb) {
var requiredArgs = {
num_minutes: numMinutes
};
return this.makeAPICall('dnd.setSnooze', requiredArgs, null, optCb);
};
/**
* Retrieves the Do Not Disturb status for users on a team.
* @see {@link https://api.slack.com/methods/dnd.teamInfo|dnd.teamInfo}
*
* @param {Object=} opts
* @param {?} opts.users - Comma-separated list of users to fetch Do Not Disturb status for
* @param {function=} optCb Optional callback, if not using promises.
*/
DndFacet.prototype.teamInfo = function teamInfo(opts, optCb) {
return this.makeAPICall('dnd.teamInfo', null, opts, optCb);
};
module.exports = DndFacet;