<?php

namespace NoahVet\Reef\RabbitMQ\Notification\Sender;

use NoahVet\Reef\Domain\Security\Model\Resource;
use NoahVet\Reef\RabbitMQ\Notification\Factory\ReefNotificationFactoryInterface;
use NoahVet\Reef\RabbitMQ\Producer\Factory\ReefMQProducerFactoryInterface;

class ReefNotificationSender implements ReefNotificationSenderInterface
{
    public function __construct(
        protected readonly ReefNotificationFactoryInterface $reefNotificationFactory,
        protected readonly ReefMQProducerFactoryInterface $producerFactory,
    ) {
    }

    #[\Override]
    public function sendNotification(
        Resource $resource,
        string $action,
        array $rawData,
    ): void {
        $this->producerFactory->getProducer()
            ->publishNotification(
                $this->reefNotificationFactory->createNotification($resource, $action, $rawData),
            )
        ;
    }
}
