use map instead of class json parser
This commit is contained in:
parent
e97af1d171
commit
a0b48a6165
|
@ -1,15 +0,0 @@
|
||||||
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap.CMCQuotes;
|
|
||||||
public class CMCData {
|
|
||||||
public String id;
|
|
||||||
public String name;
|
|
||||||
public String symbol;
|
|
||||||
public String website_slug;
|
|
||||||
public BigDecimal rank;
|
|
||||||
public BigDecimal circulating_supply;
|
|
||||||
public BigDecimal total_supply;
|
|
||||||
public BigDecimal max_supply;
|
|
||||||
public CMCQuotes quotes;
|
|
||||||
public long last_updated;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
|
|
||||||
public class CMCMetaData {
|
|
||||||
public long timestamp;
|
|
||||||
public String error;
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
public class CMCQuote {
|
|
||||||
public BigDecimal price;
|
|
||||||
public BigDecimal volume_24h;
|
|
||||||
public BigDecimal market_cap;
|
|
||||||
public BigDecimal percent_change_1h;
|
|
||||||
public BigDecimal percent_change_24h;
|
|
||||||
public BigDecimal percent_change_7d;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
|
|
||||||
import com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap.CMCQuote;
|
|
||||||
public class CMCQuotes {
|
|
||||||
public CMCQuote USD;
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
package com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap;
|
|
||||||
import com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap.CMCData;
|
|
||||||
import com.generalbytes.batm.server.extensions.extra.dash.sources.coinmarketcap.CMCMetaData;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
public class CMCTicker {
|
|
||||||
private CMCData jsondData;
|
|
||||||
private CMCMetaData metaData;
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return jsondData.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return jsondData.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSymbol() {
|
|
||||||
return jsondData.symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebsite_slug() {
|
|
||||||
return jsondData.website_slug;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getRank() {
|
|
||||||
return jsondData.rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPrice() {
|
|
||||||
return jsondData.quotes.USD.price;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal get_24h_volume() {
|
|
||||||
return jsondData.quotes.USD.volume_24h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMarket_cap() {
|
|
||||||
return jsondData.quotes.USD.market_cap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getCirculating_supply() {
|
|
||||||
return jsondData.circulating_supply;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getTotal_supply() {
|
|
||||||
return jsondData.total_supply;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMax_supply() {
|
|
||||||
return jsondData.max_supply;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPercent_change_1h() {
|
|
||||||
return jsondData.quotes.USD.percent_change_1h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPercent_change_24h() {
|
|
||||||
return jsondData.quotes.USD.percent_change_24h;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getPercent_change_7d() {
|
|
||||||
return jsondData.quotes.USD.percent_change_7d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLast_updated() {
|
|
||||||
return jsondData.last_updated;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -88,7 +88,9 @@ public class CoinmarketcapRateSource implements IRateSource {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMCTicker ticker = api.getTickers(cryptoId, fiatCurrency);
|
Map<String, String> ticker = api.getTickers(cryptoId, fiatCurrency);
|
||||||
|
JSONObject json = new JSONObject(ticker);
|
||||||
|
System.out.printf( "JSON: %s", json.toString() );
|
||||||
/*if (cryptoCurrency.equalsIgnoreCase(ticker.getSymbol())) {
|
/*if (cryptoCurrency.equalsIgnoreCase(ticker.getSymbol())) {
|
||||||
if (Currencies.EUR.equalsIgnoreCase(fiatCurrency)) {
|
if (Currencies.EUR.equalsIgnoreCase(fiatCurrency)) {
|
||||||
return ticker.getPrice_eur();
|
return ticker.getPrice_eur();
|
||||||
|
@ -99,6 +101,6 @@ public class CoinmarketcapRateSource implements IRateSource {
|
||||||
return ticker.getPrice_usd();
|
return ticker.getPrice_usd();
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
return ticker.getPrice();
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,5 +25,5 @@ import javax.ws.rs.core.MediaType;
|
||||||
public interface ICoinmarketcapAPI {
|
public interface ICoinmarketcapAPI {
|
||||||
@GET
|
@GET
|
||||||
@Path("/{id}/")
|
@Path("/{id}/")
|
||||||
CMCTicker getTickers(@PathParam("id") Integer id, @QueryParam("convert") String fiatCurrency);
|
Map<String, String> getTickers(@PathParam("id") Integer id, @QueryParam("convert") String fiatCurrency);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue