use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class Basket method loadAsset.
public static void loadAsset(String assetTypeID, String nymID, String serverID) {
if (!Utility.VerifyStringVal(otapiJNI.OTAPI_Basic_LoadAssetContract(assetTypeID))) {
System.out.println("IN getAssetTypeName, OT_API_LoadAssetContract is null");
// ----------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_CONTRACT, serverID, nymID, assetTypeID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_CONTRACT");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN getAssetTypeName: OTAPI_Func.SendRequest(() failed. (I give up.) ");
}
}
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class CashPurseAccount method exchangeCashPurse.
public boolean exchangeCashPurse(String serverID, String assetID, String nymID, String oldPurse, ArrayList selectedTokens) throws InterruptedException {
Helpers.setObj(null);
System.out.println(" Cash Purse exchange starts, selectedTokens:" + selectedTokens);
String newPurse = processCashPurse(serverID, assetID, nymID, oldPurse, selectedTokens, nymID);
if (!Utility.VerifyStringVal(newPurse)) {
System.out.println("exchangeCashPurse: Before server OT_API_exchangePurse call, new Purse is empty.. returning false ");
return false;
}
// ------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.EXCHANGE_CASH, serverID, nymID, assetID, newPurse);
// <========================
String strResponse = OTAPI_Func.SendTransaction(theRequest, "EXCHANGE_CASH");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN exchangeCashPurse: OTAPI_Func.SendTransaction(() failed. (I give up.) ");
// -------------------
boolean importStatus = otapiJNI.OTAPI_Basic_Wallet_ImportPurse(serverID, assetID, nymID, newPurse);
System.out.println("Since failure in exchangeCashPurse, OT_API_Wallet_ImportPurse called, status of import:" + importStatus);
if (!importStatus) {
Helpers.setObj(newPurse);
}
return false;
}
// ---------------------------------------
System.out.println("exchangeCashPurse ends, status: success.");
return true;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class CashPurseAccount method depositCashPurse.
public boolean depositCashPurse(String serverID, String assetID, String nymID, String oldPurse, ArrayList selectedTokens, String accountID) {
Helpers.setObj(null);
System.out.println("depositCashPurse starts, selectedTokens:" + selectedTokens);
String recepientNymID = otapiJNI.OTAPI_Basic_GetAccountWallet_NymID(accountID);
String newPurse = processCashPurse(serverID, assetID, nymID, oldPurse, selectedTokens, recepientNymID);
if (!Utility.VerifyStringVal(newPurse)) {
System.out.println("Before server OT_API_exchangePurse call, new Purse is emtpty.. returning false ");
return false;
}
// ----------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.DEPOSIT_CASH, serverID, recepientNymID, accountID, newPurse);
// <========================
String strResponse = OTAPI_Func.SendTransaction(theRequest, "DEPOSIT_CASH");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN depositCashPurse: OTAPI_Func.SendTransaction(() failed. (I give up.) ");
// -------------------
boolean importStatus = otapiJNI.OTAPI_Basic_Wallet_ImportPurse(serverID, assetID, recepientNymID, newPurse);
System.out.println("Since failure in depositCashPurse, OT_API_Wallet_ImportPurse called, status of import:" + importStatus);
if (!importStatus) {
Helpers.setObj(newPurse);
}
return false;
}
// ---------------------------------------
System.out.println("depositCashPurse ends, status: success.");
return true;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class Market method loadMarketList.
public static Map loadMarketList(String serverID, String nymID) throws InterruptedException {
//DEBUGGING 3rd step of debugging.
Map marketListMap = new HashMap();
// ----------------------------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_LIST, serverID, nymID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MARKET_LIST");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN loadMarketList: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return null;
}
if (otapiJNI.OTAPI_Basic_Message_GetDepth(strResponse) == 0) {
System.out.println("loadMarketList - marketList returns with a OT_API_Message_GetDepth() of 0 elements.");
return marketListMap;
}
MarketList marketList = Helpers.getMarketList(serverID);
if (marketList == null) {
System.out.println("loadMarketList - marketList returns null");
return null;
}
int count = (int) marketList.GetMarketDataCount();
if (0 >= count) {
System.out.println("loadMarketList - marketList returns with a size of 0 elements.");
return null;
}
for (int i = 0; i < count; i++) {
MarketData marketData = marketList.GetMarketData(i);
if (marketData == null) {
continue;
}
if ("ALL".equalsIgnoreCase(serverID) || serverID.equals(marketData.getServer_id())) {
String[] data = new String[2];
if (Utility.VerifyStringVal(marketData.getAsset_type_id()) && Utility.VerifyStringVal(marketData.getCurrency_type_id())) {
String assetName = otapiJNI.OTAPI_Basic_GetAssetType_Name(marketData.getAsset_type_id());
String currencyName = otapiJNI.OTAPI_Basic_GetAssetType_Name(marketData.getCurrency_type_id());
if (Utility.VerifyStringVal(assetName) && Utility.VerifyStringVal(currencyName)) {
data[0] = assetName + "-" + currencyName;
}
} else {
data[0] = !Utility.VerifyStringVal(marketData.getMarket_id()) ? "" : marketData.getMarket_id();
}
//data[0] = !Utility.VerifyStringVal(marketData.getGui_label()) ? "" : marketData.getGui_label();
data[1] = !Utility.VerifyStringVal(marketData.getMarket_id()) ? "" : marketData.getMarket_id();
marketListMap.put(data[1], data);
}
}
return marketListMap;
}
use of com.moneychanger.core.util.OTAPI_Func in project otapij by FellowTraveler.
the class Market method getTicker.
public static MarketTicker getTicker(String marketID, String serverID, String nymID) {
// ----------------------------------------------------------
OTAPI_Func theRequest = new OTAPI_Func(OTAPI_Func.FT.GET_MARKET_LIST, serverID, nymID);
String strResponse = OTAPI_Func.SendRequest(theRequest, "GET_MARKET_LIST");
if (!Utility.VerifyStringVal(strResponse)) {
System.out.println("IN getTicker: OTAPI_Func.SendRequest(() failed. (I give up.) ");
return null;
}
if (otapiJNI.OTAPI_Basic_Message_GetDepth(strResponse) == 0) {
System.out.println("getTicker: OT_API_Message_GetDepth returned zero");
return null;
}
MarketList marketList = Helpers.getMarketList(serverID);
if (marketList == null) {
System.out.println("getTicker - marketList returns null");
return null;
}
int nMarketDataCount = (int) marketList.GetMarketDataCount();
for (int i = 0; i < nMarketDataCount; i++) {
MarketData marketData = marketList.GetMarketData(i);
if (marketData == null) {
continue;
}
if (!Utility.VerifyStringVal(marketID) || (Utility.VerifyStringVal(marketID) && marketID.equals(marketData.getMarket_id()))) {
MarketTicker marketTicker = new MarketTicker();
marketTicker.setLastPrice(marketData.getLast_sale_price());
marketTicker.setHighestBid(marketData.getCurrent_bid());
marketTicker.setLowestAsk(marketData.getCurrent_ask());
marketTicker.setHighPrice(marketData.getRecent_highest_bid());
marketTicker.setLowPrice(marketData.getRecent_lowest_ask());
return marketTicker;
}
}
return null;
}
Aggregations