summaryrefslogtreecommitdiffstats
path: root/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs')
-rw-r--r--src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
new file mode 100644
index 0000000..d9c9769
--- /dev/null
+++ b/src/IOL.VippsEcommerce/ServiceCollectionExtensions.cs
@@ -0,0 +1,28 @@
+using System;
+using IOL.VippsEcommerce.Models;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace IOL.VippsEcommerce
+{
+ public static class ServiceCollectionExtensions
+ {
+ /// <summary>
+ /// Configures and adds the VippsEcommerceService to your DI.
+ /// </summary>
+ /// <param name="services">Servicecollection to add VippsEcommerceService to.</param>
+ /// <param name="configuration"></param>
+ /// <returns></returns>
+ public static IServiceCollection AddVippsEcommerceService(
+ this IServiceCollection services,
+ Action<VippsConfiguration> configuration
+ ) {
+ if (services == null) throw new ArgumentNullException(nameof(services));
+ if (configuration == null) throw new ArgumentNullException(nameof(configuration));
+
+ services.Configure(configuration);
+ services.AddHttpClient<IVippsEcommerceService, VippsEcommerceService>();
+ services.AddScoped<IVippsEcommerceService, VippsEcommerceService>();
+ return services;
+ }
+ }
+} \ No newline at end of file