+ Returns the id of the created folder."""
+
+ body = {
+ "name": folder_name,
+ "mimeType": "application/vnd.google-apps.folder"
+ }
+
+ folder = turb.files.create(body=body, fields='id').execute()
+
+ return folder.get('id')
+
+def sheets_create(turb, name, folder_id):
+ """Create a new spreadsheet with the given name.
+
+ Returns a dict with 'id' and 'url' of the spreadsheet
+ """
+
+ body = {
+ "name": name,
+ "parents": [folder_id],
+ "mimeType": "application/vnd.google-apps.spreadsheet"
+ }
+
+ spreadsheet = turb.files.create(body=body, fields='id').execute()
+ id = spreadsheet['id']
+
+ # The files.create call gives us the ID for our new sheet, but we
+ # need the URL for it as well. So we get that with the sheets API.
+ spreadsheet = turb.sheets.get(spreadsheetId=id,
+ fields='spreadsheetUrl').execute()
+ url = spreadsheet['spreadsheetUrl']
+
+ # Finally, we want to also allow anyone with the link to the sheet
+ # to be able to edit it.
+ turb.permissions.create(fileId=id,
+ body={'type': 'anyone', 'role': 'writer'},
+ fields='').execute()
+
+ return {
+ 'id': id,
+ 'url': url
+ }
+
+def create_spreadsheet(turb, name):
+ """
+ Returns the request's dict which has at least the following keys:
+
+ ['spreadsheetId']: ID for this spreadsheet
+ ['spreadsheetUrl']: URL of this spreadsheet
+ ['sheets'][0]['properties']['sheetId']: ID of first sheet inside