57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
from marshmallow import ValidationError
|
|
from app.utils.logger import logger
|
|
from app.helpers.response_helper import ResponseHelper
|
|
from app.schemas.sms import SMSSchema
|
|
|
|
|
|
class SMSService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the SMS request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
dict: A standardized response.
|
|
"""
|
|
try:
|
|
logger.info("Processing SMS request")
|
|
|
|
# Validate input data using SMSSchema
|
|
schema = SMSSchema()
|
|
validated_data = schema.load(data) # Raises ValidationError if invalid
|
|
|
|
# Simulated SMS sending logic
|
|
response_data = {
|
|
"data": "",
|
|
"statusCode": 200,
|
|
"isSuccessful": True,
|
|
"errorMessage": None
|
|
}
|
|
|
|
|
|
# return ResponseHelper.success(
|
|
# data=response_data,
|
|
# message="SMS sent successfully"
|
|
# )
|
|
|
|
return response_data
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return ResponseHelper.error(
|
|
message="Invalid input data",
|
|
status_code=400,
|
|
error=err.messages
|
|
)
|
|
|
|
except Exception as e:
|
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
|
return ResponseHelper.error(
|
|
message="An internal error occurred",
|
|
status_code=500,
|
|
error=str(e)
|
|
)
|