I’m retrieving the files that match a given query in my drive account using a wrapper that I created
files = get_files_by_query session, "title = 'Competitors' and trashed = false"
This returns an Array of Google::APIClient::Schema::Drive::V2::File objects
From the rails console I’m able to retrieve the parents of the first file in the array.
files.first.parents.first.id
However, when I attempt to retrieve the isRoot
files.first.parents.first.isRoot
I get the following error
TypeError: Expected boolean, got NilClass.
Which is very strange because when I inspect the contents of the parent, the hash is displayed and isRoot is clearly false or true, but never nil.
Not sure if this is related, but right after the error. If I reattempt the first command
files = get_files_by_query session, "title = 'Competitors' and trashed = false"
The results are returned as an Array of Hash objects and not Google::APIClient::Schema::Drive::V2::File objects.
Below are the wrappers used above.
def get_files_by_query session, query
get_files session, {'q' => query}
end
def get_files session, parameters
drive = session.discovered_api("drive", "v2")
result = session.execute(api_method: drive.files.list, parameters: parameters)
if result.status == 200
files = result.data.items
else
puts "An error occurred: #{result.data['error']['message']}"
end
end
Thanks!
More of an FYI since this was addressed in the comments, but the issued that caused this has been fixed in the client library for a while now.