feat(Packagers): template for interviews done, rest of code is hooked up to new template

This commit is contained in:
2024-12-14 15:14:17 -07:00
parent 27330a8a59
commit 99bfecce23
12 changed files with 88 additions and 66 deletions

View File

@ -1,11 +1,11 @@
from ReadDB import ReadDatabase
def getSchedulePackager():
def getSchedulePackager(file_name):
"""
Packages up the response for a http response
``REQUIRES``: None
``REQUIRES``: ``File_Path`` where the file is
``PROMISES``: ``JSON`` http response ready
@ -15,18 +15,18 @@ def getSchedulePackager():
"""
return {
"interviewDates": ReadDatabase()
"interviewDates": ReadDatabase(file_path=file_name)
}
from WriteDB import AppendAppointment
from email_validator import validate_email, EmailNotValidError
def SelectAppointment (appointmentJson):
def SelectAppointment (file_name, appointmentJson):
"""
Packages up a response for a http request
``REQUIRES``: ``JSON`` with the data of interviewee name, date, starttime and interviewee email
``REQUIRES``: ``File_Path`` ``JSON`` where the file is, json has the data of interviewee name, date, starttime and interviewee email
``PROMISES``: ``JSON`` Returns if the booking was a success
@ -39,15 +39,15 @@ def SelectAppointment (appointmentJson):
Example of an incoming http post body
{
"intervieweeName": "Brock",
"date": "2024-09-16",
"startTime": "10:30:00",
"date": "9/16/2024",
"startTime": "11:00:00",
"intervieweeEmail": "darkicewolf50@gmail.com"
}
"""
try:
validEmail = validate_email(appointmentJson["intervieweeEmail"], check_deliverability=True)
if validEmail:
status = AppendAppointment(date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
status = AppendAppointment(file_path=file_name, date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
if status:
resBody = {"Success": True, "validEmail": "true"}