class Dropbox::Explorer::Client
Public Class Methods
new(options = {})
click to toggle source
# File lib/dropbox/explorer/client.rb, line 6 def initialize(options = {}) @options = options @options[:credentials] = fetch_credentials @dropbox_client = init_dropbox_client end
Public Instance Methods
contents_in_path(path = '/', options = {})
click to toggle source
# File lib/dropbox/explorer/client.rb, line 13 def contents_in_path(path = '/', options = {}) folder_metadata = @dropbox_client.metadata(path) Folder.new(folder_metadata).get_contents_paths(only_files: options[:only_files]) end
get_file_content(file_path)
click to toggle source
# File lib/dropbox/explorer/client.rb, line 18 def get_file_content(file_path) content, metadata = @dropbox_client.get_file_and_metadata(file_path) content end
get_file_url(file_path)
click to toggle source
# File lib/dropbox/explorer/client.rb, line 23 def get_file_url(file_path) generated_url = @dropbox_client.media(file_path) generated_url['url'] end
Private Instance Methods
fetch_credentials()
click to toggle source
# File lib/dropbox/explorer/client.rb, line 37 def fetch_credentials Dropbox::Explorer::Credentials.new(config_path: @options[:config_path]).parse! end
init_dropbox_client()
click to toggle source
# File lib/dropbox/explorer/client.rb, line 30 def init_dropbox_client credentials = @options[:credentials] session = DropboxSession.new(credentials[:app_key], credentials[:app_secret]) session.set_access_token(credentials[:access_token], credentials[:access_token_secret]) DropboxClient.new(session, credentials[:access_type]) end