-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add Fees service for new Fees API (#203)
- Loading branch information
1 parent
5c3c486
commit 272ebf6
Showing
9 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
CoinbasePro.Specs/JsonFixtures/Services/Fees/FeesResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace CoinbasePro.Specs.JsonFixtures.Services.Fees | ||
{ | ||
public static class FeesResponseFixture | ||
{ | ||
public static string Create() | ||
{ | ||
var json = @" | ||
[ | ||
{ | ||
""maker_fee_rate"": ""0.0015"", | ||
""taker_fee_rate"": ""0.0025"", | ||
""usd_volume"": ""25000.00"" | ||
} | ||
]"; | ||
|
||
return json; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
CoinbasePro.Specs/JsonFixtures/Services/Fills/FillsResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
CoinbasePro.Specs/JsonFixtures/Services/Fundings/FundingsResponseFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using CoinbasePro.Network.HttpClient; | ||
using CoinbasePro.Services.Fees; | ||
using CoinbasePro.Services.Fees.Models; | ||
using CoinbasePro.Specs.JsonFixtures.Network.HttpResponseMessage; | ||
using CoinbasePro.Specs.JsonFixtures.Services.Fees; | ||
using Machine.Fakes; | ||
using Machine.Specifications; | ||
|
||
namespace CoinbasePro.Specs.Services.Fees | ||
{ | ||
[Subject("FeesService")] | ||
public class FeesServiceSpecs : WithSubject<FeesService> | ||
{ | ||
Establish context = () => | ||
The<IHttpClient>().WhenToldTo(p => p.SendAsync(Param.IsAny<HttpRequestMessage>())) | ||
.Return(Task.FromResult(HttpResponseMessageFixture.CreateWithEmptyValue())); | ||
|
||
class when_getting_current_fees | ||
{ | ||
static IEnumerable<Fee> fee_response; | ||
|
||
Establish context = () => | ||
The<IHttpClient>().WhenToldTo(p => p.ReadAsStringAsync(Param.IsAny<HttpResponseMessage>())) | ||
.Return(Task.FromResult(FeesResponseFixture.Create())); | ||
|
||
Because of = () => | ||
fee_response = Subject.GetCurrentFeesAsync().Result; | ||
|
||
It should_return_a_response = () => | ||
fee_response.ShouldNotBeNull(); | ||
|
||
It should_return_a_correct_response = () => | ||
{ | ||
fee_response.First().MakerFeeRate.ShouldEqual(0.0015m); | ||
fee_response.First().TakerFeeRate.ShouldEqual(0.0025m); | ||
fee_response.First().UsdVolume.ShouldEqual(25000); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using CoinbasePro.Network.HttpClient; | ||
using CoinbasePro.Network.HttpRequest; | ||
using CoinbasePro.Services.Fees.Models; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace CoinbasePro.Services.Fees | ||
{ | ||
public class FeesService : AbstractService, IFeesService | ||
{ | ||
public FeesService( | ||
IHttpClient httpClient, | ||
IHttpRequestMessageService httpRequestMessageService) | ||
: base(httpClient, httpRequestMessageService) | ||
{ | ||
} | ||
|
||
public async Task<IEnumerable<Fee>> GetCurrentFeesAsync() | ||
{ | ||
var fees = await SendServiceCall<IEnumerable<Fee>>(HttpMethod.Get, "/fees"); | ||
|
||
return fees; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using CoinbasePro.Services.Fees.Models; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace CoinbasePro.Services.Fees | ||
{ | ||
public interface IFeesService | ||
{ | ||
Task<IEnumerable<Fee>> GetCurrentFeesAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace CoinbasePro.Services.Fees.Models | ||
{ | ||
public class Fee | ||
{ | ||
public decimal MakerFeeRate { get; set; } | ||
|
||
public decimal TakerFeeRate { get; set; } | ||
|
||
public decimal UsdVolume { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters