Class: Leash::DriveClient

Inherits:
Object
  • Object
show all
Defined in:
lib/leash/drive.rb

Overview

Client for Google Drive operations via the Leash platform proxy.

Not instantiated directly – use Integrations#drive instead.

Constant Summary collapse

PROVIDER =
"google_drive"

Instance Method Summary collapse

Constructor Details

#initialize(call_fn) ⇒ DriveClient

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DriveClient.



11
12
13
# File 'lib/leash/drive.rb', line 11

def initialize(call_fn)
  @call = call_fn
end

Instance Method Details

#get_file(file_id) ⇒ Hash

Get file metadata by ID.

Parameters:

  • file_id (String)

    the file identifier

Returns:

  • (Hash)

    the file metadata object



33
34
35
# File 'lib/leash/drive.rb', line 33

def get_file(file_id)
  @call.call(PROVIDER, "get-file", { "fileId" => file_id })
end

#list_files(query: nil, max_results: nil, folder_id: nil) ⇒ Hash

List files in the user’s Drive.

Parameters:

  • query (String, nil) (defaults to: nil)

    Drive search query (Google Drive API query syntax)

  • max_results (Integer, nil) (defaults to: nil)

    maximum number of files to return

  • folder_id (String, nil) (defaults to: nil)

    restrict to files within a specific folder

Returns:

  • (Hash)

    hash with “files” list



21
22
23
24
25
26
27
# File 'lib/leash/drive.rb', line 21

def list_files(query: nil, max_results: nil, folder_id: nil)
  params = {}
  params["query"] = query if query
  params["maxResults"] = max_results if max_results
  params["folderId"] = folder_id if folder_id
  @call.call(PROVIDER, "list-files", params)
end

#search_files(query, max_results: nil) ⇒ Hash

Search files using a query string.

Parameters:

  • query (String)

    search query (Google Drive API query syntax)

  • max_results (Integer, nil) (defaults to: nil)

    maximum number of results

Returns:

  • (Hash)

    hash with “files” list



42
43
44
45
46
# File 'lib/leash/drive.rb', line 42

def search_files(query, max_results: nil)
  params = { "query" => query }
  params["maxResults"] = max_results if max_results
  @call.call(PROVIDER, "search-files", params)
end