def getIdByUsername(): print(request.args) if request.method == "GET": print(Handler().getIdByUsername(request.args).data) return Handler().getIdByUsername(request.args) else: return jsonify(Error="Method not allowed."), 405
def getAllUsers(): if request.method == 'POST': print("REQUEST: ", request.json) return Handler().insertUser(request.json) else: if not request.args: return Handler().getAllUsers() else: return Handler().getUserByIdORUsername(request.args)
def getContactById(): if request.method == 'GET': return Handler().getContactsById(request.args.to_dict()) elif request.method == 'POST': return Handler().addToContactList(request.args.to_dict(), request.json) elif request.method == 'DELETE': # NOT YET!!! return Handler().deleteContact(request.args.to_dict(), request.json) else: return jsonify(Error="Method not allowed."), 405
def getUserById(uid): print(uid) if request.method == 'GET': return Handler().getUserById(uid) elif request.method == 'PUT': return Handler().updateUser( uid, request.json) # update needs to be implemented elif request.method == 'DELETE': return Handler().deleteUser(uid) else: return jsonify(Error="Method not allowed."), 405
def getAllContactsFromUser(uid): if request.method == 'GET': return Handler().getContactsById(uid) elif request.method == 'POST': return Handler().addToContactList(uid, request.json) elif request.method == 'DELETE': if not request.json: return jsonify( Error="Need to specify parameters for deletion"), 405 else: return Handler().deleteContact(uid, request.json) else: return jsonify(Error="Method not allowed."), 405
def deleteContactFromUser(uid, cid): if request.method == 'DELETE': form = {} form['cid'] = cid return Handler().deleteContact(uid, (form)) else: return jsonify(Error="Method not allowed."), 405
def register_user(): if request.method == 'POST': return Handler().insertUser(request.json)
def validate_login(): if request.method == 'POST': print(request.json) print(Handler().validate_login(request.json)) return Handler().validate_login(request.json)