Talkspace Custom Report
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
csv = "/Users/normrasmussen/Downloads/ts_id_roles_test.csv"
|
||||
csv = "/Users/normrasmussen/Downloads/ts_id_roles.csv"
|
||||
apiKey = "18Zl2NAzWTE09FHbNEBngNOJO"
|
||||
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
|
||||
|
||||
11
Scripts/API_Tests/props_to_csv.py
Normal file
11
Scripts/API_Tests/props_to_csv.py
Normal file
@ -0,0 +1,11 @@
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
apiKey =
|
||||
|
||||
def getProps():
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
77
Scripts/API_Tests/talkspace_google_api.js
Normal file
77
Scripts/API_Tests/talkspace_google_api.js
Normal file
@ -0,0 +1,77 @@
|
||||
const sheet = SpreadsheetApp.getActiveSheet();
|
||||
const apiKey = '18Zl2NAzWTE09FHbNEBngNOJO';
|
||||
|
||||
function getUuids() {
|
||||
var sheet = SpreadsheetApp.getActiveSheet();
|
||||
var numRows = sheet.getLastRow()-1; // Number of rows to process
|
||||
var dataRange = sheet.getRange(3, 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);
|
||||
var uuid = parsedata["data"][0]["id"];
|
||||
if (email != "") {
|
||||
findRow(email, uuid);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
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, 17).setValue(role);
|
||||
sheet.getRange(row, 18).setValue(user_id).clearFormat();
|
||||
sheet.getRange(row, 19).setValue(paid);
|
||||
Logger.log(row + "," + email);
|
||||
}
|
||||
|
||||
function writeHeadings() {
|
||||
// Write the new Column Headings
|
||||
sheet.getRange(1, 17).setValue("Role");
|
||||
sheet.getRange(1, 18).setValue("ID Number");
|
||||
sheet.getRange(1, 19).setValue("Paid?");
|
||||
}
|
||||
Reference in New Issue
Block a user