finished workflow for sandata - even though they cancelled the launch! Worked on Anthology's group based course extractions.
This commit is contained in:
Binary file not shown.
@ -9,7 +9,21 @@ HEADERS = {
|
||||
"accept": "application/json",
|
||||
"X-Api-Key": APIKEY,
|
||||
}
|
||||
|
||||
GROUPS = [
|
||||
"Accreditation",
|
||||
"Anthology 101",
|
||||
"Baseline",
|
||||
"Course Evaluations",
|
||||
"Engage",
|
||||
"Evaluate",
|
||||
"Finance & HCM",
|
||||
"Learn",
|
||||
"Portfolio",
|
||||
"Power BI",
|
||||
"Raise",
|
||||
"Reach",
|
||||
"Student",
|
||||
]
|
||||
|
||||
def get_courses():
|
||||
"""
|
||||
|
||||
77
Scripts/API_Tests/get_courses_from_groups.py
Normal file
77
Scripts/API_Tests/get_courses_from_groups.py
Normal file
@ -0,0 +1,77 @@
|
||||
import Apikeys
|
||||
import requests
|
||||
import pprint
|
||||
import csv
|
||||
|
||||
pp= pprint.PrettyPrinter(indent=4)
|
||||
APIKEY = Apikeys.ANTHOLOGY
|
||||
HEADERS = {
|
||||
"accept": "application/json",
|
||||
"X-Api-Key": APIKEY,
|
||||
}
|
||||
BASEURL = "https://api.northpass.com/v2/"
|
||||
GROUPS = [
|
||||
"Accreditation",
|
||||
"Anthology 101",
|
||||
"Baseline",
|
||||
"Course Evaluations",
|
||||
"Engage",
|
||||
"Evaluate",
|
||||
"Finance & HCM",
|
||||
"Learn",
|
||||
"Portfolio",
|
||||
"Power BI",
|
||||
"Raise",
|
||||
"Reach",
|
||||
"Student",
|
||||
]
|
||||
|
||||
def group_ids():
|
||||
"""
|
||||
Get the group Ids from a list of named groups.
|
||||
"""
|
||||
url = "groups"
|
||||
for group in GROUPS:
|
||||
filter = f"?filter[name][cont]={group} - ("
|
||||
urlreq = f"{BASEURL}{url}{filter}"
|
||||
response = requests.get(urlreq, headers=HEADERS)
|
||||
response = response.json()
|
||||
|
||||
for data in response['data']:
|
||||
print(data['attributes']['name'])
|
||||
id = data['id']
|
||||
get_courses_in_groups(id)
|
||||
|
||||
def get_courses_in_groups(id):
|
||||
"""
|
||||
From the IDs received above, list out all of the courses.
|
||||
"""
|
||||
count = 0
|
||||
courses = []
|
||||
while True:
|
||||
# count += 1
|
||||
url = f"groups/{id}/courses?limit=100"
|
||||
courseurl = f"{BASEURL}{url}"
|
||||
coursereq = requests.get(courseurl, headers=HEADERS)
|
||||
coursedata = coursereq.json()
|
||||
# nextlink = coursedata['links']
|
||||
print(id)
|
||||
# print(coursedata)
|
||||
|
||||
for data in coursedata['included']:
|
||||
if data['attributes']['status'] == 'live':
|
||||
name = data['attributes']['name']
|
||||
id = data['attributes']['share_course_link'].split("/")[5]
|
||||
enrollments = data['attributes']['enrollments_count']
|
||||
created = data['attributes']['created_at']
|
||||
updated = data['attributes']['updated_at']
|
||||
coursedict = {
|
||||
"name": name, "id": id, "enrollments": enrollments,
|
||||
"created at": created, "updated at": updated
|
||||
}
|
||||
courses.append(coursedict)
|
||||
print(courses)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
group_ids()
|
||||
@ -15,8 +15,8 @@ REF = [
|
||||
("Nevada", "ST - Nevada (DHCFP)", "9fcf4e98-1dfd-441f-8ee4-0131c968867c"),
|
||||
("North Carolina", "ST - North Carolina (DHHS)", "67a01f25-57ca-49a8-8fed-b7181b020842"),
|
||||
("North Daktoa", "ST - North Dakota (DHHS)", "62dc0f55-a51d-4acf-90ce-dc10788385af"),
|
||||
("Ohio", "ST - OH NON-Agencies", "5d50b3ed-671b-4e97-9d5e-87f8b755dfe2"),
|
||||
("Ohio", "ST - OH ODM Agency Provider", "0c8efefc-364b-4971-b376-030493611b0d"),
|
||||
("Ohio", "ST - OH EVV Non-Agency", "5d50b3ed-671b-4e97-9d5e-87f8b755dfe2"),
|
||||
("Ohio", "ST - OH EVV ODM Agency Provider", "0c8efefc-364b-4971-b376-030493611b0d"),
|
||||
("Ohio", "ST - OH ODM AGENCY PROVIDER ALT EVV", "838c0923-43b4-48bd-8011-00fd0411c68f"),
|
||||
("Pennsylvania", "ST - PA DHS", "24c85122-aa00-4ce2-ad9b-70bb9c0f3f2f"),
|
||||
("Rhode Island", "ST - Rhode Island EOHHS", "e52fd639-bf63-4840-b8bc-2e6a6f11560e"),
|
||||
|
||||
@ -1,40 +1,39 @@
|
||||
import tmp
|
||||
data = webhook_payload:
|
||||
[
|
||||
|
||||
webhook_payload = {
|
||||
"payload": {
|
||||
"array": [
|
||||
{
|
||||
"id": "e134030d-a2a9-4de2-b4d5-87081feee18a",
|
||||
"email": "gwalden@sandata.com",
|
||||
"type": "person_properties",
|
||||
"attributes": {
|
||||
"properties": {
|
||||
"agency_name": "Test 2",
|
||||
"agency_id": "Test 2",
|
||||
"medicaid_id": "54321",
|
||||
"provider_id": "0987654321",
|
||||
"learner_role": "Agency Billing",
|
||||
"learner_state": "Tennessee",
|
||||
"oh_group_name": "ST - OH ODM Agency Provider",
|
||||
"evv_alt_for_ca_oh": "",
|
||||
"successfully_completed_secondary_registration": True,
|
||||
"cal_evv_id": None
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"params": {}
|
||||
}
|
||||
{
|
||||
id: dc9aafe3-eee7-4d50-a480-3bd9831b893a,
|
||||
email: it,
|
||||
type: person_properties,
|
||||
attributes:
|
||||
{
|
||||
properties:
|
||||
{
|
||||
agency_name: 32,
|
||||
agency_id: 323,
|
||||
medicaid_id: 22222,
|
||||
provider_id: 2123231234,
|
||||
learner_role: Agency Billing,
|
||||
learner_state: Ohio,
|
||||
oh_group_name: EVV,
|
||||
ca_group_name: None,
|
||||
cal_evv_id: None,
|
||||
successfully_completed_secondary_registration: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
for item in webhook_payload['payload']['array']:
|
||||
evv = item['attributes']['properties']['evv_alt_for_ca_oh']
|
||||
evv = item['attributes']['properties']['oh_group_name']
|
||||
state = item['attributes']['properties']['learner_state']
|
||||
group_result = [ref_state for ref_state in tmp.REF if state in ref_state]
|
||||
if len(group_result) > 1:
|
||||
for group in group_result:
|
||||
if evv in group:
|
||||
print(group)
|
||||
group_uuid = group[2]
|
||||
print(group_uuid)
|
||||
else:
|
||||
group_uuid = group_result[0][2]
|
||||
print(group_uuid)
|
||||
|
||||
Reference in New Issue
Block a user