Major update
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.utils.logger import logger
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.lien_check import LienCheckSchema
|
||||
from flask import request, jsonify
|
||||
from app.api.schemas.lien_check import LienCheckSchema, LienCheckResponseSchema
|
||||
|
||||
|
||||
class LienCheckService:
|
||||
@staticmethod
|
||||
@@ -23,29 +23,33 @@ class LienCheckService:
|
||||
schema = LienCheckSchema()
|
||||
validated_data = schema.load(data) # Raises ValidationError if invalid
|
||||
|
||||
# Simulated lien check logic
|
||||
# Simulated processing logic
|
||||
# In a real implementation, this would interact with your business logic
|
||||
# to check the lien amount on the account
|
||||
|
||||
# For demonstration, we'll simulate a lien amount of 20000.0
|
||||
response_data = {
|
||||
"lienAmount": 20000.0,
|
||||
"resultCode": "00",
|
||||
"resultDescription": "Successful"
|
||||
}
|
||||
|
||||
# Validate the response using the response schema
|
||||
response_schema = LienCheckResponseSchema()
|
||||
validated_response = response_schema.dump(response_data)
|
||||
|
||||
# return ResponseHelper.success(
|
||||
# data=response_data,
|
||||
# message="Lien check completed successfully"
|
||||
# )
|
||||
|
||||
return response_data
|
||||
return jsonify(validated_response)
|
||||
|
||||
except ValidationError as err:
|
||||
logger.error(f"Validation Error: {err.messages}")
|
||||
return jsonify({
|
||||
"message": "Validation exception"
|
||||
}) , 422
|
||||
"resultCode": "01",
|
||||
"resultDescription": f"Validation error: {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
|
||||
"resultCode": "08",
|
||||
"resultDescription": f"Error occurred: {str(e)}"
|
||||
}), 500
|
||||
Reference in New Issue
Block a user