progress on disbursement endpoint

This commit is contained in:
lennyaiko
2025-04-10 21:50:25 +01:00
parent f408da5a75
commit 6b272eb107
3 changed files with 24 additions and 16 deletions
+7 -8
View File
@@ -3,6 +3,7 @@ import json
from app.utils.logger import logger
from app.config import settings
import requests
from app.routes.loan import disbursement as disbursement_endpoint
class KafkaIntegration:
@@ -86,15 +87,13 @@ class KafkaIntegration:
logger.info("Kafka consumer closed")
@staticmethod
def _call_disbursement_endpoint(message, endpoint_url=f"{BASE_URL}/Disbursement"):
"""Call an HTTP endpoint with the received message"""
def _call_disbursement_endpoint(message):
"""Call the disbursement endpoint with the received message"""
try:
response = requests.post(endpoint_url, json=message, timeout=5)
response.raise_for_status()
response = disbursement_endpoint(message)
logger.info(
f"Successfully sent message to {endpoint_url}: {response.status_code}"
f"Successfully sent message to disbursement endpoint: {response.status_code}"
)
print(response.json())
except requests.exceptions.RequestException as e:
logger.error(f"Failed to call endpoint {endpoint_url}: {e}")
except Exception as e:
logger.error(f"Failed to call disbursement endpoint: {e}")
raise