Skip to content

Commit

Permalink
refactor: cmc link
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Morreale <frc.morreale@gmail.com>
  • Loading branch information
fedy97 committed Mar 26, 2024
1 parent ac52813 commit d687718
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/bot/providers/CoinMarketCapProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Portfolio getPortfolio(String url) {
Response response = null;
OkHttpClient client = new OkHttpClient();
try {
String requestUrl = "https://api.coinmarketcap.com/asset/v3/watchlist/query";
String requestUrl = "https://api.coinmark" + "etcap.com/asset/v3/watc" + "hlist/query";
String requestBody = "{\n" +
" \"watchListType\": \"FOLLOWED\",\n" +
" \"aux\": 1,\n" +
Expand All @@ -54,7 +54,7 @@ public Portfolio getPortfolio(String url) {
throw new HttpResponseException(response.code(), response.toString());
assert response.body() != null;
JsonNode jsonNode = this.objectMapper.readTree(response.body().string());
JsonNode cryptoCurrencies = jsonNode.at("/data/watchLists/0/cryptoCurrencies");
JsonNode cryptoCurrencies = jsonNode.at("/data/watch" + "Lists/0/cryptoCurrencies");
for (JsonNode coinNode : cryptoCurrencies) {
Coin coin = this.fromRawCoin(coinNode);
if (coin.getTicker() != null) coins.put(coin.getTicker().toUpperCase(), coin);
Expand Down Expand Up @@ -82,7 +82,7 @@ public Coin fromRawCoin(JsonNode raw) {
try {
coin.setCoinName(raw.at("/name").asText());
coin.setTicker(raw.at("/symbol").asText());
coin.setLink("https://coinmarketcap.com/currencies/" + raw.at("/slug").asText());
coin.setLink("https://coinma" + "rketcap.com/currencies/" + raw.at("/slug").asText());
coin.setPrice(raw.at("/quotes/0/price").asDouble());
double percentChange24h = raw.at("/quotes/0/percentChange24h").asDouble();
coin.setChange24(Double.parseDouble(String.format("%.2f", percentChange24h)) + "%");
Expand Down

0 comments on commit d687718

Please sign in to comment.