DouglasElliman & other scripts
This commit is contained in:
100
Scripts/API_Tests/assignCoursetoGroups.py
Normal file
100
Scripts/API_Tests/assignCoursetoGroups.py
Normal file
@ -0,0 +1,100 @@
|
||||
import requests
|
||||
|
||||
apiKey = "Bknf8kidbluRfcKu3m3lKoxS8"
|
||||
groups = [
|
||||
"Armonk",
|
||||
"Babylon",
|
||||
"Bayside",
|
||||
"Bedford",
|
||||
"Cutchogue",
|
||||
"East Hampton",
|
||||
"East Setauket",
|
||||
"Executive",
|
||||
"Farmingville",
|
||||
"Franklin Square",
|
||||
"Garden City",
|
||||
"Great Neck",
|
||||
"Greenport",
|
||||
"Hampton Bays",
|
||||
"Hamptons",
|
||||
"Huntington",
|
||||
"Huntington Station",
|
||||
"Katonah",
|
||||
"Locust Valley",
|
||||
"Long Beach",
|
||||
"Long Island",
|
||||
"Long Island City",
|
||||
"Manhasset",
|
||||
"Manhattan",
|
||||
"Massapequa Park",
|
||||
"Mattituck",
|
||||
"Merrick",
|
||||
"Montauk",
|
||||
"New Hyde Park",
|
||||
"New York",
|
||||
"North Fork",
|
||||
"Ocean Beach",
|
||||
"Plainview",
|
||||
"Port Washington",
|
||||
"Queens",
|
||||
"Quogue",
|
||||
"Rockville Centre",
|
||||
"Roslyn",
|
||||
"Sag Harbor",
|
||||
"Sayville",
|
||||
"Scarsdale",
|
||||
"Sea Cliff",
|
||||
"Smithtown",
|
||||
"Southampton",
|
||||
"Syosset",
|
||||
"Westchester",
|
||||
"Westhampton Beach"
|
||||
]
|
||||
|
||||
def findgroupIDs(apiKey, groups):
|
||||
groupuuids = []
|
||||
badGroups = []
|
||||
for group in groups:
|
||||
url = "https://api.northpass.com/v2/groups?filter[name][eq]="
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"X-Api-Key": apiKey
|
||||
}
|
||||
response = requests.get(url + group, headers=headers)
|
||||
response = response.json()
|
||||
try:
|
||||
response = response["data"][0]["id"]
|
||||
groupuuids.append(response)
|
||||
except:
|
||||
badGroups.append(group)
|
||||
finally:
|
||||
pass
|
||||
#print(badGroups)
|
||||
#print(groupuuids)
|
||||
assignCourse(apiKey,url, groupuuids)
|
||||
|
||||
def assignCourse(apiKey, url, groupuuids):
|
||||
for group in groupuuids:
|
||||
try:
|
||||
url = f"https://api.northpass.com/v2/groups/{group}/relationships/courses"
|
||||
courseuuid = "10e9b174-cbad-4caa-b0ff-1a7338f2345a"
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"content-type": "application/json",
|
||||
"X-Api-Key": apiKey
|
||||
}
|
||||
payload = {"data": [
|
||||
{
|
||||
"type": "courses",
|
||||
"id": courseuuid
|
||||
}
|
||||
]}
|
||||
print(f"Group {group} successfully accepted the course")
|
||||
response = requests.post(url, json=payload, headers=headers)
|
||||
except:
|
||||
print(f"Group {group} does not have that course, yet")
|
||||
finally:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
findgroupIDs(apiKey, groups)
|
||||
39
Scripts/API_Tests/getuuid_from_email.py
Normal file
39
Scripts/API_Tests/getuuid_from_email.py
Normal file
@ -0,0 +1,39 @@
|
||||
import requests
|
||||
|
||||
baseUrlname = "https://api.northpass.com/v2/people?filter[name][eq]="
|
||||
baseUrlemail = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
apiKey = "JRDpCGQ7vSRiva6t5OkWDr5eJ" #This is for G2
|
||||
|
||||
def getfromName(baseUrlname, apiKey):
|
||||
name = "Adam Nelson"
|
||||
url = baseUrlname + f"{name}"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": apiKey,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
response = response.json()
|
||||
print(response)
|
||||
uuid = response["data"][0]["id"]
|
||||
print("Learner ID:" )
|
||||
print(uuid)
|
||||
|
||||
def getfromEmail(baseUrlemail, apiKey):
|
||||
email = "norm+g2test@northpass.com"
|
||||
#email = "aaron.rodgers@corpay.com"
|
||||
url = baseUrlemail + f"{email}"
|
||||
headers = {
|
||||
"accept": "*/*",
|
||||
"x-api-key": apiKey,
|
||||
"content-type": "application/json",
|
||||
}
|
||||
response = requests.get(url, headers=headers)
|
||||
response = response.json()
|
||||
print(response)
|
||||
uuid = response["data"][0]["id"]
|
||||
print("Learner ID:" )
|
||||
|
||||
if __name__ == "__main__":
|
||||
getfromEmail(baseUrlemail, apiKey)
|
||||
#getfromName(baseUrl, apiKey)
|
||||
Reference in New Issue
Block a user