<?php

namespace Openguru\OpenCartFramework\Telegram;

use App\Services\SettingsService;
use Openguru\OpenCartFramework\Application;
use Openguru\OpenCartFramework\Container\ServiceProvider;
use Psr\Log\LoggerInterface;

class TelegramServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->container->singleton(TelegramService::class, function (Application $app) {
            $botToken = $app->getConfigValue('telegram.bot_token');

            return new TelegramService(
                $app->get(TelegramInitDataDecoder::class),
                $app->get(LoggerInterface::class),
                $botToken,
            );
        });

        $this->container->singleton(SignatureValidator::class, function (Application $app) {
            return new SignatureValidator(
                $app->get(SettingsService::class),
                $app->get(LoggerInterface::class),
                $app->get(TelegramInitDataDecoder::class),
                $app->getConfigValue('telegram.bot_token'),
            );
        });
    }
}
