Class: SlackChatter::Api::Files

Inherits:
Base
  • Object
show all
Defined in:
lib/slack_chatter/api/files.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#bool_as_i, #call_method, #channel_id_or_name, #initialize

Constructor Details

This class inherits a constructor from SlackChatter::Api::Base

Instance Method Details

#delete(file_id) ⇒ Object



5
6
7
# File 'lib/slack_chatter/api/files.rb', line 5

def delete file_id
  call_method("files", "delete", {"file" => file_id})
end

#info(file_id, opts = {}) ⇒ Object



9
10
11
# File 'lib/slack_chatter/api/files.rb', line 9

def info file_id, opts={}
  call_method("files", "info", {"file" => file_id}.merge(opts))
end

#list(opts = {}) ⇒ Object



13
14
15
# File 'lib/slack_chatter/api/files.rb', line 13

def list opts={}
  call_method("files", "list", opts)
end

#upload(opts = {}) ⇒ Object



17
18
19
20
21
# File 'lib/slack_chatter/api/files.rb', line 17

def upload opts={}
  opts = opts.with_indifferent_access
  filename = opts.delete(:file) || opts.delete(:content)
  client.post("files.upload", {}, query: opts.merge({file: UploadIO.new(File.open(filename), "multipart/form-data")}))
end