Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/add list all files method #7

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions lib/dropbox/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,12 @@ def get_thumbnail(path, format='jpeg', size='w64h64')
return FileMetadata.new(resp), body
end

def _list_folder(path, opts = nil)
args = { path: path }.merge(opts || {})
request('/files/list_folder', args)
end

# Get the contents of a folder.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure how you feel about this method _list_folder... It seems like the call to request('/files/list_folder') could be pulled out as a little helper since it's now used twice, but maybe not worth the overhead.
So in this second commit, i took that little refactor out.

#
# @param [String] path
# @return [Array<Dropbox::Metadata>]
def list_folder(path)
resp = _list_folder(path)
resp = request('/files/list_folder', path: path)
resp['entries'].map { |e| parse_tagged_response(e) }
end

Expand All @@ -141,7 +136,7 @@ def list_folder(path)
# @param [String] path
# @return [Array<Dropbox::Metadata>]
def list_all_files(path)
resp = _list_folder(path, recursive: true)
resp = request('/files/list_folder', path: path, recursive: true)
has_more = resp['has_more']
cursor = resp['cursor']
entries = resp['entries']
Expand Down