Skip to content

Commit 1738e82

Browse files
monsieurleberrejoancaron
authored andcommitted
feat: Support for top volume on last 24h endpoint (#34)
PR Close #34
1 parent 3d121c0 commit 1738e82

8 files changed

Lines changed: 104 additions & 3 deletions

File tree

src/CryptoCompare/Clients/ITopsClient.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ public interface ITopListClient : IApiClient
5959
/// <param name="page">(Optional)The pagination for the request.</param>
6060
/// <param name="sign">(Optional)If set to true, the server will sign the requests, this is useful for usage in smart contracts.</param>
6161
/// <returns>
62-
/// The asynchronous result that yields a CoinListResponse.
62+
/// The asynchronous result that yields a TopMarketCapResponse.
6363
/// </returns>
6464
Task<TopMarketCapResponse> CoinFullDataByMarketCap([NotNull] string toSymbol, int? limit = null, int? page = null, bool? sign = null);
65+
66+
/// <summary>
67+
/// Get full data for the top coins ordered by their total volume across all markets in the last 24 hours as expressed in a given currency.
68+
/// </summary>
69+
/// <param name="toSymbol">The symbol of the currency into which the market cap are expressed.</param>
70+
/// <param name="limit">(Optional)The number currencies to return, default is 10.</param>
71+
/// <param name="page">(Optional)The pagination for the request.</param>
72+
/// <param name="sign">(Optional)If set to true, the server will sign the requests, this is useful for usage in smart contracts.</param>
73+
/// <returns>
74+
/// The asynchronous result that yields a TopVolume24HResponse.
75+
/// </returns>
76+
Task<TopVolume24HResponse> CoinFullDataBy24HVolume(string toSymbol, int? limit = null, int? page = null, bool? sign = null);
6577
}
6678
}

src/CryptoCompare/Clients/TopsClient.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,30 @@ public async Task<TopExchangeFullResponse> ExchangesFullDataByPairAsync(string f
103103
/// <param name="page">(Optional)The pagination for the request.</param>
104104
/// <param name="sign">(Optional)If set to true, the server will sign the requests, this is useful for usage in smart contracts.</param>
105105
/// <returns>
106-
/// The asynchronous result that yields a CoinListResponse.
106+
/// The asynchronous result that yields a TopMarketCapResponse.
107107
/// </returns>
108-
/// <seealso cref="M:CryptoCompare.ITopListClient.ExchangesFullDataByMarketCap(string,int?,int?,bool?)"/>
108+
/// <seealso cref="M:CryptoCompare.ITopListClient.CoinFullDataByMarketCap(string,int?,int?,bool?)"/>
109109
public async Task<TopMarketCapResponse> CoinFullDataByMarketCap(string toSymbol, int? limit = null, int? page = null, bool? sign = null)
110110
{
111111
Check.NotNullOrWhiteSpace(toSymbol, nameof(toSymbol));
112112
return await this.GetAsync<TopMarketCapResponse>(ApiUrls.TopByMarketCapFull(toSymbol, limit, page, sign)).ConfigureAwait(false);
113113
}
114+
115+
/// <summary>
116+
/// Get full data for the top coins ordered by their total volume across all markets in the last 24 hours as expressed in a given currency.
117+
/// </summary>
118+
/// <param name="toSymbol">The symbol of the currency into which the market cap are expressed.</param>
119+
/// <param name="limit">(Optional)The number currencies to return, default is 10.</param>
120+
/// <param name="page">(Optional)The pagination for the request.</param>
121+
/// <param name="sign">(Optional)If set to true, the server will sign the requests, this is useful for usage in smart contracts.</param>
122+
/// <returns>
123+
/// The asynchronous result that yields a TopVolume24HResponse.
124+
/// </returns>
125+
/// <seealso cref="M:CryptoCompare.ITopListClient.CoinFullDataBy24HVolume(string,int?,int?,bool?)"/>
126+
public async Task<TopVolume24HResponse> CoinFullDataBy24HVolume(string toSymbol, int? limit = null, int? page = null, bool? sign = null)
127+
{
128+
Check.NotNullOrWhiteSpace(toSymbol, nameof(toSymbol));
129+
return await this.GetAsync<TopVolume24HResponse>(ApiUrls.TopByVolume24HFull(toSymbol, limit, page, sign)).ConfigureAwait(false);
130+
}
114131
}
115132
}

src/CryptoCompare/Core/ApiUrls.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,19 @@ public static Uri TopByPairVolume([NotNull] string tsym, int? limit)
297297
});
298298
}
299299

300+
public static Uri TopByVolume24HFull([NotNull] string tsym, int? limit, int? page, bool? sign)
301+
{
302+
Check.NotNullOrWhiteSpace(tsym, nameof(tsym));
303+
return new Uri(MinApiEndpoint, "top/totalvolfull").ApplyParameters(
304+
new Dictionary<string, string>
305+
{
306+
{ nameof(tsym), tsym },
307+
{ nameof(limit), limit?.ToString() },
308+
{ nameof(page), page?.ToString() },
309+
{ nameof(sign), sign?.ToString().ToLowerInvariant() }
310+
});
311+
}
312+
300313
public static Uri TopByMarketCapFull([NotNull] string tsym, int? limit, int? page, bool? sign)
301314
{
302315
Check.NotNullOrWhiteSpace(tsym, nameof(tsym));
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Newtonsoft.Json;
2+
3+
namespace CryptoCompare
4+
{
5+
public class TopVolume24HInfo
6+
{
7+
public CoinInfo CoinInfo { get; set; }
8+
9+
[JsonProperty("DISPLAY")]
10+
public Volume24HDisplay Display { get; set; }
11+
12+
[JsonProperty("RAW")]
13+
public Volume24HRaw Raw { get; set; }
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
3+
using Newtonsoft.Json;
4+
5+
namespace CryptoCompare
6+
{
7+
public class TopVolume24HResponse : BaseApiResponse
8+
{
9+
public IReadOnlyList<TopVolume24HInfo> Data { get; set; }
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
using System.Collections.ObjectModel;
3+
4+
namespace CryptoCompare
5+
{
6+
public class Volume24HDisplay : ReadOnlyDictionary<string, CoinFullAggregatedDataDisplay>
7+
{
8+
public Volume24HDisplay(IDictionary<string, CoinFullAggregatedDataDisplay> dictionary)
9+
: base(dictionary)
10+
{
11+
}
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
using System.Collections.ObjectModel;
3+
4+
namespace CryptoCompare
5+
{
6+
public class Volume24HRaw : ReadOnlyDictionary<string, CoinFullAggregatedData>
7+
{
8+
public Volume24HRaw(IDictionary<string, CoinFullAggregatedData> dictionary)
9+
: base(dictionary)
10+
{
11+
}
12+
}
13+
}

test/Cryptocompare.Integration.Tests/Clients/TopListClientTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@ public async Task CanCallTopListCoinFullDataByMarketCap()
4242
var result = await CryptoCompareClient.Instance.Tops.CoinFullDataByMarketCap("EUR", 20);
4343
Assert.NotNull(result);
4444
}
45+
46+
[Fact]
47+
public async Task CanCallTopListCoinFullDataBy24HVolume()
48+
{
49+
var result = await CryptoCompareClient.Instance.Tops.CoinFullDataBy24HVolume("EUR", 20);
50+
Assert.NotNull(result);
51+
}
4552
}
4653
}

0 commit comments

Comments
 (0)