diff --git a/Scripts/API_Tests/Apikeys.py b/Scripts/API_Tests/Apikeys.py index a0ed49ad..cbc398c2 100644 --- a/Scripts/API_Tests/Apikeys.py +++ b/Scripts/API_Tests/Apikeys.py @@ -32,3 +32,4 @@ BLOOMERANG = "ewGDqLgsklMnytqzUka2wmgIi" GSU = "rUUKNuBZ0rmRNPftB4smYhQ5L" EMPLOY = "qcNggCm4SBtC0gTqLGv30vX8l" LUMAFINTECH = "oDFA7XSmjEKjEwIDIKLm0rxs1" +SUPPLIERPROD = "DtRH9m4r0zMbJEx1yWBGKlObi" diff --git a/Scripts/API_Tests/__pycache__/Apikeys.cpython-310.pyc b/Scripts/API_Tests/__pycache__/Apikeys.cpython-310.pyc index c9a7881e..33ebff38 100644 Binary files a/Scripts/API_Tests/__pycache__/Apikeys.cpython-310.pyc and b/Scripts/API_Tests/__pycache__/Apikeys.cpython-310.pyc differ diff --git a/Scripts/API_Tests/get_courses_and_categories.py b/Scripts/API_Tests/get_courses_and_categories.py index 7d70001a..0b254ac0 100644 --- a/Scripts/API_Tests/get_courses_and_categories.py +++ b/Scripts/API_Tests/get_courses_and_categories.py @@ -4,25 +4,16 @@ import Apikeys import pprint pp = pprint.PrettyPrinter(indent=4) -apiKey = Apikeys.SKUID +apiKey = Apikeys.SUPPLIERPROD course_dict = {} -COURSES= [ -"Shopping an order", -"Delivery FAQs", -"Checking out Shopping & Delivery orders", -"Shopping & Delivery FAQs", -"Communicating with customers", -"Delivering an order", -] - def get_course(): count = 0 courses = [] while True: count += 1 - url = f"https://api.northpass.com/v2/courses?page={count}" + url = f"https://api2.northpass.com/v2/courses?page={count}" headers = {"accept": "application/json", "X-Api-Key": apiKey} response = requests.get(url, headers=headers) data = response.json() @@ -32,9 +23,6 @@ def get_course(): status = response["attributes"]["status"] uuid = response["id"] name = response["attributes"]["name"] - # build_url = response["links"]["builder"]["href"] - # if name in COURSES: - print(uuid) course_dict = { "id": uuid, "name": name, @@ -43,7 +31,6 @@ def get_course(): # "url": f"https://walmart.northpass.com/app/courses/{uuid}", } courses.append(course_dict) - # print(courses) # FIX: Up until here, each course gets read to the terminal. # FIX: After this, something is being overwritten. @@ -54,49 +41,41 @@ def get_course(): if "next" not in nextlink: break - # write_to_csv(courses) - # pp.pprint(courses) - # print(len(courses)) - def get_cat_name(cat_id, course_dict, courses): headers = {"accept": "application/json", "X-Api-Key": apiKey} - cats = [] if len(cat_id) == 0: pass - elif len(cat_id) == 1: - categoryid = cat_id[0]["id"] - url = f"https://api.northpass.com/v2/categories/{categoryid}" - cat_resp = requests.get(url, headers=headers) - cat_data = cat_resp.json() - try: - cat_name = cat_data["data"]["attributes"]["name"] - cats.append(cat_name) - course_dict.update({"categories": cats}) - except KeyError: - print(f"key error for cat {cat_id}") - finally: - pass + # elif len(cat_id) == 1: + # categoryid = cat_id[0]["id"] + # url = f"https://api2.northpass.com/v2/categories/{categoryid}" + # cat_resp = requests.get(url, headers=headers) + # cat_data = cat_resp.json() + # try: + # cat_name = cat_data["data"]["attributes"]["name"] + # cats.append(cat_name) + # course_dict.update({"categories": cats}) + # except KeyError: + # print(f"key error for cat {cat_id}") + # finally: + # pass else: + cats = [] for item in cat_id: categoryid = item["id"] - url = f"https://api.northpass.com/v2/categories/{categoryid}" + url = f"https://api2.northpass.com/v2/categories/{categoryid}" cat_resp = requests.get(url, headers=headers) cat_data = cat_resp.json() cat_name = cat_data["data"]["attributes"]["name"] cats.append(cat_name) - course_dict.update({"categories": cats}) + course_dict.update({"categories": cats}) + print(course_dict) - try: - courses.append(course_dict) - except TypeError as e: - print(f"Error: {e}") - finally: - write_to_csv(courses) + write_to_csv(courses) def write_to_csv(courses): df = pd.DataFrame.from_dict(courses) - df.to_csv("/Users/normrasmussen/Downloads/sps_courses.csv") + df.to_csv("/Users/normrasmussen/Downloads/supplier_courses.csv") if __name__ == "__main__": diff --git a/Scripts/API_Tests/get_courses_w_descriptions_or_props.py b/Scripts/API_Tests/get_courses_w_descriptions_or_props.py index 62aeb5c8..b0e5b392 100644 --- a/Scripts/API_Tests/get_courses_w_descriptions_or_props.py +++ b/Scripts/API_Tests/get_courses_w_descriptions_or_props.py @@ -7,7 +7,7 @@ import requests import pandas as pd import Apikeys -APIKEY = Apikeys.SPARKPROD +APIKEY = Apikeys.SUPPLIERPROD COURSES = [] HEADERS = {"accept": "application/json", "X-Api-Key": APIKEY} diff --git a/Todos.md b/Todos.md index 9ee9cf91..f59913d3 100644 --- a/Todos.md +++ b/Todos.md @@ -454,3 +454,9 @@ New Commerce Catalog: * Issue is that this needs to be addressed with supplier. +## 12/19/2024 +- [ ] Walmart - See if we can get when Jess added courses to the LP in Spark +- [X] Walmart - PDF of LP overview screens +- [X] Walmart - CSV of LPs and their Courses +- [ ] Chubb - Revisit Qualtrics Milestone +