from src.__types.index import UsageEventRequestMessage
from src.infrastructure.clients.sqs_client import SqsClient
from src.settings import Settings

settings = Settings()


class UsageEventRequestQueue:
    """使用イベントリクエストのキュー"""

    def __init__(self, client: SqsClient) -> None:
        if not settings.usage_event_queue_url:
            raise ValueError("usage_event_queue_url is required in settings")
        self.queue_url = settings.usage_event_queue_url
        self.client = client

    def publish(self, message: UsageEventRequestMessage) -> None:
        """使用イベント登録に必要な情報をキューに登録する"""
        self.client.send_message(
            queue_url=self.queue_url,
            body=message.model_dump(mode="json"),
        )
