Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coins TH support? #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
}