using System;
using IOL.VippsEcommerce.Models;
using Microsoft.Extensions.DependencyInjection;
namespace IOL.VippsEcommerce
{
public static class ServiceCollectionExtensions
{
///
/// Configures and adds the VippsEcommerceService to your DI.
///
/// Servicecollection to add VippsEcommerceService to.
///
///
public static IServiceCollection AddVippsEcommerceService(
this IServiceCollection services,
Action configuration
) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
if (configuration == null) {
throw new ArgumentNullException(nameof(configuration));
}
services.Configure(configuration);
services.AddHttpClient();
services.AddScoped();
return services;
}
///
/// Adds the VippsEcommerceService to your DI, and expects configuration values from environment variables.
///
/// Servicecollection to add VippsEcommerceService to.
///
public static IServiceCollection AddVippsEcommerceService(this IServiceCollection services) {
if (services == null) {
throw new ArgumentNullException(nameof(services));
}
services.Configure(new Action(o => o.ConfigurationMode = VippsConfigurationMode.ONLY_ENVIRONMENT));
services.AddHttpClient();
services.AddScoped();
return services;
}
}
}