Started Harri script. Pushed groups for Anthology.

This commit is contained in:
Norm Rasmussen
2023-06-22 17:00:36 -04:00
parent a6f6ecf6cf
commit b89d88ffcd
6 changed files with 142 additions and 56 deletions

View File

@ -0,0 +1,3 @@
function getProps() {
}

View File

@ -0,0 +1 @@
{"scriptId":"17cLm8wwin--btQr0A6G_QkxOeT2Q3QnL8mEup8ZThMTAPwrUw2qsyg6N","rootDir":"/Users/normrasmussen/Documents/Work/Scripts/GoogleScripts/Harri_Get_Props"}

View File

@ -0,0 +1,87 @@
const sheet = SpreadsheetApp.getActiveSheet();
const apiKey = 'RfmxChNLLodO6M0Z88BwG9Xyu'
function getUuids() {
var sheet = SpreadsheetApp.getActiveSheet();
var numRows = sheet.getLastRow()-1; // Number of rows to process
var dataRange = sheet.getRange(2, 3, numRows, 1);
var values = dataRange.getValues();
writeHeadings();
for (email in values){
var row = values[email];
var email = row[0]
var api_url = 'https://api.northpass.com/v2/people/?filter[email][eq]='+email;
const settings = {
async: true,
crossDomain: true,
method: 'GET',
headers: {
accept: 'application/json',
'X-Api-Key': apiKey
}
};
const sendMsg = UrlFetchApp.fetch(api_url, settings);
var uuidResponse = sendMsg.getContentText();
var parsedata = JSON.parse(uuidResponse);
try {
var uuid = parsedata["data"][0]["id"];
if (email != "") {
findRow(email, uuid);
}
}
catch(ex) {
Logger.log(ex)
continue
}
finally {
}
};
};
function findRow(email, uuid){
var sheetRow = SpreadsheetApp.getActiveSpreadsheet();
var data = sheetRow.getDataRange().getValues();
for(var i = 0; i<data.length;i++){
if(data[i][2] == email){ //[1] because column B
// Logger.log((i+1))
var row = i+1;
propstoSheet(uuid, row, email);
}
}
}
function propstoSheet(uuid, row, email) {
var uuid_url = 'https://api.northpass.com/v2/properties/people/'+uuid;
const settings = {
async: true,
crossDomain: true,
url: uuid_url,
method: 'GET',
headers: {
accept: 'application/json',
'X-Api-Key': apiKey,
}
};
const sendMsg = UrlFetchApp.fetch(uuid_url, settings);
var txtResponse = sendMsg.getContentText();
var parseProps = JSON.parse(txtResponse);
var role = parseProps["data"]["attributes"]["properties"]["role_type"];
var user_id = parseProps["data"]["attributes"]["properties"]["user_id"];
var paid = parseProps["data"]["attributes"]["properties"]["paid"];
// Write the Data to each row and column
sheet.getRange(row, 13).setValue(role);
sheet.getRange(row, 14).setValue(user_id);
sheet.getRange(row, 15).setValue(paid);
// Logger.log(row + "," + email);
}
function writeHeadings() {
// Write the new Column Headings
sheet.getRange(1, 13).setValue("Role");
sheet.getRange(1, 14).setValue("ID Number");
sheet.getRange(1, 14).clearFormat();
sheet.getRange(1, 15).setValue("Paid?");
}
}

View File

@ -0,0 +1,7 @@
{
"timeZone": "America/New_York",
"dependencies": {
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}

View File

@ -1,30 +0,0 @@
{% include "header" %}
{% include "course_version_outdated_alert", courses: courses.enrolled %}
{% include "sub_navigation" %}
<main class="np-main np-dashboard np-subpage-container np-max-width">
<div class="row np-flex-center">
<div class="col-xs-12 col-sm-8">
{% if features.learning_paths? %}
<div class="np-dashboard-resources-title">
{% t shared.learning_paths %}
</div>
{% include "learning_paths_index", items: learning_paths.enrolled %}
{% endif %}
<div class="np-dashboard-resources-title">
{% t shared.course_vocabulary.plural, key: current_school.course_vocabulary %}
</div>
{% include "courses_index", class: "col-xs-12 col-sm-6 np-stretch-content" %}
</div>
{% if features.training_events? %}
<div class="np-grid-spacing col-xs-12 col-sm-4">
<div class="np-dashboard-resources-title">
{% t .upcoming_events %}
</div>
{% include "training_events_dashboard" %}
</div>
{% endif %}
</div>
</main>
{% include "footer" %}
current_page: "/app/user-guides"