-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsheets.js
47 lines (43 loc) · 1.13 KB
/
sheets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const { google } = require("googleapis");
const Promise = require("bluebird");
const config = require("./config");
async function getspreadsheetIdArea(spreadsheetId, a1Notation) {
return new Promise((resolve, reject) => {
try {
const sheetConfig = {
version: "v4",
auth: config.apiKey
};
const sheets = google.sheets(sheetConfig);
const sheetsRequstObject = {
spreadsheetId: spreadsheetId,
range: a1Notation
};
sheets.spreadsheets.values.get(sheetsRequstObject, (err, response) => {
if (err) {
reject(err);
} else {
resolve(response);
}
});
} catch (e) {
reject(e);
}
});
}
async function getStartTimeColumn({
rowNr = config.rowStart,
sheetId = config.sheetId,
spreadsheetId = config.spreadsheetId,
startTimeColumn = config.startTimeColumn
} = {}) {
const response = await getspreadsheetIdArea(
spreadsheetId,
`${sheetId}!${startTimeColumn}${rowNr}:${startTimeColumn}${rowNr}`
);
return response.data.values[0][0];
}
async function main() {
console.log(await getStartTimeColumn());
}
main();