Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading;

using Rest;
using SDL.ECommerce.Api;
using SDL.ECommerce.DXA.Providers;
using SDL.ECommerce.DXA.Servants;
Expand All @@ -22,7 +22,8 @@ public T Resolve<T>()
{ typeof(IECommerceLinkResolver), new Lazy<IECommerceLinkResolver>(() => TryResolveDependency<IECommerceLinkResolver>() ?? new DXALinkResolver()) },
{ typeof(IHttpContextServant), new Lazy<IHttpContextServant>(() => TryResolveDependency<IHttpContextServant>() ?? new HttpContextServant()) },
{ typeof(IPageModelServant), new Lazy<IPageModelServant>(() => TryResolveDependency<IPageModelServant>() ?? new PageModelServant()) },
{ typeof(IPathServant), new Lazy<IPathServant>(() => TryResolveDependency<IPathServant>() ?? new PathServant()) }
{ typeof(IPathServant), new Lazy<IPathServant>(() => TryResolveDependency<IPathServant>() ?? new PathServant()) },
{ typeof(RestClientFactory), new Lazy<RestClientFactory>(() => TryResolveDependency<RestClientFactory>() ?? new RestClientFactory()) }
};

var dependency = dependencies[typeof(T)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@
<HintPath>..\packages\Microsoft.Spatial.6.15.0\lib\portable-net45+win+wpa81\Microsoft.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Sdl.Web.Delivery.DiscoveryService">
<HintPath>..\packages\Sdl.Web.Delivery.10.1.0\lib\net452\Sdl.Web.Delivery.DiscoveryService.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<package id="Microsoft.OData.Edm" version="6.15.0" targetFramework="net452" />
<package id="Microsoft.Spatial" version="6.15.0" targetFramework="net452" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net452" />
<package id="Sdl.Web.Delivery" version="10.1.0" targetFramework="net452" />
<package id="StackExchange.Redis.StrongName" version="1.1.605" targetFramework="net452" />
<package id="System.Collections" version="4.3.0" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace SDL.ECommerce.Rest
public class ECommerceClient : IECommerceClient
{
private readonly Func<Type, object> dependencies;
private readonly RestClient restClient;
private readonly IRestClient restClient;
private readonly IECommerceCacheProvider cacheProvider;
private readonly int categoryExpiryTimeout;
private readonly bool useSanitizedPathNames;
Expand All @@ -27,11 +27,14 @@ public ECommerceClient(string endpointAddress,
bool useSanitizedPathNames,
Func<Type, object> dependencies = null)
{
this.restClient = new RestClient(endpointAddress + "/rest/v1/" + locale);
this.dependencies = dependencies;

this.cacheProvider = cacheProvider;
this.categoryExpiryTimeout = categoryExpiryTimeout;
this.useSanitizedPathNames = useSanitizedPathNames;
this.dependencies = dependencies;

var restClientFactory = Resolve<RestClientFactory>() ?? new RestClientFactory();
restClient = restClientFactory.CreateClient(endpointAddress, locale);
}

public ICartService CartService
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace SDL.ECommerce.Rest
{
using RestSharp;

public class RestClientFactory
{
public virtual IRestClient CreateClient(string endpointAddress, string locale, string apiVersion = "v1")
{
return new RestClient(string.Format("{0}/rest/{1}/{2}", endpointAddress, apiVersion, locale));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
Expand Down Expand Up @@ -75,6 +74,7 @@
<Compile Include="Model\Promotion.cs" />
<Compile Include="Model\QuerySuggestion.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RestClientFactory.cs" />
<Compile Include="Service\CartService.cs" />
<Compile Include="Service\EditService.cs" />
<Compile Include="Service\ProductCategoryService.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using SDL.ECommerce.Api.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SDL.ECommerce.Api.Model;
using RestSharp;
using Newtonsoft.Json;
Expand All @@ -14,9 +11,9 @@ namespace SDL.ECommerce.Rest.Service
{
public class CartService : ICartService
{
private RestClient restClient;
private IRestClient restClient;

public CartService(RestClient restClient)
public CartService(IRestClient restClient)
{
this.restClient = restClient;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using SDL.ECommerce.Api.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SDL.ECommerce.Api.Model;
using RestSharp;
using Newtonsoft.Json;
Expand All @@ -14,10 +9,10 @@ namespace SDL.ECommerce.Rest.Service
{
class EditService : IEditService
{
private RestClient restClient;
private IRestClient restClient;
private IECommerceCacheProvider cacheProvider;

public EditService(RestClient restClient, IECommerceCacheProvider cacheProvider)
public EditService(IRestClient restClient, IECommerceCacheProvider cacheProvider)
{
this.restClient = restClient;
this.cacheProvider = cacheProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using SDL.ECommerce.Api.Model;
using RestSharp;
using SDL.ECommerce.Rest.Model;
using SDL.ECommerce.Api;
using SDL.ECommerce.Formatting.Servants;

namespace SDL.ECommerce.Rest.Service
Expand All @@ -15,13 +14,13 @@ namespace SDL.ECommerce.Rest.Service
/// </summary>
class ProductCategoryService : IProductCategoryService
{
private RestClient restClient;
private IRestClient restClient;
private int categoryExpiryTimeout = 3600000;
private bool useSanitizedPathNames = false;
private ICategory rootCategory = new Category();
private readonly ISanitizerServant _sanitizerServant;

public ProductCategoryService(RestClient restClient, int categoryExpiryTimeout, bool useSanitizedPathNames)
public ProductCategoryService(IRestClient restClient, int categoryExpiryTimeout, bool useSanitizedPathNames)
{
this.restClient = restClient;
this.useSanitizedPathNames = useSanitizedPathNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SDL.ECommerce.Rest.Service
{
Expand All @@ -16,11 +14,11 @@ namespace SDL.ECommerce.Rest.Service
/// </summary>
public class ProductDetailService : IProductDetailService
{
private RestClient restClient;
private IRestClient restClient;
private IProductCategoryService productCategoryService;
private IECommerceCacheProvider cacheProvider;

public ProductDetailService(RestClient restClient, IProductCategoryService productCategoryService, IECommerceCacheProvider cacheProvider)
public ProductDetailService(IRestClient restClient, IProductCategoryService productCategoryService, IECommerceCacheProvider cacheProvider)
{
this.restClient = restClient;
this.productCategoryService = productCategoryService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using SDL.ECommerce.Api.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SDL.ECommerce.Api.Model;
using RestSharp;
using SDL.ECommerce.Rest.Model;
Expand All @@ -18,10 +15,10 @@ namespace SDL.ECommerce.Rest.Service
class ProductQueryService : IProductQueryService
{

private RestClient restClient;
private IRestClient restClient;
private IECommerceCacheProvider cacheProvider;

public ProductQueryService(RestClient restClient, IECommerceCacheProvider cacheProvider)
public ProductQueryService(IRestClient restClient, IECommerceCacheProvider cacheProvider)
{
this.restClient = restClient;
this.cacheProvider = cacheProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.1" targetFramework="net45" />
<package id="RestSharp" version="105.2.3" targetFramework="net45" />
</packages>