Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fd7854729a | |||
| d99640345a | |||
| 6221447353 | |||
| 54e52c639b | |||
| bb85c8f166 | |||
| 6077c78840 | |||
| 9cbc824661 | |||
| 2e08c636a2 | |||
| ad043ba3f8 | |||
| 63da7e8292 | |||
| b73bf9a234 | |||
| e8abb3c668 | |||
| 396516b941 | |||
| c59068d3bb | |||
| ccd5b12f2c | |||
| 9913f6500c | |||
| 17c760981a | |||
| 68aca1407c | |||
| 550895b8ef | |||
| b7e3527f35 | |||
| 1bab78ec1a | |||
| 55140efed8 | |||
| 0faf01bcfa |
+14
-11
@@ -22,19 +22,17 @@ def create_app():
|
||||
# import oracledb
|
||||
|
||||
# oracledb.init_oracle_client(lib_dir=None)
|
||||
app = Flask(__name__)
|
||||
|
||||
# Load configuration
|
||||
app.config.from_object(Config)
|
||||
|
||||
CORS(app)
|
||||
JWTManager(app)
|
||||
CORS(app, supports_credentials=True)
|
||||
|
||||
|
||||
try:
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# Load configuration
|
||||
app.config.from_object(Config)
|
||||
|
||||
CORS(app)
|
||||
|
||||
JWTManager(app)
|
||||
CORS(app, supports_credentials=True)
|
||||
|
||||
# Swagger Doc
|
||||
SWAGGER_URL = app.config.get("SWAGGER_URL")
|
||||
API_URL = app.config.get("API_URL")
|
||||
@@ -45,6 +43,11 @@ def create_app():
|
||||
swagger_ui_blueprint = get_swaggerui_blueprint(SWAGGER_URL, API_URL)
|
||||
app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Swagger Unexpected error occurred: {e}")
|
||||
|
||||
|
||||
try:
|
||||
# Error Handlers
|
||||
register_error_handlers(app)
|
||||
|
||||
|
||||
@@ -1,13 +1,64 @@
|
||||
from os import access
|
||||
import httpx
|
||||
import json
|
||||
import time
|
||||
from app.utils.logger import logger
|
||||
from app.config import settings
|
||||
import logging
|
||||
|
||||
|
||||
class SimbrellaIntegration:
|
||||
BASE_URL = settings.SIMBRELLA_BASE_URL
|
||||
ENDPOINT_RAC_CHECKS = settings.SIMBRELLA_ENDPOINT_RAC_CHECKS
|
||||
HEALTH_ENDPOINT = settings.SIMBRELLA_HEALTH
|
||||
AUTH_ENDPOINT = settings.BANK_CALL_AUTH_ENDPOINT
|
||||
|
||||
_access_token = None # cache token in memory
|
||||
_token_expiry = 0
|
||||
|
||||
@staticmethod
|
||||
def generate_token():
|
||||
"""
|
||||
Generate a new access token using the username and password from settings.
|
||||
"""
|
||||
url = f"{SimbrellaIntegration.BASE_URL}{SimbrellaIntegration.AUTH_ENDPOINT}"
|
||||
|
||||
payload = {
|
||||
"username": settings.BANK_CALL_USERNAME,
|
||||
"password": settings.BANK_CALL_PASSWORD,
|
||||
"grant_type": "password"
|
||||
}
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
try:
|
||||
logger.info(f"Requesting Bank token from {url}")
|
||||
|
||||
response = httpx.post(url, json=payload, headers=headers, timeout=10.0)
|
||||
response.raise_for_status()
|
||||
|
||||
data = response.json()
|
||||
expires_in = data.get("expires_in", 1800)
|
||||
|
||||
SimbrellaIntegration._access_token = data.get("access_token")
|
||||
SimbrellaIntegration._token_expiry = time.time() + expires_in - 60
|
||||
|
||||
if not SimbrellaIntegration._access_token:
|
||||
raise Exception("Access token not found in Bank Authorization response")
|
||||
|
||||
logger.info("Successfully retrieved Bank access token")
|
||||
return SimbrellaIntegration._access_token
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Token generation failed: {str(e)}", exc_info=True)
|
||||
raise Exception(f"Token generation failed: {str(e)}")
|
||||
|
||||
@staticmethod
|
||||
def _get_token():
|
||||
"""
|
||||
Return a valid token, refreshing if expired or missing
|
||||
"""
|
||||
if not SimbrellaIntegration._access_token or time.time() >= SimbrellaIntegration._token_expiry:
|
||||
return SimbrellaIntegration.generate_token()
|
||||
return SimbrellaIntegration._access_token
|
||||
|
||||
@staticmethod
|
||||
def rac_check(customer_id, account_id, transaction_id):
|
||||
@@ -26,13 +77,14 @@ class SimbrellaIntegration:
|
||||
"channel": "USSD"
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": f"{settings.VALID_API_KEY}",
|
||||
"App-Id": f"{settings.VALID_APP_ID}",
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -42,4 +94,27 @@ class SimbrellaIntegration:
|
||||
except Exception as e:
|
||||
logger.error(f"RACCheck API call failed: {str(e)}", exc_info=True)
|
||||
raise Exception(f"RACCheck API call failed: {str(e)}")
|
||||
|
||||
@staticmethod
|
||||
def health_check():
|
||||
"""
|
||||
Health check for Bank Service
|
||||
"""
|
||||
|
||||
url = f"{SimbrellaIntegration.BASE_URL}/{SimbrellaIntegration.HEALTH_ENDPOINT}"
|
||||
logger.info(f"Bank Health Check URL: {url}")
|
||||
|
||||
try:
|
||||
access_token = SimbrellaIntegration._get_token()
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {access_token}"
|
||||
}
|
||||
|
||||
response = httpx.get(url, headers=headers, timeout=10.0)
|
||||
logger.info(f"Bank Health Check Response: {response.text}")
|
||||
return response
|
||||
except Exception as 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)}")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from sqlite3 import DatabaseError
|
||||
from app.api.integrations.events_service import EventServiceIntegration
|
||||
from app.api.integrations.simbrella import SimbrellaIntegration
|
||||
from flask import Blueprint, request, jsonify, send_from_directory
|
||||
from app.api.services import (
|
||||
EligibilityCheckService,
|
||||
@@ -125,6 +125,7 @@ def health_check():
|
||||
response = {}
|
||||
db_status = "Connection Successful"
|
||||
events_service_status = "Connection Successful"
|
||||
bank_status = "Connection Successful"
|
||||
errors = []
|
||||
status = "ok"
|
||||
|
||||
@@ -140,7 +141,7 @@ def health_check():
|
||||
# Check database connection
|
||||
try:
|
||||
logger.info(f"Database Health == : {SQLALCHEMY_DATABASE_URI}")
|
||||
db.session.execute(text("SELECT 1"))
|
||||
db.session.execute(text("SELECT table_name FROM user_tables ORDER BY table_name"))
|
||||
except Exception as e:
|
||||
db_status = "Connection Failed"
|
||||
errors.append(f"Database Error: {str(e)}")
|
||||
@@ -158,15 +159,30 @@ def health_check():
|
||||
|
||||
|
||||
except Exception as e:
|
||||
events_service_status = "Connection Successful"
|
||||
events_service_status = "Connection Failed"
|
||||
status = "failed"
|
||||
errors.append(f"Events Service connection failed: {str(e)}")
|
||||
|
||||
# Check Bank health
|
||||
try:
|
||||
emulator_response = SimbrellaIntegration.health_check()
|
||||
|
||||
if emulator_response.status_code != 200:
|
||||
bank_status = "Connection Failed"
|
||||
status = "failed"
|
||||
errors.append(f"Bank Connection response: {emulator_response.text}")
|
||||
|
||||
except Exception as e:
|
||||
bank_status = "Connection Failed"
|
||||
status = "failed"
|
||||
errors.append(f"Connection to Bank failed: {str(e)}")
|
||||
|
||||
|
||||
response = {
|
||||
"status": status,
|
||||
"db_status": db_status,
|
||||
"events_service_status": events_service_status,
|
||||
"bank_status": bank_status,
|
||||
"db_uri": db_uri,
|
||||
"errors": errors or None
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ from marshmallow import ValidationError
|
||||
from app.api.enums.loan_status import LoanStatus
|
||||
from app.models import Customer
|
||||
from app.utils.logger import logger
|
||||
from app.api.schemas.loan_status import LoanStatusSchema
|
||||
from app.api.schemas.loan_status import LoanStatusSchema
|
||||
from app.api.services.base_service import BaseService
|
||||
from app.api.enums import TransactionType
|
||||
from app.api.enums import TransactionType
|
||||
from app.extensions import db
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
|
||||
|
||||
class LoanStatusService(BaseService):
|
||||
TRANSACTION_TYPE = TransactionType.LOAN_STATUS
|
||||
TRANSACTION_TYPE = TransactionType.LOAN_STATUS
|
||||
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
@@ -27,31 +27,57 @@ class LoanStatusService(BaseService):
|
||||
try:
|
||||
with db.session.begin():
|
||||
# Validate data
|
||||
validated_data = LoanStatusService.validate_data(data, LoanStatusSchema())
|
||||
validated_data = LoanStatusService.validate_data(
|
||||
data, LoanStatusSchema()
|
||||
)
|
||||
|
||||
customer_id = validated_data.get('customerId')
|
||||
customer_id = validated_data.get("customerId")
|
||||
|
||||
logger.info(f"Looking for customer *** {customer_id}")
|
||||
customer = Customer.get_customer_with_loan_list(customer_id)
|
||||
|
||||
transactionId = validated_data.get('transactionId')
|
||||
account_id = validated_data.get('accountId')
|
||||
|
||||
if(LoanStatusService.validate_account_ownership(account_id = account_id, customer_id = customer_id)):
|
||||
transactionId = validated_data.get("transactionId")
|
||||
account_id = validated_data.get("accountId")
|
||||
|
||||
if LoanStatusService.validate_account_ownership(
|
||||
account_id=account_id, customer_id=customer_id
|
||||
):
|
||||
# Get loans
|
||||
loans = [loan.to_dict() for loan in customer.loans if loan.status == LoanStatus.ACTIVE]
|
||||
transaction = LoanStatusService.log_transaction(validated_data = validated_data)
|
||||
customer_loans = customer.loans
|
||||
loans = [
|
||||
loan.to_dict()
|
||||
for loan in customer_loans
|
||||
if loan.status in [LoanStatus.ACTIVE, LoanStatus.START_REPAY, LoanStatus.ACTIVE_PARTIAL]
|
||||
]
|
||||
|
||||
transaction = LoanStatusService.log_transaction(
|
||||
validated_data=validated_data
|
||||
)
|
||||
if not transaction:
|
||||
logger.error(f"Failed to log transaction")
|
||||
return ResponseHelper.error(result_description="Failed to log transaction.")
|
||||
else:
|
||||
return ResponseHelper.error(result_description="Invalid Customer or Account")
|
||||
|
||||
total_debt_amount = sum(
|
||||
loan.get("currentLoanAmount") or 0
|
||||
for loan in loans
|
||||
return ResponseHelper.error(
|
||||
result_description="Failed to log transaction."
|
||||
)
|
||||
else:
|
||||
return ResponseHelper.error(
|
||||
result_description="Invalid Customer or Account"
|
||||
)
|
||||
|
||||
# CONFIRM IF THE TOTAL DEBT IF FOR ONLY ACTIVE LOANS OR ALL LOANS
|
||||
total_debt_amount = sum(
|
||||
loan.get("currentLoanAmount") or 0 for loan in loans
|
||||
)
|
||||
|
||||
total_outstanding_amount = sum(
|
||||
loan.get("currentLoanAmount") or 0 for loan in loans
|
||||
)
|
||||
|
||||
total_active_loan_amount = sum(
|
||||
loan.get("repaymentAmount") or 0 for loan in loans
|
||||
)
|
||||
|
||||
total_settled_amount = total_active_loan_amount - total_outstanding_amount
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"customerId": customer_id,
|
||||
@@ -59,6 +85,11 @@ class LoanStatusService(BaseService):
|
||||
"transactionId": transactionId,
|
||||
"loans": loans,
|
||||
"totalDebtAmount": total_debt_amount,
|
||||
"summary": {
|
||||
"totalSettledAmount": total_settled_amount,
|
||||
"totalOutstandingAmount": total_outstanding_amount,
|
||||
"totalActiveLoanAmount": total_active_loan_amount,
|
||||
}
|
||||
}
|
||||
|
||||
db.session.commit()
|
||||
@@ -68,9 +99,11 @@ class LoanStatusService(BaseService):
|
||||
|
||||
logger.error(f"Validation Error: {getattr(err, 'messages', str(err))}")
|
||||
db.session.rollback()
|
||||
return ResponseHelper.unprocessable_entity(result_description="Validation exception")
|
||||
|
||||
except ValueError as err:
|
||||
return ResponseHelper.unprocessable_entity(
|
||||
result_description="Validation exception"
|
||||
)
|
||||
|
||||
except ValueError as err:
|
||||
logger.error(f"{getattr(err, 'messages', str(err))}")
|
||||
db.session.rollback()
|
||||
return ResponseHelper.error(result_description=str(err))
|
||||
@@ -78,4 +111,4 @@ class LoanStatusService(BaseService):
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||
db.session.rollback()
|
||||
return ResponseHelper.internal_server_error()
|
||||
return ResponseHelper.internal_server_error()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from gettext import install
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.api.integrations.kafka import KafkaIntegration
|
||||
@@ -11,13 +12,12 @@ from threading import Thread
|
||||
from app.models import Loan, Offer, Charge , TransactionOffer, RACCheck
|
||||
from app.api.enums import LoanStatus
|
||||
from app.extensions import db
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from app.api.integrations import EventServiceIntegration
|
||||
from app.models import LoanRepaymentSchedule
|
||||
from app.api.services.offer_analysis import OfferAnalysis
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
||||
class ProvideLoanService(BaseService):
|
||||
TRANSACTION_TYPE = TransactionType.PROVIDE_LOAN
|
||||
@@ -144,10 +144,10 @@ class ProvideLoanService(BaseService):
|
||||
|
||||
db.session.flush()
|
||||
current_product_id = offer.product_id
|
||||
schedule = LoanRepaymentSchedule.add_repayment_schedule(loan = loan, num_schedules = num_schedules, transaction_id = transaction_id)
|
||||
schedules = LoanRepaymentSchedule.add_repayment_schedule(loan = loan, num_schedules = num_schedules, transaction_id = transaction_id)
|
||||
|
||||
|
||||
if not schedule:
|
||||
if not schedules:
|
||||
logger.error(f"Failed to create repayment schedule for loan ID {loan.id}")
|
||||
return ResponseHelper.error(result_description="Failed to generate loan repayment schedule.")
|
||||
|
||||
@@ -168,7 +168,8 @@ class ProvideLoanService(BaseService):
|
||||
loan_charges=loan_charges,
|
||||
offer=offer,
|
||||
loan_ref=loan_ref,
|
||||
amount=amount
|
||||
amount=amount,
|
||||
schedules=schedules
|
||||
)
|
||||
|
||||
response_data = {
|
||||
@@ -215,33 +216,74 @@ class ProvideLoanService(BaseService):
|
||||
return response
|
||||
|
||||
@classmethod
|
||||
def get_charge_schedule_items(cls, loan_charges, offer, loan_ref, amount):
|
||||
def get_charge_schedule_items(cls, loan_charges, offer, loan_ref, amount, schedules):
|
||||
now = datetime.now(timezone.utc)
|
||||
due_date = now + timedelta(days=offer.tenor)
|
||||
id_counter = 1
|
||||
|
||||
charge_schedule_items = []
|
||||
|
||||
charge_schedule_items.append({
|
||||
"id": 1,
|
||||
"id": id_counter,
|
||||
"dueDate": due_date.isoformat(),
|
||||
"amountDue": amount,
|
||||
"componentName": "PRINCIPAL",
|
||||
"startDate": now.isoformat(),
|
||||
})
|
||||
|
||||
for idx, charge in enumerate(loan_charges, start=len(charge_schedule_items) + 1):
|
||||
|
||||
interest_amount = 0.0
|
||||
|
||||
for charge in loan_charges:
|
||||
|
||||
code = charge.code.upper()
|
||||
|
||||
if code == "INTEREST":
|
||||
interest_amount = float(charge.amount)
|
||||
continue
|
||||
|
||||
|
||||
item = {
|
||||
"id": idx,
|
||||
"id": id_counter,
|
||||
"dueDate": charge.due_date.isoformat(),
|
||||
"amountDue": float(charge.amount),
|
||||
"componentName": charge.code.upper(), # e.g. INTEREST, MGMT_FEE, VAT_FEE
|
||||
"startDate": charge.created_at.isoformat(),
|
||||
}
|
||||
|
||||
if charge.code.upper() == "INTEREST":
|
||||
item["loanRef"] = loan_ref
|
||||
|
||||
charge_schedule_items.append(item)
|
||||
id_counter += 1
|
||||
|
||||
|
||||
num_schedules = len(schedules)
|
||||
if num_schedules > 0:
|
||||
principal_per_schedule = amount / num_schedules
|
||||
else:
|
||||
principal_per_schedule = 0.0
|
||||
|
||||
|
||||
for schedule in schedules:
|
||||
default = {
|
||||
"id": id_counter,
|
||||
"installmentNo": schedule.installment_number,
|
||||
"dueDate": schedule.due_date.isoformat(),
|
||||
"amountDue": round(principal_per_schedule, 2),
|
||||
"componentName": "DEFAULT",
|
||||
"startDate": schedule.created_at.isoformat(),
|
||||
}
|
||||
|
||||
charge_schedule_items.append(default)
|
||||
id_counter += 1
|
||||
|
||||
interest = {
|
||||
"id": id_counter,
|
||||
"dueDate": schedule.due_date.isoformat(),
|
||||
"amountDue": round(interest_amount, 2),
|
||||
"componentName": "INTEREST",
|
||||
"startDate": schedule.created_at.isoformat()
|
||||
}
|
||||
|
||||
charge_schedule_items.append(interest)
|
||||
id_counter += 1
|
||||
|
||||
return charge_schedule_items
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ class SelectOfferService(BaseService):
|
||||
transaction_id = validated_data.get("transactionId")
|
||||
request_id = validated_data.get("requestId")
|
||||
|
||||
|
||||
offer_id = int(transaction_offer_id[5:]) # The last part is int
|
||||
|
||||
#"offerId": "SAL30001129",
|
||||
|
||||
@@ -46,6 +46,13 @@ class Config:
|
||||
VALID_API_KEY = os.getenv("SIMBRELLA_API_KEY", "test-api-key-12345")
|
||||
SIMBRELLA_BASE_URL = os.getenv("SIMBRELLA_BASE_URL", "http://127.0.0.1:6337")
|
||||
SIMBRELLA_ENDPOINT_RAC_CHECKS = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS","api/rac-check")
|
||||
SIMBRELLA_HEALTH = os.getenv("SIMBRELLA_ENDPOINT_RAC_CHECKS","api/system-health-check")
|
||||
BANK_CALL_AUTH_ENDPOINT = os.getenv("BANK_CALL_AUTH_ENDPOINT", "/api/Auth/generate-token")
|
||||
BANK_CALL_USERNAME = os.getenv("BANK_CALL_USERNAME", "simbrella")
|
||||
BANK_CALL_PASSWORD = os.getenv("BANK_CALL_PASSWORD", "G7$k9@pL2!qR")
|
||||
|
||||
|
||||
|
||||
EVENTS_SERVICE_BASE_URL = os.getenv("EVENTS_SERVICE_BASE_URL","https://event-core.simbrellang.net")
|
||||
ENDPOINT_DIRECT_LOAN = os.getenv("ENDPOINT_DIRECT_LOAN","/autocall/direct/loan")
|
||||
ENDPOINT_DIRECT_REPAYMENT = os.getenv("ENDPOINT_DIRECT_REPAYMENT","/autocall/direct/repayment")
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ class Loan(db.Model):
|
||||
'loanRef': self.reference,
|
||||
'productId': self.product_id,
|
||||
'initialLoanAmount': self.initial_loan_amount,
|
||||
'currentLoanAmount': self.current_loan_amount,
|
||||
'currentLoanAmount': self.balance,
|
||||
'defaultPenaltyFee': self.default_penalty_fee,
|
||||
'continuousFee': self.continuous_fee,
|
||||
'collectionType': self.collection_type,
|
||||
|
||||
@@ -56,6 +56,12 @@ class Repayment(db.Model):
|
||||
raise ValueError(f"Database integrity error: {err}")
|
||||
|
||||
return repayment
|
||||
|
||||
# Get loan repayments
|
||||
@classmethod
|
||||
def get_repayments_by_id(cls, loan_id):
|
||||
return cls.query.filter_by(loan_id=loan_id).all()
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "Swagger Bank Channel to Simbrella FirstAdvance - OpenAPI 3.0",
|
||||
"title": "Swagger Simbrella Core [10/22/2025] - OpenAPI 3.0",
|
||||
"description": "This is a Simbrella FirstAdvance Backend Server with the OpenAPI 3.0 specification. \n\n\nSome useful links:\n- [Web Simulated Demo Page](https://digifi-salaryloan.chiefsoft.net/)\n- [Web Management Support Portal](https://digifi-office.chiefsoft.net/auth/login)",
|
||||
"termsOfService": "http://swagger.io/terms/",
|
||||
"contact": {
|
||||
@@ -28,6 +28,10 @@
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"name": "Health",
|
||||
"description": "System health check including DB status."
|
||||
},
|
||||
{
|
||||
"name": "Authorize",
|
||||
"description": "This feature will be used for authorizing customers.",
|
||||
@@ -83,13 +87,48 @@
|
||||
"description": "Find out more",
|
||||
"url": "https://www.simbrellang.net"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Health",
|
||||
"description": "System health check including DB status."
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/health": {
|
||||
"get": {
|
||||
"tags": ["Health"],
|
||||
"summary": "Health Check",
|
||||
"description": "Returns service health information including DB connection status.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Health check successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"status": "ok",
|
||||
"db_status": "Connection Successful",
|
||||
"events_service_status":"Connection Successful",
|
||||
"bank_status":"Connection Successful",
|
||||
"db_uri": "postgresql://user:****@localhost:5432/digifi_db",
|
||||
"error": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Health check failed",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"status": "failed",
|
||||
"db_status": "Connection Failed",
|
||||
"events_service_status":"Connection Failed",
|
||||
"bank_status":"Connection Failed",
|
||||
"db_uri": "Unavailable",
|
||||
"error":["could not connect to server: Connection refused"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/Authorize": {
|
||||
"$ref": "swagger/paths/Authorize.json"
|
||||
},
|
||||
@@ -110,41 +149,6 @@
|
||||
},
|
||||
"/Repayment": {
|
||||
"$ref": "swagger/paths/Repayment.json"
|
||||
},
|
||||
"/health": {
|
||||
"get": {
|
||||
"tags": ["Health"],
|
||||
"summary": "Health Check",
|
||||
"description": "Returns service health information including DB connection status.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Health check successful",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"status": "ok",
|
||||
"db_status": "Connection Successful",
|
||||
"events_service_status": "healthy",
|
||||
"error": []
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Health check failed",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"status": "ok",
|
||||
"db_status": "Connection Failed",
|
||||
"events_service_status": "unhealthy",
|
||||
"error":["could not connect to server: Connection refused"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
|
||||
@@ -102,6 +102,29 @@
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"example": 30000.0
|
||||
},
|
||||
"summary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"totalOutstandingAmount": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"example": 114450.0,
|
||||
"description": "Total amount still owed across all unpaid loans."
|
||||
},
|
||||
"totalActiveLoanAmount": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"example": 40000.0,
|
||||
"description": "Total principal amount of currently active loans."
|
||||
},
|
||||
"totalSettledAmount": {
|
||||
"type": "number",
|
||||
"format": "float",
|
||||
"example": 80000.0,
|
||||
"description": "Total amount that has been fully repaid."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"xml": {
|
||||
|
||||
+12
-1
@@ -1,3 +1,4 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
digifi-bank-to-product-core:
|
||||
build: .
|
||||
@@ -11,4 +12,14 @@ services:
|
||||
- DATABASE_URL=postgresql+psycopg2://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}
|
||||
volumes:
|
||||
- .:/app
|
||||
restart: always
|
||||
restart: always
|
||||
networks:
|
||||
- my_custom_network
|
||||
|
||||
|
||||
networks:
|
||||
my_custom_network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 10.244.0.0/26
|
||||
|
||||
Reference in New Issue
Block a user