using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using StellaOps.Plugin;
using StellaOps.Excititor.Connectors.Abstractions;
using StellaOps.Excititor.Core;

namespace StellaOps.Excititor.Connectors.MyProvider;

public sealed class MyConnectorPlugin : IConnectorPlugin
{
    private static readonly VexConnectorDescriptor Descriptor = new(
        id: "excititor:my-provider",
        kind: VexProviderKind.Vendor,
        displayName: "My Provider VEX");

    public string Name => Descriptor.DisplayName;

    public bool IsAvailable(IServiceProvider services) => true;

    public IFeedConnector Create(IServiceProvider services)
    {
        var logger = services.GetRequiredService<ILogger<MyConnector>>();
        var timeProvider = services.GetRequiredService<TimeProvider>();
        var validators = services.GetServices<IVexConnectorOptionsValidator<MyConnectorOptions>>();
        return new MyConnector(Descriptor, logger, timeProvider, validators);
    }
}
