using System;
using System.Collections.Generic;
using isnd.Entities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Unleash;
using Unleash.ClientFactory;

namespace isnd.Helpers
{
    public static class UnleashHelpers
    {

        public static IUnleash CreateUnleahClient(this IHostingEnvironment env,
        UnleashClientSettings unleashClientSettings)
        {
            var unleashSettings = new UnleashSettings
            {
                UnleashApi = new Uri(unleashClientSettings.ApiUrl),
                AppName = "isnd",
                Environment = env.EnvironmentName,
                CustomHttpHeaders = new Dictionary<string, string>
                {
                    { "Authorization", unleashClientSettings.ClientApiKey }
                }
            };

            UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
            return unleashClientFactory.CreateClient(unleashSettings);
        }
    }
}