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

@ -4,26 +4,39 @@ import Apikeys
apikey = Apikeys.anthology
groups_to_create = [
"Engage",
"Encompass",
"Reach",
"Student",
"Learn",
"Baseline",
"Ally",
"Milestone",
"Raise",
"Accreditation",
"Program Review",
"Portfolio",
"Outcomes",
"Engage-Campus-wide Elections",
"Engage-Co-Curricular Paths",
"Engage-ECIA",
"Engage-Rooms and Reservations",
"Learn-Bb Reporting",
"Learn-A4L",
]
"Academic Economics",
"Academy Use/Navigation",
"Accreditation",
"Ally",
"Anthology 101",
"Baseline",
"Beacon",
"Course Evaluations",
"Evaluate",
"CVue",
"Data Strategy",
"Digital Assistant",
"Encompass",
"Engage",
"Faculty Development",
"Finance & HCM",
"Insight",
"Learn",
"Milestone",
"Occupation Insight",
"Outcomes",
"Payroll",
"Planning",
"Portfolio",
"Power BI",
"Professional Development",
"Program Review",
"Radius",
"Raise",
"Reach",
"Student",
"Talisma",
]
url = "https://api.northpass.com/v2/bulk/groups"
headers = {
@ -33,10 +46,15 @@ headers = {
}
payload2 = []
for group in groups_to_create:
payload2.append({"name": group})
payload = {"data": {"attributes": {"groups": payload2}}}
t1 = f"{group} - (T1)"
t2 = f"{group} - (T2)"
t3 = f"{group} - (T3)"
# print(payload)
response = requests.post(url, json=payload, headers=headers)
print(response.text)
# print(response)
payload = {"data": {"attributes": {"groups":
[{"name": t1},
{"name": t2},
{"name": t3}]}}}
# print(payload)
response = requests.post(url, json=payload, headers=headers)
print(response.status_code)
print(response)

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"