<?php

namespace Chatbeep\Laravel;

use Illuminate\Support\ServiceProvider;

class ChatbeepServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__.'/../config/chatbeep.php', 'chatbeep');

        $this->app->singleton('chatbeep', function ($app) {
            return new ChatbeepManager(
                $app['config']->get('chatbeep.base_url'),
                $app['config']->get('chatbeep.token'),
                (int) $app['config']->get('chatbeep.timeout', 10),
            );
        });

        $this->app->singleton(ChatbeepManager::class, function ($app) {
            return $app->make('chatbeep');
        });
    }

    public function boot(): void
    {
        $this->publishes([
            __DIR__.'/../config/chatbeep.php' => config_path('chatbeep.php'),
        ], 'chatbeep-config');
    }
}
