<?php

namespace Openguru\OpenCartFramework\TeleCartPulse;

use Openguru\OpenCartFramework\Container\Container;
use Openguru\OpenCartFramework\Container\ServiceProvider;
use Openguru\OpenCartFramework\Telegram\TelegramInitDataDecoder;

class TeleCartPulseServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->container->singleton(PayloadSigner::class, function (Container $app) {
            return new PayloadSigner(
                $app->getConfigValue('pulse.api_key'),
            );
        });

        $this->container->singleton(TeleCartPulseService::class, function (Container $app) {
            return new TeleCartPulseService(
                $app->get(TelegramInitDataDecoder::class),
                $app->get(PayloadSigner::class),
                $app->getConfigValue('pulse.api_key'),
            );
        });
    }
}
