-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio.api.js
49 lines (38 loc) · 1.14 KB
/
io.api.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
48
49
const { google } = require("googleapis"),
colors = require("colors/safe");
const util = require("./util");
const team_tlvl = util.client.team_tlvl;
const getInputs = async () => {
try {
const sheets = google.sheets({ version: "v4", auth: team_tlvl });
const data = await sheets.spreadsheets.values.get({
spreadsheetId: "1Lg_-7ns1Y48XGvWg0NEzG515ACrEfjyyXDdXM-ZsUC8",
range: "Inputs!A1:D",
});
await sheets.spreadsheets.values.clear({
spreadsheetId: "1Lg_-7ns1Y48XGvWg0NEzG515ACrEfjyyXDdXM-ZsUC8",
range: "Inputs!A2:D",
});
const inputs = data.data.values;
inputs.shift();
return inputs;
} catch (error) {
console.error(error);
}
};
const setOutput = async (id, fileUrl, count) => {
const sheets = google.sheets({ version: "v4", auth: team_tlvl });
await sheets.spreadsheets.values.append({
spreadsheetId: "1Lg_-7ns1Y48XGvWg0NEzG515ACrEfjyyXDdXM-ZsUC8",
valueInputOption: "RAW",
range: "Outputs!A2:B",
requestBody: {
values: [[id, fileUrl]],
},
});
console.log(colors.gray(`${count}. ${id}: ${fileUrl}.`))
};
module.exports = {
getInputs,
setOutput,
};