From 1ac590758021964dae72b85863a0c4c4602a8af7 Mon Sep 17 00:00:00 2001 From: Doug Dellolio Date: Fri, 15 Dec 2017 19:57:51 -0500 Subject: [PATCH] [Refactor] Fills service (#29) --- .../Services/Fills/FillsServiceSpecs.cs | 2 +- GDAXClient/Services/Fills/FillsService.cs | 25 ++++++------------- README.md | 13 ++++++++++ 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/GDAXClient.Specs/Services/Fills/FillsServiceSpecs.cs b/GDAXClient.Specs/Services/Fills/FillsServiceSpecs.cs index c1281a73..925b0ad2 100644 --- a/GDAXClient.Specs/Services/Fills/FillsServiceSpecs.cs +++ b/GDAXClient.Specs/Services/Fills/FillsServiceSpecs.cs @@ -102,7 +102,7 @@ class when_requesting_fills_by_product_id }; Because of = () => - fill_response = Subject.GetFillsByProductIdAsync(ProductType.BtcUsd.ToDasherizedUpper(), 1).Result; + fill_response = Subject.GetFillsByProductIdAsync(ProductType.BtcUsd, 1).Result; It should_return_a_response = () => fill_response.ShouldNotBeNull(); diff --git a/GDAXClient/Services/Fills/FillsService.cs b/GDAXClient/Services/Fills/FillsService.cs index 8df018a5..407b5818 100644 --- a/GDAXClient/Services/Fills/FillsService.cs +++ b/GDAXClient/Services/Fills/FillsService.cs @@ -1,13 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using GDAXClient.HttpClient; using GDAXClient.Services.Accounts; -using GDAXClient.Services.Fills.Models; using GDAXClient.Services.Fills.Models.Responses; using GDAXClient.Services.HttpRequest; -using Newtonsoft.Json; +using GDAXClient.Services.Orders; +using GDAXClient.Utilities.Extensions; namespace GDAXClient.Services.Fills { @@ -32,31 +31,21 @@ public FillsService( public async Task>> GetAllFillsAsync(int limit = 100) { - var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Post, authenticator, $"/fills?limit={limit}"); + var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Get, authenticator, $"/fills?limit={limit}"); return fills; } public async Task>> GetFillsByOrderIdAsync(string orderId, int limit = 100) { - var fill = JsonConvert.SerializeObject(new Fill - { - order_id = new Guid(orderId) - }); - - var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Post, authenticator, $"/fills?limit={limit}", fill); + var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Get, authenticator, $"/fills?limit={limit}&order_id={orderId}"); return fills; } - public async Task>> GetFillsByProductIdAsync(string productId, int limit = 100) + public async Task>> GetFillsByProductIdAsync(ProductType productId, int limit = 100) { - var fill = JsonConvert.SerializeObject(new Fill - { - product_id = productId.ToUpper() - }); - - var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Post, authenticator, $"/fills?limit={limit}", fill); + var fills = await SendHttpRequestMessagePagedAsync(HttpMethod.Get, authenticator, $"/fills?limit={limit}&product_id={productId.ToDasherizedUpper()}"); return fills; } diff --git a/README.md b/README.md index 961c7001..8df8910f 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ var allAccounts = await gdaxClient.AccountsService.GetAllAccountsAsync(); ###### Currencies ###### - GetAllCurrenciesAsync() - gets a list of known currencies +###### Fills ###### +- GetAllFillsAsync(limit) - gets a list of all recent fills (paged response) +- GetFillsByOrderIdAsync(orderId, limit) - gets a list of all recent fills by order id (paged response) +- GetFillsByProductIdAsync(productType, limit) - gets a list of all recent fills by product type (paged response) +

Sandbox Support

Generate your key at https://public.sandbox.gdax.com/settings/api @@ -107,5 +112,13 @@ var firstAccountHistoryOnFirstPage = firstPage.ToList()[0]; var secondAccountHistoryOnFirstPage = firstPage.ToList()[1]; ```` +

Contributors

+ +Thanks for contributing! + +- @dgelineau + +

Bugs or questions?

+ Please open an issue for any bugs or questions