Module: EasyDrive::Files

Included in:
Client
Defined in:
lib/easy_drive/files/copy.rb

Instance Method Summary collapse

Instance Method Details

#copy(client, drive, file_id, folder_id, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/easy_drive/files/copy.rb', line 3

def copy(client, drive, file_id, folder_id, options = {})
  client = self.client
  drive = self.drive

  file = drive.files.insert.request_schema.new({
    'title' => options[:title],
    'parents' => [{:id => folder_id}]
  })

  result = client.execute(
    :api_method => drive.files.copy,
    :body_object => file,
    :parameters => {
      'fileId' => file_id,
      'alt' => 'json'})

  result.data
end