protected function copy_file(\repository_googledocs\rest $client, $fileid, $name) {
        $fields = "id,name,mimeType,webContentLink,webViewLink,size,thumbnailLink,iconLink";
        $params = [
            'fileid' => $fileid,
            'fields' => $fields,
        ];
        // Keep the original name (don't put copy at the end of it).
        $copyinfo = [];
        if (!empty($name)) {
            $copyinfo = [ 'name' => $name ];
        }
        $fileinfo = $client->call('copy', $params, json_encode($copyinfo));
        if (empty($fileinfo->id)) {
            $details = 'Cannot copy file:' . $fileid;
            throw new repository_exception('errorwhilecommunicatingwith', 'repository', '', $details);
        }
        return $fileinfo;
    }