using Microsoft.Extensions.DependencyInjection;
using NewRock.Sdk.Security;

namespace NewRock.Sdk
{
    public static class NewRockSdkStartupExtensions
    {
        public static IServiceCollection AddNewRockSdk(this IServiceCollection services, string deviceAddress)
        {
            services.AddHttpClient(Defaults.DeviceName, d =>
            {
                d.BaseAddress = new Uri(deviceAddress);
            });

            services.AddScoped<INewRockClient, NewRockClient>()
                .AddScoped<Encryptor>()
                .AddSingleton<IAuthorizeGenerator, AuthorizeGenerator>();

            return services;
        }
    }
}
