worked on disbursement endpoint and added more things to log #7
@@ -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
@@ -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
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user