[fix]: swagger and health check response

This commit was merged in pull request #67.
This commit is contained in:
VivianDee
2025-10-27 19:42:23 +01:00
parent 6221447353
commit d99640345a
3 changed files with 23 additions and 19 deletions
+18 -14
View File
@@ -1,3 +1,4 @@
from os import access
import httpx
import time
from app.utils.logger import logger
@@ -29,7 +30,7 @@ class SimbrellaIntegration:
headers = {"Content-Type": "application/json"}
try:
logger.info(f"Requesting token from {url}")
logger.info(f"Requesting Bank token from {url}")
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
response.raise_for_status()
@@ -41,9 +42,9 @@ class SimbrellaIntegration:
SimbrellaIntegration._token_expiry = time.time() + expires_in - 60
if not SimbrellaIntegration._access_token:
raise Exception("Access token not found in response")
raise Exception("Access token not found in Bank Authorization response")
logger.info("Successfully retrieved access token")
logger.info("Successfully retrieved Bank access token")
return SimbrellaIntegration._access_token
except Exception as e:
@@ -76,12 +77,14 @@ class SimbrellaIntegration:
"channel": "USSD"
}
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {SimbrellaIntegration._get_token()}"
}
try:
access_token = SimbrellaIntegration._get_token()
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {access_token}"
}
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
logger.info(f"This is Response: {str(response)}", exc_info=True)
@@ -95,22 +98,23 @@ class SimbrellaIntegration:
@staticmethod
def health_check():
"""
Health check for Simbrella Service
Health check for Bank Service
"""
url = f"{SimbrellaIntegration.BASE_URL}/{SimbrellaIntegration.HEALTH_ENDPOINT}"
logger.info(f"Simbrella Health Check URL: {url}")
logger.info(f"Bank Health Check URL: {url}")
try:
access_token = SimbrellaIntegration._get_token()
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {SimbrellaIntegration._get_token()}"
"Authorization": f"Bearer {access_token}"
}
response = httpx.get(url, headers=headers, timeout=10.0)
logger.info(f"Simbrella Health Check Response: {response.text}")
logger.info(f"Bank Health Check Response: {response.text}")
return response
except Exception as e:
logger.error(f"Simbrella Health Check API call failed: {str(e)}", exc_info=True)
raise Exception(f"Simbrella Health Check API call failed: {str(e)}")
logger.error(f"Bank Health Check API call failed: {str(e)}", exc_info=True)
raise Exception(f"Bank Health Check API call failed: {str(e)}")