Uncommented some of Pipedrive's templates for password reset warning. WilliamSonoma notes, Aubrey check in.

This commit is contained in:
Norm Rasmussen
2023-10-05 17:26:26 -04:00
parent a610b52c6e
commit 8cd8a61d34
26 changed files with 541 additions and 798 deletions

View File

@ -0,0 +1,66 @@
"""
Small script to grab the list of courses from Northpass API
along with their status & description and write them to a CSV.
"""
import requests
import pandas as pd
import Apikeys
APIKEY = Apikeys.walmartprod
def get_course():
"""
This function paginates through API responses to get the courses information
"""
count = 0
courses = []
course_dict = {}
while True:
count += 1
url = f"https://api2.northpass.com/v2/courses?page={count}"
print(url)
headers = {"accept": "application/json", "X-Api-Key": APIKEY}
response = requests.get(url, headers=headers)
data = response.json()
nextlink = data["links"]
for response in data["data"]:
status = response["attributes"]["status"]
if status == "live":
uuid = response["id"]
name = response["attributes"]["name"]
full_description = response["attributes"]["full_description"]
course_dict = {
"id": uuid,
"name": name,
"status": status,
"full_description": full_description,
}
try:
courses.append(course_dict)
except TypeError as e:
print(f"Error: {e}")
finally:
write_to_csv(courses)
else:
pass
if "next" not in nextlink:
break
def write_to_csv(courses):
"""
Function to write the list of dictionaries to a CSV using pandas.
Takes on parameter, the list of courses.
"""
df = pd.DataFrame.from_dict(courses)
df.to_csv("/Users/normrasmussen/Downloads/walmart_courses_descriptions.csv")
if __name__ == "__main__":
get_course()

View File

@ -1,23 +1,30 @@
import requests
import Apikeys
APIKEY = Apikeys.walmartprod
def list_prop():
url = "http://api.northpass.com/v2/properties/people/bulk"
"""
Quick little function to output Course Properties to terminal
"""
url = "http://api2.northpass.com/v2/properties/courses/properties"
headers = {
"X-Api-Key": "SlpQlju219WnWogn94dQUT6Yt",
"X-Api-Key": APIKEY,
"accept": "application/json",
"content-type": "application/json",
}
payload = {
"data": [
{
"attributes": {"properties": {"sample_list": "item 3"}},
"id": "0b31c435-c18b-4573-984e-32cda57045b4",
"type": "person_properties",
}
]
}
response = requests.post(url, headers=headers, json=payload)
# payload = {
# "data": [
# {
# "attributes": {"properties": {"sample_list": "item 3"}},
# "id": "0b31c435-c18b-4573-984e-32cda57045b4",
# "type": "person_properties",
# }
# ]
# }
# response = requests.post(url, headers=headers, json=payload)
response = requests.get(url, headers=headers)
print(response.text)
print(response.status_code)