[add]: Balance Check
This commit is contained in:
@@ -56,6 +56,22 @@ def rac_check():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception("Unhandled exception in /RACCheck route")
|
logger.exception("Unhandled exception in /RACCheck route")
|
||||||
return jsonify({"message": "Unhandled server error"}), 500
|
return jsonify({"message": "Unhandled server error"}), 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# RACCheck Endpoint
|
||||||
|
@api.route('/VerifyAccountBalance', methods=['POST'])
|
||||||
|
@jwt_required()
|
||||||
|
def verify_account_balance():
|
||||||
|
logger.info("VerifyAccountBalance request received")
|
||||||
|
try:
|
||||||
|
logger.info("VerifyAccountBalance inside try request received")
|
||||||
|
data = request.get_json()
|
||||||
|
response = VerifyAccountBalanceService.process_request(data)
|
||||||
|
return response
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception("Unhandled exception in /VerifyAccountBalance route")
|
||||||
|
return jsonify({"message": "Unhandled server error"}), 500
|
||||||
|
|
||||||
# CompleteRACcheck Endpoint
|
# CompleteRACcheck Endpoint
|
||||||
@api.route('/CompleteRACcheck', methods=['POST'])
|
@api.route('/CompleteRACcheck', methods=['POST'])
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
from marshmallow import Schema, fields
|
||||||
|
|
||||||
|
from marshmallow import Schema, fields
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
|
||||||
|
class VerifyAccountBalanceSchema(Schema):
|
||||||
|
accountId = fields.Str(required=True)
|
||||||
|
amount = fields.Str(required=True)
|
||||||
|
requestId = fields.Str(required=True)
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
from app.api.schemas.verify_account_balance import VerifyAccountBalanceSchema
|
||||||
|
from flask import request, jsonify
|
||||||
|
from marshmallow import ValidationError
|
||||||
|
from app.utils.logger import logger
|
||||||
|
from app.api.helpers.response_helper import ResponseHelper
|
||||||
|
from datetime import datetime
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
class VerifyAccountBalanceService:
|
||||||
|
@staticmethod
|
||||||
|
def process_request(data):
|
||||||
|
"""
|
||||||
|
Process the RACCheck request.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
data (dict): The request data.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: JSON response and status code.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
logger.info("Processing RACCheck request")
|
||||||
|
|
||||||
|
# Validate input data
|
||||||
|
schema = VerifyAccountBalanceSchema()
|
||||||
|
validated_data = schema.load(data)
|
||||||
|
|
||||||
|
account_id = validated_data["account_id"]
|
||||||
|
request_id = validated_data["request_id"]
|
||||||
|
amount = validated_data["amount"]
|
||||||
|
|
||||||
|
|
||||||
|
# response_schema = RACCheckResponseSchema()
|
||||||
|
result = {
|
||||||
|
"responseCode": "00",
|
||||||
|
"responseMessage": "Operation Successful",
|
||||||
|
"isSufficient": True
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonify(result), 200
|
||||||
|
|
||||||
|
except ValidationError as err:
|
||||||
|
logger.error(f"Validation Error: {err.messages}")
|
||||||
|
return jsonify({
|
||||||
|
"message": "Validation exception",
|
||||||
|
"errors": err.messages
|
||||||
|
}), 422
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||||
|
return jsonify({
|
||||||
|
"message": "Internal Server Error"
|
||||||
|
}), 500
|
||||||
Reference in New Issue
Block a user