Small notes changes. Added HackerRank Internal's Templates

This commit is contained in:
Norm Rasmussen
2023-02-13 13:35:02 -05:00
parent 747bb47464
commit 0a322b8f3a
333 changed files with 1881 additions and 106 deletions

View File

@ -2,64 +2,62 @@ 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"
]
"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
}
headers = {"accept": "application/json", "X-Api-Key": apiKey}
response = requests.get(url + group, headers=headers)
response = response.json()
try:
@ -69,26 +67,22 @@ def findgroupIDs(apiKey, groups):
badGroups.append(group)
finally:
pass
#print(badGroups)
#print(groupuuids)
assignCourse(apiKey,url, groupuuids)
# print(badGroups)
# print(groupuuids)
assignCourse(apiKey, url, groupuuids)
def assignCourse(apiKey, url, groupuuids):
for group in groupuuids:
try:
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
"X-Api-Key": apiKey,
}
payload = {"data": [
{
"type": "courses",
"id": courseuuid
}
]}
payload = {"data": [{"type": "courses", "id": courseuuid}]}
print(f"Group {group} successfully accepted the course")
response = requests.post(url, json=payload, headers=headers)
except:
@ -96,5 +90,6 @@ def assignCourse(apiKey, url, groupuuids):
finally:
pass
if __name__ == "__main__":
findgroupIDs(apiKey, groups)