Created new script to mass delete people. Added some notes.
This commit is contained in:
@ -4,7 +4,7 @@ from pathlib import Path
|
||||
import Apikeys
|
||||
import os
|
||||
|
||||
basefile = "/Users/normrasmussen/Downloads/mizuno-mla.csv"
|
||||
basefile = "/Users/normrasmussen/Downloads/mizuno-april-completions.csv"
|
||||
api_key = Apikeys.MIZUNO
|
||||
uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]="
|
||||
prop_url = "https://api.northpass.com/v2/properties/people/"
|
||||
@ -26,7 +26,7 @@ def load_file(basefile):
|
||||
for email in completions.itertuples():
|
||||
row_num = email[0]
|
||||
row_dict = {"row_num": row_num}
|
||||
email = email[3]
|
||||
email = email[2]
|
||||
url = uuid_url + f"{email}"
|
||||
response = requests.get(url, headers=headers)
|
||||
if response.status_code == 200:
|
||||
@ -50,7 +50,7 @@ def load_file(basefile):
|
||||
completions = completions[completions["userid"] != "0"]
|
||||
# completions = completions.iloc[:, 0:]
|
||||
completions.to_csv(
|
||||
"/Users/normrasmussen/Downloads/Mizuno-March2024-with-PGAID.csv",
|
||||
"/Users/normrasmussen/Downloads/Mizuno-April2024-with-PGAID.csv",
|
||||
index=False,
|
||||
)
|
||||
|
||||
|
||||
40
Scripts/API_Tests/mass_delete_learners_based_on_group.py
Normal file
40
Scripts/API_Tests/mass_delete_learners_based_on_group.py
Normal file
@ -0,0 +1,40 @@
|
||||
import Apikeys
|
||||
import requests
|
||||
import pprint
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
BASEURL = "https://api.northpass.com/v2"
|
||||
LEARNFILTER = "?filter[partnerships_type][eq]=Partnerships::Learner"
|
||||
APIKEY = Apikeys.SANDATA
|
||||
HEADERS = { "accept": "application/json", "X-Api-Key": APIKEY }
|
||||
|
||||
def get_people():
|
||||
count = 0
|
||||
while True:
|
||||
count =+ 1
|
||||
url = f"{BASEURL}/people/{LEARNFILTER}&limit=100&page={count}"
|
||||
resp = requests.get(url, headers=HEADERS)
|
||||
json = resp.json()
|
||||
nextlink = json['links']
|
||||
|
||||
for data in json['data']:
|
||||
id = data['id']
|
||||
groups = data['relationships']['groups']
|
||||
print(groups)
|
||||
for key,val in groups.items():
|
||||
if groups == "":
|
||||
print(groups)
|
||||
else:
|
||||
print("Else")
|
||||
|
||||
if "next" not in nextlink:
|
||||
break
|
||||
|
||||
"""
|
||||
Bulk delete endpoint: https://api.northpass.com/v2/bulk/people/delete
|
||||
Payload:
|
||||
payload = { "payload": ["asd", "asd", "asd"] }
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_people()
|
||||
Reference in New Issue
Block a user