class Dropbox::API::Client
Attributes
connection[RW]
raw[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/dropbox-api/client.rb, line 11 def initialize(options = {}) @connection = Dropbox::API::Connection.new(:token => options.delete(:token), :secret => options.delete(:secret)) @raw = Dropbox::API::Raw.new :connection => @connection @options = options end
Public Instance Methods
account()
click to toggle source
# File lib/dropbox-api/client.rb, line 29 def account Dropbox::API::Object.init(self.raw.account, self) end
delta(cursor=nil, options={})
click to toggle source
# File lib/dropbox-api/client.rb, line 51 def delta(cursor=nil, options={}) entries = [] has_more = true params = cursor ? options.merge(:cursor => cursor) : options while has_more response = raw.delta(params) params[:cursor] = response['cursor'] has_more = response['has_more'] entries.push *response['entries'] end files = entries.map do |entry| entry.last || {:is_deleted => true, :path => entry.first} end Delta.new(params[:cursor], Dropbox::API::Object.convert(files, self)) end
destroy(path, options = {})
click to toggle source
# File lib/dropbox-api/client.rb, line 40 def destroy(path, options = {}) response = raw.delete({ :path => path }.merge(options)) Dropbox::API::Object.convert(response, self) end
find(filename)
click to toggle source
# File lib/dropbox-api/client.rb, line 20 def find(filename) data = self.raw.metadata(:path => filename, :list => false) Dropbox::API::Object.convert(data, self) end
ls(path = '')
click to toggle source
# File lib/dropbox-api/client.rb, line 25 def ls(path = '') Dropbox::API::Dir.init({'path' => path}, self).ls end
mkdir(path)
click to toggle source
# File lib/dropbox-api/client.rb, line 33 def mkdir(path) # Remove the characters not allowed by Dropbox path = path.gsub(/[\\\:\?\*\<\>\"\|]+/, '') response = raw.create_folder :path => path Dropbox::API::Dir.init(response, self) end
search(term, options = {})
click to toggle source
# File lib/dropbox-api/client.rb, line 45 def search(term, options = {}) options[:path] ||= '' results = raw.search({ :query => term }.merge(options)) Dropbox::API::Object.convert(results, self) end