Class: DropboxApi::Endpoints::Files::Search

Inherits:
Rpc
  • Object
show all
Includes:
OptionsValidator
Defined in:
lib/dropbox_api/endpoints/files/search.rb

Constant Summary collapse

Method =
:post
Path =
"/2/files/search".freeze
ResultType =
DropboxApi::Results::SearchResult
ErrorType =
DropboxApi::Errors::SearchError

Instance Method Summary collapse

Methods included from OptionsValidator

#validate_options

Methods inherited from Rpc

#build_request, #initialize, #request_body

Methods inherited from Base

add_endpoint

Constructor Details

This class inherits a constructor from DropboxApi::Endpoints::Rpc

Instance Method Details

#search(query, path = "", options = {}) ⇒ Object

Searches for files and folders.

Note: Recent changes may not immediately be reflected in search results due to a short delay in indexing.

Parameters:

  • query (String)

    The string to search for. The search string is split on spaces into multiple tokens. For file name searching, the last token is used for prefix matching (i.e. "bat c" matches "bat cave" but not "batman car").

  • path (String) (defaults to: "")

    The path in the user's Dropbox to search.

Options Hash (options):

  • start (Numeric)

    The starting index within the search results (used for paging). The default for this field is 0.

  • max_results (Numeric)

    The maximum number of search results to return. The default for this field is 100.

  • mode (:filename, :filename_and_content, :deleted_filename)

    The search mode. Note that searching file content is only available for Dropbox Business accounts. The default is filename.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dropbox_api/endpoints/files/search.rb', line 27

add_endpoint :search do |query, path = "", options = {}|
  validate_options([
    :start,
    :max_results,
    :mode
  ], options)
  options[:start] ||= 0
  options[:max_results] ||= 100
  options[:mode] ||= :filename

  perform_request options.merge({
    :query => query,
    :path => path
  })
end