Class: Putio::File

Inherits:
Api::Object show all
Defined in:
lib/putio-ruby/file.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api::Object

#client

Methods included from Api::Client

#client

Class Method Details

.file(id) ⇒ Object



22
23
24
# File 'lib/putio-ruby/file.rb', line 22

def self.file(id)
  self.new client.get("files/#{id}").body
end

.list(parent_id = nil) ⇒ Object



17
18
19
20
# File 'lib/putio-ruby/file.rb', line 17

def self.list(parent_id=nil)
  res = client.get "files/list", ( parent_id ? {:parent_id => parent_id} : nil )
  res.body.map { |f| self.new f }
end

.search(query) ⇒ Object



26
27
28
29
# File 'lib/putio-ruby/file.rb', line 26

def self.search(query)
  res = client.get("files/search", query: query)
  res.body.map { |f| self.new f }
end

Instance Method Details

#deleteObject



35
36
37
38
# File 'lib/putio-ruby/file.rb', line 35

def delete
  client.post "files/delete", :file_ids => id
  true
end

#download_urlObject



31
32
33
# File 'lib/putio-ruby/file.rb', line 31

def download_url
  client.get("files/#{id}/download").env.response_headers["location"]
end