Renaissance notes. Updated webhook script and small items for DataSnipper. Need to finish that workflow for them...

This commit is contained in:
Norm Rasmussen
2023-12-05 17:33:38 -05:00
parent 6b3ba2e5e1
commit 54cddb23f1
6 changed files with 137 additions and 82 deletions

View File

@ -1,60 +1,67 @@
import requests
import Apikeys
apikey = Apikeys.anthology
apikey = Apikeys.NORMSANDBOX
groups_to_create = [
"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",
]
"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 = {
# URL = "https://api.northpass.com/v2/bulk/groups"
URL = "https://api.northpass.com/v2/groups"
HEADERS = {
"accept": "application/json",
"content-type": "application/json",
"X-Api-Key": apikey,
}
payload2 = []
for group in groups_to_create:
t1 = f"{group} - (T1)"
t2 = f"{group} - (T2)"
t3 = f"{group} - (T3)"
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)
PAYLOAD = {
"data": {
"attributes": {
"name": "This Is a Test"
}
}
}
# for group in groups_to_create:
# t1 = f"{group} - (T1)"
# t2 = f"{group} - (T2)"
# t3 = f"{group} - (T3)"
#
# 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.text)

View File

@ -1,18 +1,20 @@
import pprint
import requests
import Apikeys
baseUrl = "https://api.northpass.com/v2/people/"
baseUrlname = "https://api.northpass.com/v2/people?filter[name][eq]="
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
apiKey = "JRDpCGQ7vSRiva6t5OkWDr5eJ" # G2
# apiKey = "6hUfJdAartHTHhHc0WIRZYPWe" #Walmart
pp = pprint.PrettyPrinter(indent=4)
BASEURL = "https://api.northpass.com/v2/people/"
BASEURLNAME = "https://api.northpass.com/v2/people?filter[name][eq]="
BASEURLEMAIL = "https://api.northpass.com/v2/people?filter[email][cont]="
APIKEY = Apikeys.DATASNIPPER
def getfromName(baseUrlname, apiKey):
def getfromName(BASEURLNAME, APIKEY):
name = "Someone else"
url = baseUrlname + f"{name}"
url = BASEURLNAME + f"{name}"
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"x-api-key": APIKEY,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
@ -28,35 +30,33 @@ def getfromName(baseUrlname, apiKey):
# print(uuid)
def getfromEmail(baseUrlemail, apiKey):
def getfromEmail(BASEURLEMAIL, APIKEY):
# email = "norm2test@northpass.com" # The %2B encodes the + sign in the URL. Using the + sign won't work.
email = " "
url = baseUrlemail + f"{email}"
print(url)
email = "datasnipper.com"
url = BASEURLEMAIL + f"{email}"
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"x-api-key": APIKEY,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
print(response)
if response.status_code == 200:
print("200 Error!")
else:
print("Another Error!")
response = response.json()
# print(response)
uuid = response["data"]
email = response["data"]
# print("Learner ID:" )
# print(uuid)
pp.pprint(email)
def getfromUuid(baseUrl, apiKey):
def getfromUuid(BASEURL, APIKEY):
uuid = "57b2b5eb-aa56-4cee-bb32-8c678a2de1b7"
url = baseUrl + uuid
url = BASEURL + uuid
headers = {
"accept": "*/*",
"x-api-key": apiKey,
"x-api-key": APIKEY,
"content-type": "application/json",
}
response = requests.get(url, headers=headers)
@ -65,6 +65,6 @@ def getfromUuid(baseUrl, apiKey):
if __name__ == "__main__":
getfromUuid(baseUrl, apiKey)
# getfromEmail(baseUrlemail, apiKey)
# getfromName(baseUrlname, apiKey)
# getfromUuid(BASEURL, APIKEY)
getfromEmail(BASEURLEMAIL, APIKEY)
# getfromName(BASEURLNAME, APIKEY)