Chubb, Sandata, Skuid notes. Updated Anthology's get courses from groups since we hit the API per-page limit. Sendgrid for Sandata.
This commit is contained in:
@ -33,9 +33,6 @@ def group_ids():
|
||||
Get the group Ids from a list of named groups.
|
||||
"""
|
||||
url = "groups"
|
||||
df = pd.DataFrame()
|
||||
count = 0
|
||||
courses = []
|
||||
ids = []
|
||||
for group in GROUPS:
|
||||
filter = f"?filter[name][cont]={group} - ("
|
||||
@ -49,35 +46,66 @@ def group_ids():
|
||||
group_tupe = (id1, group)
|
||||
ids.append(group_tupe)
|
||||
|
||||
get_courses(ids)
|
||||
|
||||
def get_courses(ids):
|
||||
df = pd.DataFrame()
|
||||
courses = []
|
||||
for tupe in ids:
|
||||
count += 1
|
||||
id = tupe[0]
|
||||
print(id)
|
||||
group = tupe[1]
|
||||
url2 = f"groups/{id}/courses?limit=100?page={count}"
|
||||
url2 = f"groups/{id}/courses?limit=100"
|
||||
courseurl = f"{BASEURL}{url2}"
|
||||
coursereq = requests.get(courseurl, headers=HEADERS)
|
||||
coursedata = coursereq.json()
|
||||
|
||||
for cdata in coursedata["included"]:
|
||||
if cdata["attributes"]["status"] == "live":
|
||||
name = cdata["attributes"]["name"]
|
||||
courseid = cdata["attributes"]["share_course_link"].split("/")[5]
|
||||
enrollments = cdata["attributes"]["enrollments_count"]
|
||||
created = cdata["attributes"]["created_at"]
|
||||
updated = cdata["attributes"]["updated_at"]
|
||||
coursedict = {
|
||||
"group": group,
|
||||
"name": name,
|
||||
"id": courseid,
|
||||
"enrollments": enrollments,
|
||||
"created at": created,
|
||||
"updated at": updated,
|
||||
}
|
||||
courses.append(coursedict)
|
||||
nextlink = coursedata["links"]
|
||||
count = 0
|
||||
while "next" in nextlink:
|
||||
for count in range(10):
|
||||
print(f"Next link for {group} and page {count}")
|
||||
coursereq2 = requests.get(f"{courseurl}&page={count}", headers=HEADERS)
|
||||
coursedata2 = coursereq2.json()
|
||||
next = coursedata2["links"]
|
||||
coursedict = parse_data(coursedata2, group)
|
||||
print(f"While Coursedict --> {coursedict}")
|
||||
if coursedict is None:
|
||||
pass
|
||||
else:
|
||||
courses.append(coursedict)
|
||||
if "next" not in next:
|
||||
break
|
||||
else:
|
||||
print(f"Else Statement for {group}")
|
||||
coursedict = parse_data(coursedata, group)
|
||||
print(f"Else Coursedict --> {coursedict}")
|
||||
if coursedict is None:
|
||||
pass
|
||||
else:
|
||||
courses.append(coursedict)
|
||||
|
||||
pddata = df.from_records(courses)
|
||||
pddata.to_csv("~/Downloads/Anthology_Course_IDs_Names.csv")
|
||||
|
||||
def parse_data(coursedata, group):
|
||||
for cdata in coursedata["included"]:
|
||||
if cdata["attributes"]["status"] == "live":
|
||||
name = cdata["attributes"]["name"]
|
||||
courseid = cdata["attributes"]["share_course_link"].split("/")[5]
|
||||
enrollments = cdata["attributes"]["enrollments_count"]
|
||||
created = cdata["attributes"]["created_at"]
|
||||
updated = cdata["attributes"]["updated_at"]
|
||||
coursedict = {
|
||||
"group": group,
|
||||
"name": name,
|
||||
"id": courseid,
|
||||
"enrollments": enrollments,
|
||||
"created at": created,
|
||||
"updated at": updated,
|
||||
}
|
||||
if coursedict is not None:
|
||||
return coursedict
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
group_ids()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import tmp
|
||||
data = webhook_payload:
|
||||
|
||||
webhook_payload:
|
||||
[
|
||||
|
||||
{
|
||||
|
||||
@ -2,11 +2,11 @@ import requests
|
||||
import sys
|
||||
sys.path.insert(0, "./API_Tests/")
|
||||
import Apikeys
|
||||
apikey = Apikeys.CIN7
|
||||
apikey = Apikeys.SANDATA
|
||||
|
||||
url = "https://api.northpass.com/v2/email_domains"
|
||||
header = { "x-api-key": apikey, "Content-Type": "application/json" }
|
||||
payload = {"domain": "cin7.com", "custom_dkim_selector": "n"}
|
||||
payload = {"domain": "sandata.com", "custom_dkim_selector": "g"}
|
||||
|
||||
response = requests.post(url, headers=header, json=payload)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user