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_comments(options = {}) ⇒ Object

Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (file)

    File containing the comment to edit.

  • :id (Object)

    The comment to edit.

  • :comment (Object)

    Text of the comment to edit.

See Also:


19
20
21
22
23
24
# File 'lib/slack/web/api/endpoints/files.rb', line 19

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

#files_delete(options = {}) ⇒ Object

This method deletes a file from your team.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (file)

    ID of file to delete.

See Also:


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

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

#files_info(options = {}) ⇒ Object

This method returns information about a file in your team.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (file)

    File to fetch info for.

See Also:


45
46
47
48
# File 'lib/slack/web/api/endpoints/files.rb', line 45

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

#files_list(options = {}) ⇒ Object

This method returns a list of files within the team. It can be filtered and sliced in various ways.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :user (user)

    Filter files created by a single user.

  • :channel (channel)

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

  • :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:

    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. .

See Also:


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

def files_list(options = {})
  options = options.merge(channel: channels_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_upload(options = {}) ⇒ Object

This method allows you to create or upload an existing file.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (file)

    File contents via multipart/form-data.

  • :content (Object)

    File contents via a POST var.

  • :filetype (Object)

    Slack-internal file type identifier.

  • :filename (Object)

    Filename of file.

  • :title (Object)

    Title of file.

  • :initial_comment (Object)

    Initial comment to add to file.

  • :channels (Object)

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

See Also:


102
103
104
105
106
# File 'lib/slack/web/api/endpoints/files.rb', line 102

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