Class: SlackWebApi::FilesController

Inherits:
BaseController show all
Defined in:
lib/slack_web_api/controllers/files_controller.rb

Overview

FilesController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SlackWebApi::BaseController

Instance Method Details

#files_delete(token: nil, file: nil) ⇒ ApiResponse

Deletes a file. scope: files:write:user

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • file (String) (defaults to: nil)

    Optional parameter: ID of file to delete.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/slack_web_api/controllers/files_controller.rb', line 14

def files_delete(token: nil,
                 file: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/files.delete',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token'))
               .form_param(new_parameter(file, key: 'file'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesDeleteSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesDeleteErrorSchemaException))
    .execute
end

#files_info(token: nil, file: nil, count: nil, page: nil, limit: nil, cursor: nil) ⇒ ApiResponse

Gets information about a file. scope: files:read ID. return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached. comments are paginated for a single file. Set cursor equal to the next_cursor attribute returned by the previous request’s response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first “page” of the collection of comments. See [pagination](/docs/pagination) for more details.

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • file (String) (defaults to: nil)

    Optional parameter: Specify a file by providing its

  • count (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • page (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of items to

  • cursor (String) (defaults to: nil)

    Optional parameter: Parameter for pagination. File

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/slack_web_api/controllers/files_controller.rb', line 53

def files_info(token: nil,
               file: nil,
               count: nil,
               page: nil,
               limit: nil,
               cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/files.info',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(token, key: 'token'))
               .query_param(new_parameter(file, key: 'file'))
               .query_param(new_parameter(count, key: 'count'))
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesInfoSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesInfoErrorSchemaException))
    .execute
end

#files_list(token: nil, user: nil, channel: nil, ts_from: nil, ts_to: nil, types: nil, count: nil, page: nil, show_files_hidden_by_limit: nil) ⇒ ApiResponse

List for a team, in a channel, or from a user with applied filters. scope: files:read user. specific channel, indicated by its ID. timestamp (inclusive). timestamp (inclusive). below](#file_types)). You can pass multiple values in the types argument, like ‘types=spaces,snippets`.The default value is all, which does not filter the list. parameter: Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit.

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • user (String) (defaults to: nil)

    Optional parameter: Filter files created by a single

  • channel (String) (defaults to: nil)

    Optional parameter: Filter files appearing in a

  • ts_from (Float) (defaults to: nil)

    Optional parameter: Filter files created after this

  • ts_to (Float) (defaults to: nil)

    Optional parameter: Filter files created before this

  • types (String) (defaults to: nil)

    Optional parameter: Filter files by type ([see

  • count (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • page (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • show_files_hidden_by_limit (TrueClass | FalseClass) (defaults to: nil)

    Optional

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/slack_web_api/controllers/files_controller.rb', line 103

def files_list(token: nil,
               user: nil,
               channel: nil,
               ts_from: nil,
               ts_to: nil,
               types: nil,
               count: nil,
               page: nil,
               show_files_hidden_by_limit: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/files.list',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'Content-Type'))
               .query_param(new_parameter(token, key: 'token'))
               .query_param(new_parameter(user, key: 'user'))
               .query_param(new_parameter(channel, key: 'channel'))
               .query_param(new_parameter(ts_from, key: 'ts_from'))
               .query_param(new_parameter(ts_to, key: 'ts_to'))
               .query_param(new_parameter(types, key: 'types'))
               .query_param(new_parameter(count, key: 'count'))
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(show_files_hidden_by_limit, key: 'show_files_hidden_by_limit'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesListSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesListErrorSchemaException))
    .execute
end

#files_revoke_public_url(token: nil, file: nil) ⇒ ApiResponse

Revokes public/external sharing access for a file scope: files:write:user

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • file (String) (defaults to: nil)

    Optional parameter: File to revoke

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/slack_web_api/controllers/files_controller.rb', line 143

def files_revoke_public_url(token: nil,
                            file: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/files.revokePublicURL',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token'))
               .form_param(new_parameter(file, key: 'file'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesRevokePublicUrlSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesRevokePublicUrlErrorSchemaException))
    .execute
end

#files_shared_public_url(token: nil, file: nil) ⇒ ApiResponse

Enables a file for public/external sharing. scope: files:write:user

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • file (String) (defaults to: nil)

    Optional parameter: File to share

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/slack_web_api/controllers/files_controller.rb', line 169

def files_shared_public_url(token: nil,
                            file: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/files.sharedPublicURL',
                                 Server::DEFAULT)
               .header_param(new_parameter(token, key: 'token'))
               .form_param(new_parameter(file, key: 'file'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesSharedPublicUrlSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesSharedPublicUrlErrorSchemaException))
    .execute
end

#files_upload(token: nil, file: nil, content: nil, filetype: nil, filename: nil, title: nil, initial_comment: nil, channels: nil, thread_ts: nil) ⇒ ApiResponse

Uploads or creates a file. scope: files:write:user multipart/form-data. If omitting this parameter, you must submit content. variable. If omitting this parameter, you must provide a file. type](/types/file#file_types) identifier. introducing the file in specified channels. channel names or IDs where the file will be shared. ts value to upload this file as a reply. Never use a reply’s ts value; use its parent instead.

Parameters:

  • token (String) (defaults to: nil)

    Optional parameter: Authentication token. Requires

  • file (String) (defaults to: nil)

    Optional parameter: File contents via

  • content (String) (defaults to: nil)

    Optional parameter: File contents via a POST

  • filetype (String) (defaults to: nil)

    Optional parameter: A [file

  • filename (String) (defaults to: nil)

    Optional parameter: Filename of file.

  • title (String) (defaults to: nil)

    Optional parameter: Title of file.

  • initial_comment (String) (defaults to: nil)

    Optional parameter: The message text

  • channels (String) (defaults to: nil)

    Optional parameter: Comma-separated list of

  • thread_ts (Float) (defaults to: nil)

    Optional parameter: Provide another message’s

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/slack_web_api/controllers/files_controller.rb', line 210

def files_upload(token: nil,
                 file: nil,
                 content: nil,
                 filetype: nil,
                 filename: nil,
                 title: nil,
                 initial_comment: nil,
                 channels: nil,
                 thread_ts: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/files.upload',
                                 Server::DEFAULT)
               .form_param(new_parameter(token, key: 'token'))
               .form_param(new_parameter(file, key: 'file'))
               .form_param(new_parameter(content, key: 'content'))
               .form_param(new_parameter(filetype, key: 'filetype'))
               .form_param(new_parameter(filename, key: 'filename'))
               .form_param(new_parameter(title, key: 'title'))
               .form_param(new_parameter(initial_comment, key: 'initial_comment'))
               .form_param(new_parameter(channels, key: 'channels'))
               .form_param(new_parameter(thread_ts, key: 'thread_ts'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('slackAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(FilesUploadSchema.method(:from_hash))
                .is_api_response(true)
                .local_error('default',
                             'Typical error response',
                             FilesUploadErrorSchemaException))
    .execute
end