using Microsoft.Extensions.DependencyInjection;
using SatelliteProvider.Common.Interfaces;

namespace SatelliteProvider.Services.TileDownloader;

public static class TileDownloaderServiceCollectionExtensions
{
    public static IServiceCollection AddTileDownloader(this IServiceCollection services)
    {
        services.AddMemoryCache();
        services.AddHttpClient(GoogleMapsDownloaderV2.GoogleMapsTilesClientName, c =>
        {
            c.DefaultRequestHeaders.UserAgent.ParseAdd(GoogleMapsDownloaderV2.UserAgent);
            c.Timeout = TimeSpan.FromSeconds(GoogleMapsDownloaderV2.DefaultHttpClientTimeoutSeconds);
        });
        services.AddSingleton<ISatelliteDownloader, GoogleMapsDownloaderV2>();
        services.AddSingleton<ITileService, TileService>();
        services.AddSingleton<IUavTileQualityGate, UavTileQualityGate>();
        services.AddSingleton<IUavTileUploadHandler, UavTileUploadHandler>();
        return services;
    }
}
