Module: Slack::Web::Api::Endpoints::Files

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/files.rb

Instance Method Summary collapse

Instance Method Details

#files_delete(options = {}) ⇒ Object

Deletes a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    ID of file to delete.

See Also:



16
17
18
19
# File 'lib/slack/web/api/endpoints/files.rb', line 16

def files_delete(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  post('files.delete', options)
end

#files_edit(options = {}) ⇒ Object

Change the properties of a file (undocumented)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (Object)

    ID of the file to be edited

  • :title (Object)

    New title of the file

  • :filetype (Object)

    New filetype of the file. See api.slack.com/types/file#file_types for a list of all supported types.

See Also:



31
32
33
34
35
36
# File 'lib/slack/web/api/endpoints/files.rb', line 31

def files_edit(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  throw ArgumentError.new('Required arguments :title missing') if options[:title].nil?
  logger.warn('The files.edit method is undocumented.')
  post('files.edit', options)
end

#files_info(options = {}) ⇒ Object

Gets information about a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    Specify a file by providing its ID.

  • :cursor (Object)

    Parameter for pagination. File 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 for more details.

  • :limit (Object)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached.

See Also:



49
50
51
52
53
54
55
56
57
58
# File 'lib/slack/web/api/endpoints/files.rb', line 49

def files_info(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  if block_given?
    Pagination::Cursor.new(self, :files_info, options).each do |page|
      yield page
    end
  else
    post('files.info', options)
  end
end

#files_list(options = {}) ⇒ Object

List for a team, in a channel, or from a user with applied filters.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Filter files appearing in a specific channel, indicated by its ID.

  • :show_files_hidden_by_limit (Object)

    Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit.

  • :team_id (Object)

    encoded team id to list files in, required if org token is used.

  • :ts_from (Object)

    Filter files created after this timestamp (inclusive).

  • :ts_to (Object)

    Filter files created before this timestamp (inclusive).

  • :types (Object)

    Filter files by type (see below). You can pass multiple values in the types argument, like types=spaces,snippets.The default value is all, which does not filter the list.

  • :user (user)

    Filter files created by a single user.

See Also:



79
80
81
82
83
# File 'lib/slack/web/api/endpoints/files.rb', line 79

def files_list(options = {})
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('files.list', options)
end

#files_revokePublicURL(options = {}) ⇒ Object

Revokes public/external sharing access for a file

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    File to revoke.

See Also:



92
93
94
95
# File 'lib/slack/web/api/endpoints/files.rb', line 92

def files_revokePublicURL(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  post('files.revokePublicURL', options)
end

#files_share(options = {}) ⇒ Object

Share an existing file in a channel (undocumented)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (Object)

    ID of the file to be shared

  • :channel (channel)

    Channel to share the file in. Works with both public (channel ID) and private channels (group ID).

See Also:



105
106
107
108
109
110
111
# File 'lib/slack/web/api/endpoints/files.rb', line 105

def files_share(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('The files.share method is undocumented.')
  post('files.share', options)
end

#files_sharedPublicURL(options = {}) ⇒ Object

Enables a file for public/external sharing.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    File to share.

See Also:



120
121
122
123
# File 'lib/slack/web/api/endpoints/files.rb', line 120

def files_sharedPublicURL(options = {})
  throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
  post('files.sharedPublicURL', options)
end

#files_upload(options = {}) ⇒ Object

Uploads or creates a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channels (Object)

    Comma-separated list of channel names or IDs where the file will be shared.

  • :content (Object)

    File contents via a POST variable. If omitting this parameter, you must provide a file.

  • :file (file)

    File contents via multipart/form-data. If omitting this parameter, you must submit content.

  • :filename (Object)

    Filename of file.

  • :filetype (Object)

    A file type identifier.

  • :initial_comment (Object)

    The message text introducing the file in specified channels.

  • :thread_ts (Object)

    Provide another message’s ts value to upload this file as a reply. Never use a reply’s ts value; use its parent instead.

  • :title (Object)

    Title of file.

See Also:



146
147
148
# File 'lib/slack/web/api/endpoints/files.rb', line 146

def files_upload(options = {})
  post('files.upload', options)
end