55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from flask import request, jsonify
|
|
from marshmallow import ValidationError
|
|
from app.utils.logger import logger
|
|
from app.helpers.response_helper import ResponseHelper
|
|
from app.schemas.token_validation import TokenValidationSchema
|
|
|
|
|
|
class TokenValidationService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the TokenValidation request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
dict: A standardized response.
|
|
"""
|
|
try:
|
|
logger.info("Processing TokenValidation request")
|
|
|
|
# Validate input data using TokenValidationSchema
|
|
schema = TokenValidationSchema()
|
|
validated_data = schema.load(data) # Raises ValidationError if invalid
|
|
|
|
# Simulated token validation logic
|
|
response_data = {
|
|
"Authenticated": True,
|
|
"AuthenticatedMessage": "The user Oluwole Olusoga has successfully authenticated!",
|
|
"ResponseCode": "00",
|
|
"ResponseMessage": "Successful",
|
|
"RequestId": "SMB1234567"
|
|
}
|
|
|
|
|
|
# return ResponseHelper.success(
|
|
# data=response_data,
|
|
# message="Token validation completed successfully"
|
|
# )
|
|
|
|
return response_data
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return jsonify({
|
|
"message": "Validation exception"
|
|
}) , 422
|
|
|
|
except Exception as e:
|
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
|
return jsonify({
|
|
"message": "Internal Server Error"
|
|
}) , 500
|