def post(self): #received data from cleint json_data = request.get_json() print(json_data) #Responsoe Builder jsonRespBuiler = Response() if not json_data: # No data received from client jsonRespBuiler.add(Failure()) jsonRespBuiler.add(NoInputMessage) resp = make_response(jsonify(jsonRespBuiler.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp #perform login using database account = dbFacade.login(json_data['type'], json_data['email'], json_data['password']) if 'email' not in account: #invalid login jsonRespBuiler.add(Failure()) jsonRespBuiler.add(InvalidLoginMessage) resp = make_response(jsonify(jsonRespBuiler.build())) else: #Login successfull jsonRespBuiler.add(Success()) jsonRespBuiler.add(Data(account)) resp = make_response(jsonify(jsonRespBuiler.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def get(self): jsonRespBuilder = Response() availabilities = dbFacade.getAll("Availability") jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(availabilities)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def get(self): jsonRespBuilder = Response() appointments = dbFacade.getAll("Appointment") jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(appointments)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def get(self): jsonRespBuilder = Response() doctors = dbFacade.getAll("Clinics") jsonRespBuilder.add(Success) jsonRespBuilder.add(Data(doctors)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def get(self): #Response Buidler jsonRespBuilder = Response() patients = dbFacade.getAll("Patient") jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(patients)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def post(self): jsonRespBuilder = Response() json_data = request.get_json(force=True) if not json_data: jsonRespBuilder.add(Failure()) jsonRespBuilder.add(NoInputMessage()) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp result = dbFacade.register("Availability", json_data) jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(result)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def delete(self): jsonRespBuilder = Response() json_data = request.get_json(force=True) if not json_data: jsonRespBuilder.add(Failure()) jsonRespBuilder.add(NoInputMessage) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp result = dbFacade.remove("Appointment", json_data) jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(result)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def delete(self): jsonRespBuilder = Response() json_data = request.get_json(force=True) print(json_data) if not json_data: jsonRespBuilder.add(Failure()) jsonRespBuilder.add(NoInputMessage()) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp # Validate and deserialize input result = dbFacade.remove("Availability", json_data) jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(result)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp
def put(self): jsonRespBuilder = Response() json_data = request.get_json(force=True) if not json_data: jsonRespBuilder.add(Failure()) jsonRespBuilder.add(NoInputMessage()) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp result = dbFacade.update("Patient", json_data) if 'error' in result: jsonRespBuilder.add(Failure()) jsonRespBuilder.add(CustomMessage(result)) resp = make_response(jsonify(jsonRespBuilder.build())) else: jsonRespBuilder.add(Success()) jsonRespBuilder.add(Data(result)) resp = make_response(jsonify(jsonRespBuilder.build())) resp.headers['Access-Control-Allow-Origin'] = '*' return resp