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, instantiate_object, parse_collection, parse_object, plural_name, #set_attribute, singular_name

Methods included from Api::Client

#client

Class Method Details

.get(id) ⇒ Object



8
9
10
11
# File 'lib/putio-ruby/file.rb', line 8

def self.get(id)
  res = client.get "files/#{id}"
  parse_object res.body if res.success?
end

.list(parent_id = nil) ⇒ Object



3
4
5
6
# File 'lib/putio-ruby/file.rb', line 3

def self.list(parent_id=nil)
  res = client.get "files/list", ( parent_id ? {:parent_id => parent_id} : nil )
  parse_collection res.body if res.success?
end

Instance Method Details

#deleteObject



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

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

#download_urlObject



13
14
15
16
# File 'lib/putio-ruby/file.rb', line 13

def download_url
  res = client.get "files/#{id}/download"
  res.headers[:location] if res.success?
end