Class: SlackWebApi::FilesController
- Inherits:
-
BaseController
- Object
- BaseController
- SlackWebApi::FilesController
- Defined in:
- lib/slack_web_api/controllers/files_controller.rb
Overview
FilesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#files_delete(token: nil, file: nil) ⇒ ApiResponse
Deletes a file.
-
#files_info(token: nil, file: nil, count: nil, page: nil, limit: nil, cursor: nil) ⇒ ApiResponse
Gets information about a file.
-
#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.
-
#files_revoke_public_url(token: nil, file: nil) ⇒ ApiResponse
Revokes public/external sharing access for a file scope:
files:write:user. -
#files_shared_public_url(token: nil, file: nil) ⇒ ApiResponse
Enables a file for public/external sharing.
-
#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.
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
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.
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.
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
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
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.
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 |