-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Would love to see Coins.TH supported, this is my try at reading their (simplistic) API. I don't really have a way of testing it though. Cheers!
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
dataModule/src/main/java/com/mobnetic/coinguardian/model/market/CoinsTH.java
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,40 @@ | ||
package com.mobnetic.coinguardian.model.market.example; | ||
|
||
import java.util.HashMap; | ||
import java.util.LinkedHashMap; | ||
import org.json.JSONObject; | ||
|
||
import com.mobnetic.coinguardian.model.CheckerInfo; | ||
import com.mobnetic.coinguardian.model.Market; | ||
import com.mobnetic.coinguardian.model.Ticker; | ||
import com.mobnetic.coinguardian.model.currency.Currency; | ||
import com.mobnetic.coinguardian.model.currency.VirtualCurrency; | ||
|
||
public class CoinsTH extends Market { | ||
|
||
private final static String NAME = "Coins.TH"; | ||
private final static String TTS_NAME = NAME; | ||
private final static String URL = "https://coins.co.th/api/v1/quote"; | ||
private final static HashMap<String, CharSequence[]> CURRENCY_PAIRS = new LinkedHashMap<String, CharSequence[]>(); | ||
static { | ||
CURRENCY_PAIRS.put(VirtualCurrency.BTC, new String[]{ | ||
Currency.THB | ||
}); | ||
} | ||
|
||
public MarketExample() { | ||
super(NAME, TTS_NAME, CURRENCY_PAIRS); | ||
} | ||
|
||
@Override | ||
public String getUrl(int requestId, CheckerInfo checkerInfo) { | ||
return String.format(URL, checkerInfo.getCurrencyBase(), checkerInfo.getCurrencyCounter()); | ||
} | ||
|
||
@Override | ||
protected void parseTickerFromJsonObject(int requestId, JSONObject jsonObject, Ticker ticker, CheckerInfo checkerInfo) throws Exception { | ||
ticker.bid = jsonObject.getJsonObject("quote").getDouble("bid"); | ||
ticker.ask = jsonObject.getJsonObject("quote").getDouble("ask"); | ||
ticker.last = jsonObject.getJsonObject("quote").getDouble("ask"); | ||
} | ||
} |