55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
from flask import request, jsonify
|
|
from marshmallow import ValidationError
|
|
from app.utils.logger import logger
|
|
from app.api.schemas.lien_check import LienCheckSchema, LienCheckResponseSchema
|
|
|
|
|
|
class LienCheckService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the LienCheck request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
dict: A standardized response.
|
|
"""
|
|
try:
|
|
logger.info("Processing LienCheck request")
|
|
|
|
# Validate input data using LienCheckSchema
|
|
schema = LienCheckSchema()
|
|
validated_data = schema.load(data) # Raises ValidationError if invalid
|
|
|
|
# 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 jsonify(validated_response)
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return jsonify({
|
|
"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({
|
|
"resultCode": "08",
|
|
"resultDescription": f"Error occurred: {str(e)}"
|
|
}), 500 |