From 9ef9e632978f46049344d97105eb1515058d140f Mon Sep 17 00:00:00 2001 From: Norm Rasmussen Date: Mon, 3 Apr 2023 17:16:01 -0400 Subject: [PATCH] Started and almost completed Mizuno Script --- CustomerNotes/G2.md | 4 +++ Scripts/API_Tests/get_courses.py | 14 ++++---- Scripts/Mizuno/add-pgaids.py | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 Scripts/Mizuno/add-pgaids.py diff --git a/CustomerNotes/G2.md b/CustomerNotes/G2.md index ee02d6bf..5feac68b 100644 --- a/CustomerNotes/G2.md +++ b/CustomerNotes/G2.md @@ -312,3 +312,7 @@ BDR team is launching their own academy/cert program. It's an internal program a They will be the QA tester in May DONE: Send Katlin and Erin examples of customized login pages, forms, learning paths/dashboards, etc. + +## 04/04/2023 + +TODO: Reach out to Katlin regarding admin/embedded. diff --git a/Scripts/API_Tests/get_courses.py b/Scripts/API_Tests/get_courses.py index f787e78d..a0c23430 100644 --- a/Scripts/API_Tests/get_courses.py +++ b/Scripts/API_Tests/get_courses.py @@ -5,6 +5,7 @@ import Apikeys apiKey = Apikeys.walmartprod course_dict = {} + def get_course(): count = 0 courses = [] @@ -22,11 +23,11 @@ def get_course(): uuid = response["id"] name = response["attributes"]["name"] course_dict = { - "id": uuid, - "name": name, - "status": status, - "url": f"https://walmart.northpass.com/app/courses/{uuid}" - } + "id": uuid, + "name": name, + "status": status, + "url": f"https://walmart.northpass.com/app/courses/{uuid}", + } # FIX: Up until here, each course gets read to the terminal. # FIX: After this, something is being overwritten. @@ -37,6 +38,7 @@ def get_course(): if "next" not in nextlink: break + def get_cat_name(cat_id, course_dict, courses): headers = {"accept": "application/json", "X-Api-Key": apiKey} cats = [] @@ -61,7 +63,6 @@ def get_cat_name(cat_id, course_dict, courses): cats.append(cat_name) course_dict.update({"categories": cats}) - try: courses.append(course_dict) except TypeError as e: @@ -74,5 +75,6 @@ def write_to_csv(courses): df = pd.DataFrame.from_dict(courses) df.to_csv("/Users/normrasmussen/Downloads/walmart_courses.csv") + if __name__ == "__main__": get_course() diff --git a/Scripts/Mizuno/add-pgaids.py b/Scripts/Mizuno/add-pgaids.py new file mode 100644 index 00000000..a5cf72f1 --- /dev/null +++ b/Scripts/Mizuno/add-pgaids.py @@ -0,0 +1,58 @@ +import requests +import pandas as pd +from pathlib import Path +import os + +basefile = "/Users/normrasmussen/Downloads/mizuno-march-completions.csv" +api_key = "stXNF84HWL8aCGeRjHEo2rJ1U" +uuid_url = "https://api.northpass.com/v2/people?filter[email][eq]=" +prop_url = "https://api.northpass.com/v2/properties/people/" +headers = { + "accept": "*/*", + "x-api-key": api_key, + "content-type": "application/json", + } +drop_rows = [] + +def load_file(basefile): + try: + if os.path.isfile(basefile): + basefile = Path(basefile) + print(f"File found! Importing {basefile}") + completions = pd.read_csv(basefile) + for email in completions.itertuples(): + row_num = email[0] + email = email[3] + print(email) + url = uuid_url + f"{email}" + response = requests.get(url, headers=headers) + if response.status_code == 200: + print("Fetching person found!") + response = response.json() + uuid = response["data"][0]["id"] + url2 = prop_url + f"{uuid}" + response = requests.get(url2, headers=headers) + data = response.json() + pgaid = data["data"]["attributes"]["properties"]["account_number"] + write_to_csv(pgaid, row_num, completions) + except KeyError as e: + print(e) + finally: + pass + +def write_to_csv(pgaid, row_num, completions): + print(pgaid) + try: + completions.loc[completions.index[row_num], "PGA ID"] = pgaid + except (TypeError, KeyError) as e: + print(e) + finally: + pass + #completions.drop(completions["PGA ID"] == "0") + print("the end?") + print(completions) + + +if __name__ == "__main__": + load_file(basefile) +