import json

import boto3
from botocore.config import Config
from src.logger import logger


class SqsClient:
    def __init__(self) -> None:
        retry_config = Config(retries={"max_attempts": 3, "mode": "standard"})
        self.client = boto3.client("sqs", config=retry_config)

    def send_message(self, queue_url: str, body: dict) -> None:
        try:
            result = self.client.send_message(
                QueueUrl=queue_url,
                MessageBody=json.dumps(body),
            )
            logger.debug(f"Successfully sent message to SQS: message_id '{result.get('MessageId')}'")

        except Exception as e:
            logger.error(f"Failed to send message to SQS: {e!s}")
            raise
