Cin7 was upset that the design work wasn't complete yet so I downloaded and started chipping away at some of the items that are remaining. Still working on Anthology's CSV mapping functionality. Modified their master dictionary since the CSV stuff isn't ready.

This commit is contained in:
Norm Rasmussen
2024-01-19 19:47:00 -05:00
parent 760bf3925a
commit 620797240d
113 changed files with 3359 additions and 18 deletions

View File

@ -1,15 +1,10 @@
const apiKey = '8ALsk8jDOlynEwn8ScMBSnG87';
let indexRange = (arr, start, end) => {
return arr.slice(start, end)
}
function main() {
var folder = DriveApp.getFolderById("15p4vXVQd6hhcMl73VOxD8VctL2gR-q43")
var files = folder.getFiles()
while (files.hasNext()) {
var file = files.next();
//var date = "Wed Jan 10 2024 15:01:58 GMT-0500 (Eastern Standard Time)"
var getDate = new Date();
var date = Utilities.formatDate(getDate, 'America/New_York', 'MM/dd/yyyy');
var fileDate = file.getLastUpdated();
@ -20,17 +15,27 @@ function main() {
var updated_data = Utilities.parseCsv(updated_blob, ',');
}
}
quickParse(updated_data);
//parseCSV(outdated_data, updated_data)
//quickParse(updated_data);
writeDataToSheet(updated_data);
}
//Inserts a new sheet and writes a 2D array of data in it
function writeDataToSheet(updated_data) {
var ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/1Kck1UUOkVIU4kbBC8b_bl77fNaCTSFStiv0I5Gg-kIc/');
sheet = ss.insertSheet();
sheet.getRange(1, 1, updated_data.length, updated_data[0].length).setValues(updated_data);
Logger.log(sheet.getName());
}
function quickParse(updated_data) {
for (var x = 1; x < updated_data.length; x++) {
var array = updated_data[x];
for (var i = 1; i < array.length; i++) {
var item = array[i]
if (item != "") {
var api_url = 'https://api.northpass.com/v2/groups/?filter[name][eq]='+item;
var api_url = 'https://api.northpass.com/v2/groups/?filter[name][eq]='+encodeURIComponent(item);
Logger.log(api_url)
const settings = {
async: true,
crossDomain: true,
@ -52,8 +57,18 @@ function quickParse(updated_data) {
}
const dom = array.shift();
const groups = array;
Logger.log(groups)
const domain_to_update = { domain: dom, group_ids: groups }
Logger.log(domain_to_update)
//const domain_to_update : { domain: dom, group_ids: groups }
sendWebhook({domain_to_update : { domain: dom, group_ids: groups }})
}
}
function sendWebhook(domain_to_update){
var payload = domain_to_update
//Logger.log(JSON.stringify(payload))
var options = {
'method': 'post',
'payload': JSON.stringify(payload)
};
//UrlFetchApp.fetch('https://webhooks.workato.com/webhooks/rest/604b4fc0-fcd9-4f3b-b715-b42d7f740ba6/domains-updated', options);
}