-
Notifications
You must be signed in to change notification settings - Fork 662
/
files.js
144 lines (119 loc) · 4.47 KB
/
files.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
/**
* API Facet to make calls to methods in the files namespace.
*
* This provides functions to call:
* - delete: {@link https://api.slack.com/methods/files.delete|files.delete}
* - info: {@link https://api.slack.com/methods/files.info|files.info}
* - list: {@link https://api.slack.com/methods/files.list|files.list}
* - revokePublicURL: {@link https://api.slack.com/methods/files.revokePublicURL|files.revokePublicURL}
* - sharedPublicURL: {@link https://api.slack.com/methods/files.sharedPublicURL|files.sharedPublicURL}
* - upload: {@link https://api.slack.com/methods/files.upload|files.upload}
*
*/
function FilesFacet(makeAPICall) {
this.name = 'files';
this.makeAPICall = makeAPICall;
}
/**
* Deletes a file.
* @see {@link https://api.slack.com/methods/files.delete|files.delete}
*
* @param {?} file - ID of file to delete.
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.delete = function delete_(file, optCb) {
var requiredArgs = {
file: file
};
return this.makeAPICall('files.delete', requiredArgs, null, optCb);
};
/**
* Gets information about a team file.
* @see {@link https://api.slack.com/methods/files.info|files.info}
*
* @param {?} file - Specify a file by providing its ID.
* @param {Object=} opts
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.info = function info(file, opts, optCb) {
var requiredArgs = {
file: file
};
return this.makeAPICall('files.info', requiredArgs, opts, optCb);
};
/**
* Lists & filters team files.
* @see {@link https://api.slack.com/methods/files.list|files.list}
*
* @param {Object=} opts
* @param {?} opts.user - Filter files created by a single user.
* @param {?} opts.channel - Filter files appearing in a specific channel, indicated by its ID.
* @param {?} opts.ts_from - Filter files created after this timestamp (inclusive).
* @param {?} opts.ts_to - Filter files created before this timestamp (inclusive).
* @param {?} opts.types - Filter files by type:
*
* * `all` - All files
* * `posts` - Posts
* * `snippets` - Snippets
* * `images` - Image files
* * `gdocs` - Google docs
* * `zips` - Zip files
* * `pdfs` - PDF files
*
* You can pass multiple values in the types argument, like `types=posts,snippets`.The default
* value is `all`, which does not filter the list.
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.list = function list(opts, optCb) {
return this.makeAPICall('files.list', null, opts, optCb);
};
/**
* Revokes public/external sharing access for a file
* @see {@link https://api.slack.com/methods/files.revokePublicURL|files.revokePublicURL}
*
* @param {?} file - File to revoke
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.revokePublicURL = function revokePublicURL(file, optCb) {
var requiredArgs = {
file: file
};
return this.makeAPICall('files.revokePublicURL', requiredArgs, null, optCb);
};
/**
* Enables a file for public/external sharing.
* @see {@link https://api.slack.com/methods/files.sharedPublicURL|files.sharedPublicURL}
*
* @param {?} file - File to share
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.sharedPublicURL = function sharedPublicURL(file, optCb) {
var requiredArgs = {
file: file
};
return this.makeAPICall('files.sharedPublicURL', requiredArgs, null, optCb);
};
/**
* Uploads or creates a file.
* @see {@link https://api.slack.com/methods/files.upload|files.upload}
*
* @param {?} filename - Filename of file.
* @param {Object=} opts
* @param {?} opts.file - File contents via `multipart/form-data`. If omitting this parameter, you
* must submit `content`.
* @param {?} opts.content - File contents via a POST variable. If omitting this parameter, you
* must provide a `file`.
* @param {?} opts.filetype - A [file type](/types/file#file_types) identifier.
* @param {?} opts.title - Title of file.
* @param {?} opts.initial_comment - Initial comment to add to file.
* @param {?} opts.channels - Comma-separated list of channel names or IDs where the file will be
* shared.
* @param {function=} optCb Optional callback, if not using promises.
*/
FilesFacet.prototype.upload = function upload(filename, opts, optCb) {
var requiredArgs = {
filename: filename
};
return this.makeAPICall('files.upload', requiredArgs, opts, optCb);
};
module.exports = FilesFacet;