added health check for bank
This commit was merged in pull request #48.
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from .kafka import KafkaIntegration
|
||||
from .simbrella import SimbrellaClient
|
||||
from .simbrella import SimbrellaClient
|
||||
from .bank_service import BankService
|
||||
@@ -0,0 +1,25 @@
|
||||
import requests
|
||||
from app.config import settings
|
||||
from app.utils.auth import get_headers
|
||||
from app.utils.logger import logger
|
||||
|
||||
|
||||
class BankService:
|
||||
BANK_CALL_BASE_URL = settings.BANK_CALL_BASE_URL
|
||||
BANK_HEALTH_CHECK_ENDPOINT = settings.BANK_HEALTH_CHECK_ENDPOINT
|
||||
BANK_CALL_APP_ID = settings.BANK_CALL_APP_ID
|
||||
|
||||
@staticmethod
|
||||
def health_check():
|
||||
api_url = f"{BankService.BANK_CALL_BASE_URL}{BankService.BANK_HEALTH_CHECK_ENDPOINT}"
|
||||
logger.info(f"Calling Health Check endpoint: {api_url}")
|
||||
|
||||
try:
|
||||
response = requests.get(api_url, timeout=5, headers=get_headers())
|
||||
logger.info(f"Health Check response status code: {response.status_code}")
|
||||
|
||||
return response.json()
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Health Check API call failed: {str(e)}", exc_info=True)
|
||||
raise
|
||||
@@ -32,6 +32,7 @@ class SimbrellaClient:
|
||||
BANK_CALL_DISBURSE_LOAN_ENDPOINT = settings.BANK_CALL_DISBURSE_LOAN_ENDPOINT
|
||||
BANK_CALL_COLLECT_LOAN_ENDPOINT = settings.BANK_CALL_COLLECT_LOAN_ENDPOINT
|
||||
BANK_CALL_TRANSACTION_VERIFY = settings.BANK_CALL_TRANSACTION_VERIFY
|
||||
BANK_HEALTH_CHECK_ENDPOINT = settings.BANK_HEALTH_CHECK_ENDPOINT
|
||||
|
||||
@staticmethod
|
||||
def disburse_loan(data):
|
||||
@@ -399,4 +400,6 @@ class SimbrellaClient:
|
||||
|
||||
except Exception as e:
|
||||
logger.info(f"Failed to call Penal Charge endpoint: {e}")
|
||||
raise
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user