forked from slackapi/node-slack-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
54 lines (42 loc) · 1.35 KB
/
client.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
/**
*
*/
var bind = require('lodash').bind;
var forEach = require('lodash').forEach;
var inherits = require('inherits');
var BaseAPIClient = require('../client');
var facets = require('./facets/index');
/**
* Slack Web API client.
*
* @param token The Slack API token to use with this client.
* @param {Object=} opts
* @param {Object} opts.retryConfig The configuration to use for the retry operation,
* {@see https://github.com/tim-kos/node-retry}
* @constructor
*/
function WebAPIClient(token, opts) {
var clientOpts = opts || {};
BaseAPIClient.call(this, token, clientOpts);
this.logger('debug', 'WebAPIClient initialized');
}
inherits(WebAPIClient, BaseAPIClient);
/** @inheritDocs **/
WebAPIClient.prototype._createFacets = function _createFacets() {
var newFacet;
var makeAPICall;
WebAPIClient.super_.prototype._createFacets.call(this);
makeAPICall = bind(this._makeAPICall, this);
forEach(facets, bind(function registerWebClientFacet(Facet) {
newFacet = new Facet(makeAPICall);
this[newFacet.name] = newFacet;
}, this));
// Add a dm alias for the im and mpim facets
this.dm = this.im;
this.mpdm = this.mpim;
// Alias for subfacets
this.files.comments = this['files.comments'];
this.usergroups.users = this['usergroups.users'];
this.users.profile = this['users.profile'];
};
module.exports = WebAPIClient;