Commit 5d823d76 authored by Jeremy Bokobza's avatar Jeremy Bokobza Committed by GitHub

Removed Refit in favor of Flurl (#84)

* Removed Refit in favor of Flurl

* Removed Refit ns
parent 96891758
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Flurl.Http" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" />
<PackageReference Include="refit" Version="3.0.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.1" /> <PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.1" />
<PackageReference Include="Stratis.Bitcoin" Version="1.0.1.8-alpha" /> <PackageReference Include="Stratis.Bitcoin" Version="1.0.1.8-alpha" />
</ItemGroup> </ItemGroup>
......
...@@ -4,7 +4,6 @@ using System.Text; ...@@ -4,7 +4,6 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NTumbleBit; using NTumbleBit;
using NTumbleBit.ClassicTumbler; using NTumbleBit.ClassicTumbler;
using Refit;
namespace Breeze.TumbleBit.Client namespace Breeze.TumbleBit.Client
{ {
...@@ -17,7 +16,6 @@ namespace Breeze.TumbleBit.Client ...@@ -17,7 +16,6 @@ namespace Breeze.TumbleBit.Client
/// Gets the tumbler's parameters. /// Gets the tumbler's parameters.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Get("/api/v1/tumblers/0/parameters")]
Task<ClassicTumblerParameters> GetClassicTumblerParametersAsync(); Task<ClassicTumblerParameters> GetClassicTumblerParametersAsync();
} }
} }
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
using NTumbleBit.ClassicTumbler; using NTumbleBit.ClassicTumbler;
using Refit;
using NBitcoin.JsonConverters;
using NTumbleBit.JsonConverters;
namespace Breeze.TumbleBit.Client namespace Breeze.TumbleBit.Client
{ {
...@@ -29,15 +23,7 @@ namespace Breeze.TumbleBit.Client ...@@ -29,15 +23,7 @@ namespace Breeze.TumbleBit.Client
/// <param name="serverAddress">The server address.</param> /// <param name="serverAddress">The server address.</param>
public void InitializeTumblerService(Uri serverAddress) public void InitializeTumblerService(Uri serverAddress)
{ {
this.tumblerService = RestService.For<ITumblerService>(serverAddress.ToString(), this.tumblerService = new TumblerService(serverAddress);
new RefitSettings
{
JsonSerializerSettings = new JsonSerializerSettings
{
Converters = new List<JsonConverter> { new NetworkJsonConverter(), new RsaKeyJsonConverter(), new UInt256JsonConverter() }
}
});
} }
/// <inheritdoc /> /// <inheritdoc />
......
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Flurl;
using Flurl.Http;
using Flurl.Http.Configuration;
using NBitcoin.JsonConverters;
using Newtonsoft.Json;
using NTumbleBit.ClassicTumbler;
using NTumbleBit.JsonConverters;
namespace Breeze.TumbleBit.Client
{
public class TumblerService : ITumblerService
{
private readonly string serverAddress;
public TumblerService(Uri serverAddress)
{
this.serverAddress = serverAddress.ToString();
FlurlHttp.Configure(c => {
c.JsonSerializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings
{
Converters = new List<JsonConverter> { new NetworkJsonConverter(), new RsaKeyJsonConverter(), new UInt256JsonConverter() }
});
});
}
/// <inheritdoc />
public async Task<ClassicTumblerParameters> GetClassicTumblerParametersAsync()
{
ClassicTumblerParameters result = await this.serverAddress.AppendPathSegment("/api/v1/tumblers/0/parameters").GetJsonAsync<ClassicTumblerParameters>();
return result;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment