Skip to content

Commit

Permalink
Add restore method
Browse files Browse the repository at this point in the history
  • Loading branch information
waits committed Jun 14, 2016
1 parent d5ea9b2 commit e1a4b4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/dropbox/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def move(from, to)
object_from_response(resp)
end

def restore(path, rev)
resp = request('/restore', path: path, rev: rev)
object_from_response(resp, 'file')
end

def search(query, path='', max=100)
resp = request('/search', path: path, query: query, max_results: max)
resp['matches'].map { |m| object_from_response(m['metadata']) }
Expand Down
13 changes: 13 additions & 0 deletions test/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def test_move_error
end
end

def test_restore
file = @client.restore('/file.txt', '14449c1893e')

assert file.is_a?(Dropbox::FileMetadata)
assert_equal 'file.txt', file.name
end

def test_restore_error
assert_raises(Dropbox::APIError) do
@client.restore('/file.txt', 'xyz')
end
end

def test_search
matches = @client.search('folder')
assert_equal 3, matches.length
Expand Down

0 comments on commit e1a4b4d

Please sign in to comment.