From 7fc5474f987d82fe27d9070eb190e57c8e5b5afe Mon Sep 17 00:00:00 2001 From: lennyaiko Date: Thu, 27 Mar 2025 11:41:10 +0100 Subject: [PATCH] done with loan offers --- .gitignore | 2 +- app/__init__.py | 4 +- app/__pycache__/__init__.cpython-310.pyc | Bin 771 -> 818 bytes app/routes/__init__.py | 5 +- .../__pycache__/__init__.cpython-310.pyc | Bin 216 -> 252 bytes .../__pycache__/eligibility.cpython-310.pyc | Bin 987 -> 970 bytes app/routes/eligibility.py | 2 - app/routes/loan.py | 43 ++++++++++++++++++ openapi.yml | 37 +++++++++++++++ 9 files changed, 86 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index ea42e26..90cc466 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -./vscode +.vscode/ __pycache__/ .env \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py index a98c30b..4541b93 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,7 +1,7 @@ from flask import Flask from flask_cors import CORS from app.config import Config -from app.routes import auth_bp, eligibility_bp +from app.routes import auth_bp, eligibility_bp, loan_bp from app.errors import method_not_allowed, unsupported_media_type @@ -16,7 +16,7 @@ def create_app(): # Register blueprints app.register_blueprint(auth_bp) - # app.register_blueprint(loan_bp) + app.register_blueprint(loan_bp, url_prefix="/loans") app.register_blueprint(eligibility_bp, url_prefix="/eligibility") # app.register_blueprint(repayment_bp) diff --git a/app/__pycache__/__init__.cpython-310.pyc b/app/__pycache__/__init__.cpython-310.pyc index 30e884ee10e5b534dd82ac8055e2585ad1d2937b..61b13ba248bfbcb78e91e1a148d3255f8cb7e474 100644 GIT binary patch delta 329 zcmYjMF-yZh6ux(tUYg``igYYRCrJth1qXKrL2%K<8!Rb_^&~Oznu0BEx;lizSsh(F z`CGC%_!o5bswjQK$M=2jeedz^=$!Jx_g!S_EBqJ{Qu8jH)cxIF?g$4^f|6F|=AQ6! zCYaGQvG0-a>)GZyY3z7XT?~e0!_!QTOx2+1b{fv@Lq0Ji>w zjZWMAp&SDNG$by|SEPL1$6;^Hcx}u`8@q%92WBy_uv#(pQNZ;z-rrWX5yCa8tyHN( Xjn)6QpE>25{t|Hgj=Qu2tH8)N)Bj6y delta 285 zcmdnQ*38D2&&$ij00gcoPt%_>P2`hd449~GD#gfZ^nShf{d0j3pi7lOSl#?F*4LJ z0NE@h+z@s!gC^_b5=J9+9(^Qznv79grA0aM1x2Z8nH8B+85tNd=K~2%p2=4kJtiwL z$%?Q8omj*HBs3XsF((!jtYj$SnHc_l*;E08K;ow!h+iw(%)Vc=mDU<3ds@Dw=! delta 61 zcmeyvc!QBEpO=@50SNMxCUPk-%1qRjVPy_x&}5kyp~UP5q&n0&S27f_096#ROgya5 L0b=nm2rvQwg8d6m diff --git a/app/routes/__pycache__/eligibility.cpython-310.pyc b/app/routes/__pycache__/eligibility.cpython-310.pyc index e8711c075d41c7c4a26e6d7cbd5a3bfa9b78c8bc..5267435a714538d1444d1873f266ab0c746962d3 100644 GIT binary patch delta 120 zcmcc3eu|wppO=@50SK09Jx!lGk@uTa5Rg;Cki}TbP{NeOoWdx{Fq)pO=@50SI{2o~Cb{$oowx3dkv8$YQKzC}GNCPGOW}n9Y#FG?%HCv4o|D zv6+#PVX`cvAtUQ%e@1gg1-2q)p!!=ZS;hHzMXVquTXKG0T4wq!)`FtUypqZDnUopD qCLd<9<}v`vvM~uTaxhJ1W7cMrm~6zHC@KLIED}Q{#3!#{RssM`Rw69` diff --git a/app/routes/eligibility.py b/app/routes/eligibility.py index d8c7cea..45b4f95 100644 --- a/app/routes/eligibility.py +++ b/app/routes/eligibility.py @@ -10,8 +10,6 @@ def eligibility_check(): data = request.json api_url = f"{current_app.config['API_BASE_URL']}/EligibilityCheck" - print(api_url) - # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code response = { diff --git a/app/routes/loan.py b/app/routes/loan.py index e69de29..f6cf44e 100644 --- a/app/routes/loan.py +++ b/app/routes/loan.py @@ -0,0 +1,43 @@ +from flask import Blueprint, request, jsonify, current_app +import requests +from app.utils.auth import get_headers + +loan_bp = Blueprint("loan", __name__) + + +@loan_bp.route("/select-offer", methods=["POST"]) +def select_offer(): + data = request.json + api_url = f"{current_app.config['API_BASE_URL']}/SelectOffer" + + # response = requests.post(api_url, json=data, headers=get_headers()) + # return jsonify(response.json()), response.status_code + response = { + "transactionId": "1231231321232", + "customerId": "1256907", + "accountId": "5948306019", + "outstandingDebtAmount": 0, + "loan": [ + { + "offerId": "14451", + "productId": "2030", + "amount": 10000, + "upfrontPayment": 1000, + "interestRate": 3, + "Interest": 300, + "ManagementRate": 1, + "ManagementFee": 100, + "InsuranceRate": 1, + "InsuranceFee": 100, + "VATRate": 7.5, + "VATamount": 100, + "recommendedRepaymentDates": ["2022-11-30"], + "installmentAmount": 11000, + "totalRepaymentAmount": 11000, + } + ], + "resultCode": "00", + "resultDescription": "Successful", + } + + return jsonify(response), 200 diff --git a/openapi.yml b/openapi.yml index 25f7fbf..f946ca3 100644 --- a/openapi.yml +++ b/openapi.yml @@ -58,3 +58,40 @@ paths: responses: 200: description: A successful response + /loans/select-offer: + post: + summary: Selects an offer for a loan + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + requestId: + type: string + example: "202111170001371256908" + transactionId: + type: string + example: "1231231321232" + customerId: + type: string + example: "1256907" + accountId: + type: string + example: "5948306019" + msisdn: + type: string + example: "123456789" + requestedAmount: + type: integer + example: 10000 + productId: + type: string + example: "101" + channel: + type: string + example: "USSD" + responses: + 200: + description: A successful response