import json

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


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

    def publish(self, message: dict) -> None:

        self.client.publish(
            TopicArn=self.topic_arn,
            Message=json.dumps(message),
        )
        logger.debug("Successfully published message to SNS")
