Major update

This commit is contained in:
Azeez Muibi
2025-03-27 08:21:20 +01:00
parent 1a36416094
commit ba4d878daf
24 changed files with 776 additions and 254 deletions
+15 -12
View File
@@ -1,8 +1,7 @@
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.penal_charge import PenalChargeSchema
from app.api.schemas.penal_charge import PenalChargeSchema, PenalChargeResponseSchema
class PenalChargeService:
@@ -25,27 +24,31 @@ class PenalChargeService:
validated_data = schema.load(data) # Raises ValidationError if invalid
# Simulated processing logic
# In a real implementation, this would interact with your business logic
# to process the penal charge
# For demonstration, we'll simulate a successful penal charge
response_data = {
"resultCode": "00",
"resultDescription": "Penal charge debited successfully"
}
# Validate the response using the response schema
response_schema = PenalChargeResponseSchema()
validated_response = response_schema.dump(response_data)
# return ResponseHelper.success(
# data=response_data,
# message="Penal charge applied 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