Class: Leash::Integrations::Drive

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

Overview

‘leash.integrations.drive` — mirrors TS `leash.integrations.drive`. Wire provider id is `google_drive` (also aliased as `leash.integrations.google_drive`).

Constant Summary collapse

PROVIDER =
"google_drive"

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Leash::Integrations::Base

Instance Method Details

#create_folder(name, parent_id: nil) ⇒ Object



30
31
32
33
34
# File 'lib/leash/integrations/drive.rb', line 30

def create_folder(name, parent_id: nil)
  params = { "name" => name }
  params["parentId"] = parent_id unless parent_id.nil?
  call("create-folder", params)
end

#delete_file(file_id) ⇒ Object



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

def delete_file(file_id)
  call("delete-file", { "fileId" => file_id })
end

#download_file(file_id) ⇒ Object



26
27
28
# File 'lib/leash/integrations/drive.rb', line 26

def download_file(file_id)
  call("download-file", { "fileId" => file_id })
end

#get_file(file_id) ⇒ Object



22
23
24
# File 'lib/leash/integrations/drive.rb', line 22

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

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



13
14
15
16
17
18
19
20
# File 'lib/leash/integrations/drive.rb', line 13

def list_files(query: nil, max_results: nil, folder_id: nil)
  params = compact_params(
    "query" => query,
    "maxResults" => max_results,
    "folderId" => folder_id
  )
  call("list-files", params.empty? ? nil : params)
end

#search_files(query, max_results: nil) ⇒ Object



46
47
48
49
50
# File 'lib/leash/integrations/drive.rb', line 46

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

#upload_file(name:, content:, mime_type:, parent_id: nil) ⇒ Object



36
37
38
39
40
# File 'lib/leash/integrations/drive.rb', line 36

def upload_file(name:, content:, mime_type:, parent_id: nil)
  params = { "name" => name, "content" => content, "mimeType" => mime_type }
  params["parentId"] = parent_id unless parent_id.nil?
  call("upload-file", params)
end