DATA SAVE
This commit is contained in:
+42
@@ -231,6 +231,48 @@ def salary_loanoffers():
|
|||||||
|
|
||||||
@app.route('/salary/loanselect', methods=["POST"])
|
@app.route('/salary/loanselect', methods=["POST"])
|
||||||
def salary_loanselect():
|
def salary_loanselect():
|
||||||
|
try:
|
||||||
|
data = request.json
|
||||||
|
if not data:
|
||||||
|
return {
|
||||||
|
"message": "Please provide bvn and loan",
|
||||||
|
"data": None,
|
||||||
|
"error": "Bad request"
|
||||||
|
}, 400
|
||||||
|
# validate input
|
||||||
|
loan = data["loan"]
|
||||||
|
bvn = data["bvn"]
|
||||||
|
if loan != '' and bvn != '' :
|
||||||
|
loan = load_offer(loan,bvn)
|
||||||
|
INSERT_LOAN ="INSERT INTO loan_select (loan, bvn) VALUES(%s, %s)"
|
||||||
|
new_data = (loan,bvn)
|
||||||
|
with connection:
|
||||||
|
with connection.cursor(cursor_factory=psycopg2.extras.DictCursor) as cursor:
|
||||||
|
cursor.execute(INSERT_LOAN, new_data)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"message": "REQUEST_AMOUNT",
|
||||||
|
"loan": loan,
|
||||||
|
"active_loan_count": 0,
|
||||||
|
"active_loan": []
|
||||||
|
}, 201
|
||||||
|
else:
|
||||||
|
return {
|
||||||
|
"message": "Error fetching loan!, invalid bvn or loan",
|
||||||
|
"data": None,
|
||||||
|
"error": "Unauthorized"
|
||||||
|
}, 404
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"message": "Something went wrong!",
|
||||||
|
"error": str(e),
|
||||||
|
"data": None
|
||||||
|
}, 500
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/salary/loanapply', methods=["POST"])
|
||||||
|
def salary_loanapply():
|
||||||
try:
|
try:
|
||||||
data = request.json
|
data = request.json
|
||||||
if not data:
|
if not data:
|
||||||
|
|||||||
Reference in New Issue
Block a user