diff --git a/app.log b/app.log index f6358cd..741d0ec 100644 --- a/app.log +++ b/app.log @@ -274,3 +274,107 @@ 2025-04-10 15:29:07,431 - INFO - No message received within timeout 2025-04-10 15:29:07,489 - INFO - No message received within timeout 2025-04-10 15:29:07,532 - INFO - No message received within timeout +2025-04-10 15:29:12,431 - INFO - No message received within timeout +2025-04-10 15:29:12,432 - INFO - No message received within timeout +2025-04-10 15:29:12,490 - INFO - No message received within timeout +2025-04-10 15:29:12,533 - INFO - No message received within timeout +2025-04-10 15:29:17,432 - INFO - No message received within timeout +2025-04-10 15:29:17,433 - INFO - No message received within timeout +2025-04-10 15:29:17,491 - INFO - No message received within timeout +2025-04-10 15:29:17,534 - INFO - No message received within timeout +2025-04-10 15:29:22,433 - INFO - No message received within timeout +2025-04-10 15:29:22,434 - INFO - No message received within timeout +2025-04-10 15:29:22,492 - INFO - No message received within timeout +2025-04-10 15:29:22,535 - INFO - No message received within timeout +2025-04-10 15:29:27,434 - INFO - No message received within timeout +2025-04-10 15:29:27,435 - INFO - No message received within timeout +2025-04-10 15:29:27,493 - INFO - No message received within timeout +2025-04-10 15:29:27,537 - INFO - No message received within timeout +2025-04-10 15:29:32,435 - INFO - No message received within timeout +2025-04-10 15:29:32,436 - INFO - No message received within timeout +2025-04-10 15:29:32,494 - INFO - No message received within timeout +2025-04-10 15:29:32,539 - INFO - No message received within timeout +2025-04-10 15:29:37,436 - INFO - No message received within timeout +2025-04-10 15:29:37,437 - INFO - No message received within timeout +2025-04-10 15:29:37,495 - INFO - No message received within timeout +2025-04-10 15:29:37,540 - INFO - No message received within timeout +2025-04-10 15:29:42,437 - INFO - No message received within timeout +2025-04-10 15:29:42,438 - INFO - No message received within timeout +2025-04-10 15:29:42,496 - INFO - No message received within timeout +2025-04-10 15:29:42,542 - INFO - No message received within timeout +2025-04-10 15:29:47,438 - INFO - No message received within timeout +2025-04-10 15:29:47,439 - INFO - No message received within timeout +2025-04-10 15:29:47,497 - INFO - No message received within timeout +2025-04-10 15:29:47,543 - INFO - No message received within timeout +2025-04-10 15:29:52,439 - INFO - No message received within timeout +2025-04-10 15:29:52,440 - INFO - No message received within timeout +2025-04-10 15:29:52,498 - INFO - No message received within timeout +2025-04-10 15:29:52,544 - INFO - No message received within timeout +2025-04-10 15:29:57,440 - INFO - No message received within timeout +2025-04-10 15:29:57,441 - INFO - No message received within timeout +2025-04-10 15:29:57,499 - INFO - No message received within timeout +2025-04-10 15:29:57,545 - INFO - No message received within timeout +2025-04-10 15:30:02,441 - INFO - No message received within timeout +2025-04-10 15:30:02,442 - INFO - No message received within timeout +2025-04-10 15:30:02,500 - INFO - No message received within timeout +2025-04-10 15:30:02,546 - INFO - No message received within timeout +2025-04-10 15:30:07,442 - INFO - No message received within timeout +2025-04-10 15:30:07,443 - INFO - No message received within timeout +2025-04-10 15:30:07,501 - INFO - No message received within timeout +2025-04-10 15:30:07,547 - INFO - No message received within timeout +2025-04-10 15:30:12,443 - INFO - No message received within timeout +2025-04-10 15:30:12,444 - INFO - No message received within timeout +2025-04-10 15:30:12,502 - INFO - No message received within timeout +2025-04-10 15:30:12,548 - INFO - No message received within timeout +2025-04-10 15:30:17,444 - INFO - No message received within timeout +2025-04-10 15:30:17,445 - INFO - No message received within timeout +2025-04-10 15:30:17,503 - INFO - No message received within timeout +2025-04-10 15:30:17,549 - INFO - No message received within timeout +2025-04-10 15:30:22,445 - INFO - No message received within timeout +2025-04-10 15:30:22,446 - INFO - No message received within timeout +2025-04-10 15:30:22,504 - INFO - No message received within timeout +2025-04-10 15:30:22,550 - INFO - No message received within timeout +2025-04-10 15:30:27,446 - INFO - No message received within timeout +2025-04-10 15:30:27,447 - INFO - No message received within timeout +2025-04-10 15:30:27,505 - INFO - No message received within timeout +2025-04-10 15:30:27,551 - INFO - No message received within timeout +2025-04-10 15:30:32,447 - INFO - No message received within timeout +2025-04-10 15:30:32,448 - INFO - No message received within timeout +2025-04-10 15:30:32,510 - INFO - No message received within timeout +2025-04-10 15:30:32,552 - INFO - No message received within timeout +2025-04-10 15:30:37,448 - INFO - No message received within timeout +2025-04-10 15:30:37,449 - INFO - No message received within timeout +2025-04-10 15:30:37,511 - INFO - No message received within timeout +2025-04-10 15:30:37,553 - INFO - No message received within timeout +2025-04-10 15:30:42,449 - INFO - No message received within timeout +2025-04-10 15:30:42,450 - INFO - No message received within timeout +2025-04-10 15:30:42,512 - INFO - No message received within timeout +2025-04-10 15:30:42,554 - INFO - No message received within timeout +2025-04-10 15:30:47,450 - INFO - No message received within timeout +2025-04-10 15:30:47,451 - INFO - No message received within timeout +2025-04-10 15:30:47,513 - INFO - No message received within timeout +2025-04-10 15:30:47,555 - INFO - No message received within timeout +2025-04-10 15:30:52,451 - INFO - No message received within timeout +2025-04-10 15:30:52,452 - INFO - No message received within timeout +2025-04-10 15:30:52,514 - INFO - No message received within timeout +2025-04-10 15:30:52,556 - INFO - No message received within timeout +2025-04-10 15:30:57,452 - INFO - No message received within timeout +2025-04-10 15:30:57,455 - INFO - No message received within timeout +2025-04-10 15:30:57,515 - INFO - No message received within timeout +2025-04-10 15:30:57,557 - INFO - No message received within timeout +2025-04-10 15:31:02,453 - INFO - No message received within timeout +2025-04-10 15:31:02,456 - INFO - No message received within timeout +2025-04-10 15:31:02,516 - INFO - No message received within timeout +2025-04-10 15:31:02,558 - INFO - No message received within timeout +2025-04-10 15:31:07,455 - INFO - No message received within timeout +2025-04-10 15:31:07,456 - INFO - No message received within timeout +2025-04-10 15:31:07,518 - INFO - No message received within timeout +2025-04-10 15:31:07,560 - INFO - No message received within timeout +2025-04-10 15:31:12,455 - INFO - No message received within timeout +2025-04-10 15:31:12,457 - INFO - No message received within timeout +2025-04-10 15:31:12,519 - INFO - No message received within timeout +2025-04-10 15:31:12,561 - INFO - No message received within timeout +2025-04-10 15:31:17,457 - INFO - No message received within timeout +2025-04-10 15:31:17,459 - INFO - No message received within timeout +2025-04-10 15:31:17,519 - INFO - No message received within timeout +2025-04-10 15:31:17,562 - INFO - No message received within timeout diff --git a/app/config.py b/app/config.py index 74abe6d..41d7c51 100644 --- a/app/config.py +++ b/app/config.py @@ -5,7 +5,8 @@ class Config: """Base configuration for Flask app""" SECRET_KEY = os.getenv("SECRET_KEY", "supersecretkey") - API_BASE_URL = "https://coreapi.dev.simbrellang.net/v1/api/salary" + SIMBRELLA_AUTH_BASE_URL = "https://coreapi.dev.simbrellang.net/v1/api/auth" + SIMBRELLA_BASE_URL = "https://coreapi.dev.simbrellang.net/v1/api/salary" JWT_SECRET_KEY = os.getenv("JWT_SECRET_KEY", "your_jwt_secret") DEBUG = True diff --git a/app/integrations/kafka.py b/app/integrations/kafka.py index 257c71f..385937a 100644 --- a/app/integrations/kafka.py +++ b/app/integrations/kafka.py @@ -6,6 +6,9 @@ import requests class KafkaIntegration: + + BASE_URL = settings.SIMBRELLA_BASE_URL + _consumer = None _consumer_config = { @@ -83,9 +86,7 @@ class KafkaIntegration: logger.info("Kafka consumer closed") @staticmethod - def _call_disbursement_endpoint( - message, endpoint_url="http://localhost:8000/loans/disbursement" - ): + def _call_disbursement_endpoint(message, endpoint_url=f"{BASE_URL}/Disbursement"): """Call an HTTP endpoint with the received message""" try: response = requests.post(endpoint_url, json=message, timeout=5) diff --git a/app/routes/authentication.py b/app/routes/authentication.py index 793e25f..bba08a7 100644 --- a/app/routes/authentication.py +++ b/app/routes/authentication.py @@ -1,9 +1,13 @@ from flask import Blueprint, request, jsonify, current_app import requests from app.utils.auth import get_headers +from app.config import settings auth_bp = Blueprint("auth", __name__) +AUTH_BASE_URL = settings.SIMBRELLA_AUTH_BASE_URL +BASE_URL = settings.SIMBRELLA_BASE_URL + @auth_bp.route("/health", methods=["GET"]) def health(): @@ -13,7 +17,7 @@ def health(): @auth_bp.route("/login", methods=["POST"]) def login(): data = request.json - api_url = "https://coreapi.dev.simbrellang.net/api/auth/login" + api_url = f"{AUTH_BASE_URL}/login" response = requests.post(api_url, json=data) if response.status_code == 200: @@ -24,7 +28,7 @@ def login(): @auth_bp.route("/status-call", methods=["POST"]) def status_call(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/StatusCall" + api_url = f"{BASE_URL}/StatusCall" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -47,7 +51,7 @@ def status_call(): @auth_bp.route("/sms", methods=["POST"]) def sms(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/SMS" + api_url = f"{BASE_URL}/SMS" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -64,7 +68,7 @@ def sms(): @auth_bp.route("/bulk-sms", methods=["POST"]) def bulk_sms(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/BulkSMS" + api_url = f"{BASE_URL}/BulkSMS" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code diff --git a/app/routes/eligibility.py b/app/routes/eligibility.py index 45b4f95..bf91ce2 100644 --- a/app/routes/eligibility.py +++ b/app/routes/eligibility.py @@ -1,14 +1,17 @@ from flask import Blueprint, request, jsonify, current_app +from app.config import settings import requests from app.utils.auth import get_headers eligibility_bp = Blueprint("eligibility", __name__) +BASE_URL = settings.SIMBRELLA_BASE_URL + @eligibility_bp.route("/check", methods=["POST"]) def eligibility_check(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/EligibilityCheck" + api_url = f"{BASE_URL}/EligibilityCheck" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code diff --git a/app/routes/loan.py b/app/routes/loan.py index 5c80968..bcb3a3e 100644 --- a/app/routes/loan.py +++ b/app/routes/loan.py @@ -1,16 +1,17 @@ from flask import Blueprint, request, jsonify, current_app import requests +from app.config import settings from app.utils.auth import get_headers -from app.integrations import KafkaIntegration -from threading import Thread loan_bp = Blueprint("loan", __name__) +BASE_URL = settings.SIMBRELLA_BASE_URL + @loan_bp.route("/select-offer", methods=["POST"]) def select_offer(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/SelectOffer" + api_url = f"{BASE_URL}/SelectOffer" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -48,7 +49,7 @@ def select_offer(): @loan_bp.route("/provide-loan", methods=["POST"]) def provide_loan(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/ProvideLoan" + api_url = f"{BASE_URL}/ProvideLoan" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -68,7 +69,7 @@ def provide_loan(): @loan_bp.route("/status", methods=["POST"]) def status(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/LoanStatus" + api_url = f"{BASE_URL}/LoanStatus" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -98,7 +99,7 @@ def status(): @loan_bp.route("/repayment", methods=["POST"]) def repayment(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/Repayment" + api_url = f"{BASE_URL}/Repayment" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -124,7 +125,7 @@ def repayment(): @loan_bp.route("/rac-check", methods=["POST"]) def rac_check(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/RACCheck" + api_url = f"{BASE_URL}/RACCheck" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -154,7 +155,7 @@ def rac_check(): @loan_bp.route("/disbursement", methods=["POST"]) def disbursement(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/Disbursement" + api_url = f"{BASE_URL}/Disbursement" return jsonify({"requestId": data["requestId"]}), 200 @@ -165,7 +166,7 @@ def disbursement(): @loan_bp.route("/collect-loan", methods=["POST"]) def collect_loan(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/CollectLoan" + api_url = f"{BASE_URL}/CollectLoan" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -190,7 +191,7 @@ def collect_loan(): @loan_bp.route("/transaction-verify", methods=["POST"]) def transaction_verify(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/TransactionVerify" + api_url = f"{BASE_URL}/TransactionVerify" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -213,7 +214,7 @@ def transaction_verify(): @loan_bp.route("/penal-charge", methods=["POST"]) def penal_charge(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/PenalCharge" + api_url = f"{BASE_URL}/PenalCharge" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code @@ -228,7 +229,7 @@ def penal_charge(): @loan_bp.route("/lien-check", methods=["POST"]) def lien_check(): data = request.json - api_url = f"{current_app.config['API_BASE_URL']}/LienCheck" + api_url = f"{BASE_URL}/LienCheck" # response = requests.post(api_url, json=data, headers=get_headers()) # return jsonify(response.json()), response.status_code