worked oon disbursement endpoint and added more things to log

This commit was merged in pull request #7.
This commit is contained in:
lennyaiko
2025-04-10 22:07:06 +01:00
parent 6b272eb107
commit c242e53eaa
4 changed files with 16 additions and 6 deletions
+6
View File
@@ -53,6 +53,10 @@ class KafkaIntegration:
consumer = KafkaIntegration._get_consumer()
consumer.subscribe([topic])
logger.info(
f"Waiting for messages from topic {topic} with this timeout: {timeout}..."
)
try:
msg = consumer.poll(timeout=timeout)
if msg is None:
@@ -89,6 +93,8 @@ class KafkaIntegration:
@staticmethod
def _call_disbursement_endpoint(message):
"""Call the disbursement endpoint with the received message"""
logger.info(f"Calling disbursement endpoint with message: {message}")
try:
response = disbursement_endpoint(message)
logger.info(
+6 -4
View File
@@ -2,6 +2,7 @@ from flask import Blueprint, request, jsonify, current_app
import requests
from app.config import settings
from app.utils.auth import get_headers
from app.utils.logger import logger
loan_bp = Blueprint("loan", __name__)
@@ -159,15 +160,16 @@ def disbursement(data=None):
api_url = f"{BASE_URL}/Disbursement"
logger.info(f"Calling disbursement endpoint with data: {data}")
response = requests.post(
api_url,
json=data,
headers=get_headers(),
auth=(
settings.BANK_CALL_BASIC_AUTH_USERNAME,
settings.BANK_CALL_BASIC_AUTH_PASSWORD,
),
)
logger.info(f"Disbursement response: {response.json()}")
return jsonify(response.json()), response.status_code
+3 -2
View File
@@ -1,9 +1,10 @@
import requests
from flask import current_app
from app.config import settings
def get_headers():
return {
"Content-Type": "application/json",
"Accept": "application/json",
"api_key": settings.BANK_CALL_API_KEY,
"app_id": settings.BANK_CALL_APP_ID,
}
+1
View File
@@ -9,6 +9,7 @@ if __name__ != "__main__":
kafka = KafkaIntegration()
logger.info("Starting Kafka consumer...")
while True:
message = kafka.receive_disbursement_messages(
topic=settings.KAFKA_PAYMENT_TOPIC, timeout=settings.KAFKA_TIMEOUT