From 77be3c1a339b5871e9756a75214b36d5037c8b2f Mon Sep 17 00:00:00 2001 From: Moe Date: Sun, 12 Apr 2020 15:28:04 +0700 Subject: [PATCH] Update quintal.py --- Quintal/quintal.py | 85 ++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/Quintal/quintal.py b/Quintal/quintal.py index 2d5b12e..3e1ba5f 100644 --- a/Quintal/quintal.py +++ b/Quintal/quintal.py @@ -15,48 +15,51 @@ class QuintalGrabber: def __init__(self, id): self.host = "https://quintal.id" - self.id = id - - def get_data(self, query=None): - endpoint = "/id/api/initial_data/{}/?format=json".format(str(self.id)) + self.id = str(id) + self.endpoint = "/id/api/initial_data/{}/?format=json".format(self.id) try: - req = requests.get(self.host + endpoint) - data = json.loads(req.text) + self.req = requests.get(self.host + self.endpoint) + self.data = json.loads(self.req.text) except: print ("Invalid ID") sys.exit() - x = { - "lastlogin": data["student_class_semester"]["profile"]["user"]["last_login"], - "username": data["student_class_semester"]["profile"]["user"]["username"], - "firstname": data["student_class_semester"]["profile"]["user"]["first_name"], - "lastname": data["student_class_semester"]["profile"]["user"]["last_name"], - "email": data["student_class_semester"]["profile"]["user"]["email"], - "gender": data["student_class_semester"]["profile"]["gender"], - "phonenumber": data["student_class_semester"]["profile"]["mobile_no"], - "address": data["student_class_semester"]["profile"]["address"], - "city": data["student_class_semester"]["profile"]["city"], - "province": data["student_class_semester"]["profile"]["province"], - "country": data["student_class_semester"]["profile"]["country"], - "profilephoto": self.host + data["student_class_semester"]["profile"]["profile_photo"], - "birthdate": data["student_class_semester"]["profile"]["birth_date"], - "sectionname": data["student_class_semester"]["section_name"], - "gradename": data["student_class_semester"]["grade_name"], - "classname": data["student_class_semester"]["class_name"], - "i_fullname": data["student_class_semester"]["profile"]["institution"]["full_name"], - "i_shortname": data["student_class_semester"]["profile"]["institution"]["short_name"], - "i_address": data["student_class_semester"]["profile"]["institution"]["address"], - "i_city": data["student_class_semester"]["profile"]["institution"]["city"], - "i_province": data["student_class_semester"]["profile"]["institution"]["province"], - "i_country": data["student_class_semester"]["profile"]["institution"]["country"], - "i_logo": self.host + data["student_class_semester"]["profile"]["institution"]["logo"], - "i_domain": data["student_class_semester"]["profile"]["institution"]["sch_domain"] - } - if query is None: - return(x) - else: - try: - xm = x["{}".format(str(query))] - return (xm) - except Exception as e: - xm = "type {} not found".format(str(query)) - return (xm) + + def get_identity(self): + res = self.data["student_class_semester"] + return res + + def get_event(self): + res = self.data["event_users"] + return res + + def get_payment(self): + res = self.data["payments"] + return res + + def get_assignment(self): + res = self.data["assignment_class_semester_subject_submissions"] + return res + + def get_test(self): + res = self.data["test_class_semester_subject_submissions"] + return res + + def get_settings(self): + res = self.data["section_settings"] + return res + + def get_subjects(self): + res = self.data["student_class_semester_subjects"] + return res + + def get_materials(self): + res = self.data["materials"] + return res + + def get_announcements(self): + res = self.data["announcement_users"] + return res + + def get_schedule(self): + res = self.data["class_timetable_periods"] + return res \ No newline at end of file