import json with open('./sample_payload.json', 'r') as file: input = json.load(file) def main(input): # input = input['input'] quiz_name = "" quiz_score = "" sso_uid = "" course = "" timestamp = input['payload']['data']['attributes']['created_at'] for items in input['payload']['data']['included']: if items['type'] == 'quizzes': if items['attributes']['name'] == 'Deutsch Einstufungstest': quiz_score = input['attributes']['value'] quiz_name = items['attributes']['name'] print(quiz_score, quiz_name) elif items['type'] == 'people': sso_uid = items['attributes']['sso_uid'] elif items['type'] == 'courses': course = items['attributes']['name'] if input['payload']['data']['type'] == 'quiz_completed_events': job_report = { "email": sso_uid, "course": course, "quiz_name": quiz_name, "quiz_score": quiz_score, "timestamp": timestamp } print(job_report) if quiz_name: if quiz_name == "Deutsch Einstufungstest": """ At this point, we need to add a new row to the Google Sheet The columns to add are: email = sso_uid course name = course date stamp = created at quiz name = quiz name quiz score = quiz score """ print("adding row!") else: """ At this point, we need to add a new row to the Google Sheet The columns to add are: email = sso_uid course name = course date stamp = created at link to BE profile = "=HYPERLINK(SUBSTITUTE("https://ops-live.zenjob.tools/ops/employee/showByUuid/{{sso_uid}}}";"test";INDIRECT("R[0]C1"; FALSE));"Talent Profil")" Tag = "=IFS(INDIRECT("R[0]C2"; FALSE)="Kassentraining";"food_cashier_lms, exp_cashier_123";INDIRECT("R[0]C2"; FALSE)="Servicetraining";"pool_service_lms, exp_service_staff_123";INDIRECT("R[0]C2"; FALSE)="";"")" tag assigned = false """ print("final else statement") if __name__ == "__main__": main(input)