{"size": 596, "ext": "js", "max_stars_repo_path": "lib/google/gsheet/list.js", "max_stars_repo_name": "quilicicf/ep-stats", "max_stars_repo_stars_event_min_datetime": "2019-10-03T11:57:37.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-03T14:32:42.000Z", "max_issues_repo_path": "lib/google/gsheet/list.js", "max_issues_repo_name": "quilicicf/ep-stats", "max_issues_repo_issues_event_min_datetime": "2020-04-24T13:26:04.000Z", "max_issues_repo_issues_event_max_datetime": "2020-09-09T10:01:16.000Z", "max_forks_repo_path": "lib/google/gsheet/list.js", "max_forks_repo_name": "quilicicf/ep-stats", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 29.8, "max_line_length": 90, "alphanum_fraction": 0.6291946309}
const { google } = require('googleapis');

const authorize = require('../authorization/authorize');

module.exports = async (sheetId, range) => {
  const oauthClient = await authorize();

  return new Promise((resolve, reject) => {
    const sheets = google.sheets({ version: 'v4', auth: oauthClient });

    sheets.spreadsheets.values.get(
      { spreadsheetId: sheetId, range, majorDimension: 'COLUMNS' },
      (error, result) => {
        if (error) { return reject(Error(`Cannot list range ${range}\n${error.stack}`)); }
        return resolve(result.data.values);
      },
    );
  });
};
