-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added market cap added total supply added bnb price added lp holdings
- Loading branch information
Natured
authored and
Natured
committed
Nov 24, 2021
1 parent
8304e32
commit e1da7c7
Showing
8 changed files
with
144 additions
and
13 deletions.
There are no files selected for viewing
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,8 @@ | ||
namespace StonkBot.Entities | ||
{ | ||
public class TickerPrice | ||
{ | ||
public string Symbol { get; set; } | ||
public decimal Price { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace StonkBot.Entities | ||
{ | ||
public class TokenData | ||
{ | ||
public string TotalSupply { get; set; } | ||
public string MarketCap { get; set; } | ||
public string LpHoldings { 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
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 Discord; | ||
using Newtonsoft.Json; | ||
using RestSharp; | ||
using StonkBot.Entities; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
|
||
namespace StonkBot.Services | ||
{ | ||
internal class BinanceRestApi | ||
{ | ||
private RestClient _restClient; | ||
|
||
private const string BaseUrl = "https://api.binance.com/api/v3"; | ||
private readonly ILogService _logService; | ||
|
||
public BinanceRestApi(ILogService logService) | ||
{ | ||
_restClient = new RestClient(); | ||
_logService = logService; | ||
} | ||
|
||
public async Task<TickerPrice> GetTickerPriceAsync(string tickerSymbol) | ||
{ | ||
var url = $"{BaseUrl}/ticker/price?symbol={tickerSymbol.ToUpper()}"; | ||
var request = new RestRequest(url, Method.GET, DataFormat.Json); | ||
|
||
var response = await _restClient.ExecuteAsync(request).ConfigureAwait(false); | ||
CheckResponse(response); | ||
var tickerPrice = JsonConvert.DeserializeObject<TickerPrice>(response.Content); | ||
|
||
return tickerPrice; | ||
} | ||
|
||
private void CheckResponse(IRestResponse restResponse) | ||
{ | ||
if (restResponse.StatusCode != HttpStatusCode.OK) | ||
{ | ||
_logService.Log(LogSeverity.Debug, $"Code: {restResponse.StatusCode}"); | ||
_logService.Log(LogSeverity.Debug, $"Code: {restResponse.Content}"); | ||
} | ||
} | ||
} | ||
} |
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
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