/**
 * Retrieve a list of File resources.
 *
 * @param Google_Service_Drive $service Drive API service instance.
 * @return Array List of Google_Service_Drive_DriveFile resources.
 */
function retrieveReportFiles($service)
{
    $result = array();
    $pageToken = null;

    do {
        try {
            $parameters = array(
                'q' => 'title contains "' . date(DATE_FORMAT_FNAME) . '"
                 and trashed = false and mimeType="' . GDOC_SHEET_MIME_GET . '" and
                 properties has { key="isAsanaGDocReport" and value="true" and visibility="PUBLIC"}'
            );
            if ($pageToken) {
                $parameters['pageToken'] = $pageToken;
            }
            $files = $service->files->listFiles($parameters);

            $result = array_merge($result, $files->getItems());
            $pageToken = $files->getNextPageToken();
        } catch (Exception $e) {
            catchGoogleExceptions($e);
            $pageToken = null;
        }
    } while ($pageToken);
    return $result;
}
/**
 * Permanently delete a file, skipping the trash.
 *
 * @param Google_Service_Drive $service Drive API service instance.
 * @param String $fileId ID of the file to delete.
 */
function deleteFile($service, $fileId)
{
    try {

        $service->files->delete($fileId);

    } catch (Exception $e) {
        catchGoogleExceptions($e);
    }
}