<?php

namespace FSPoster\App\TelegramNotification;

use FSPoster\App\Providers\Common\WorkflowDriversManager;
use FSPoster\App\Providers\Core\Container;
use FSPoster\App\SocialNetworks\Telegram\Api\Api;
use FSPoster\App\TelegramNotification\App\Controllers\TelegramNotificationController;
use FSPoster\App\TelegramNotification\App\Driver;
use FSPoster\App\TelegramNotification\App\DTOs\Request\TelegramNotificationRequest;
use FSPoster\App\TelegramNotification\App\DTOs\Response\TelegramNotificationResponse;
use FSPoster\App\TelegramNotification\App\Mappers\TelegramNotificationMapper;
use FSPoster\App\TelegramNotification\App\Repositories\TelegramNotificationRepository;
use FSPoster\App\TelegramNotification\App\Services\TelegramNotificationService;

class TelegramNotificationModule
{
    public static function init(): void
    {
        self::registerDependencies();
        self::registerHooks();
    }

    private static function registerDependencies(): void
    {
        Container::addBulk([
            TelegramNotificationController::class,
            TelegramNotificationRepository::class,
            TelegramNotificationMapper::class,
            TelegramNotificationService::class,
            Driver::class,
        ]);

        Container::addTransient(TelegramNotificationRequest::class);
        Container::addTransient(TelegramNotificationResponse::class);
        Container::addTransient(Api::class);
    }

    private static function registerHooks(): void
    {
        add_action('fsp_register_workflow_drivers', function (WorkflowDriversManager $drivers) {
            $drivers->register(Container::get(Driver::class));
        });
    }
}
