Skip to content

Commit

Permalink
Coins TH support?
Browse files Browse the repository at this point in the history
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
DODMax authored May 15, 2017
1 parent cb367c8 commit 92f7131
Showing 1 changed file with 40 additions and 0 deletions.
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");
}
}

0 comments on commit 92f7131

Please sign in to comment.