Search in sources :

Example 11 with Storable

use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.

the class Helpers method getNYMOffer.

public static OfferListNym getNYMOffer(String serverID, String nymID) {
    OfferListNym offerListNym = null;
    Storable storable = null;
    if (otapi.Exists("nyms", serverID, "offers", nymID + ".bin")) {
        storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_OFFER_LIST_NYM, "nyms", serverID, "offers", nymID + ".bin");
        if (storable == null) {
            return null;
        }
        offerListNym = OfferListNym.ot_dynamic_cast(storable);
    } else {
        storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_OFFER_LIST_NYM);
        if (storable == null) {
            return null;
        }
        offerListNym = OfferListNym.ot_dynamic_cast(storable);
    }
    return offerListNym;
}
Also used : OfferListNym(org.opentransactions.otapi.OfferListNym) Storable(org.opentransactions.otapi.Storable)

Example 12 with Storable

use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.

the class Helpers method getMarketTradeList.

public static TradeListMarket getMarketTradeList(String serverID, String marketID) {
    TradeListMarket tradeListMarket = null;
    Storable storable = null;
    if (otapi.Exists("markets", serverID, "recent", marketID + ".bin")) {
        storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_TRADE_LIST_MARKET, "markets", serverID, "recent", marketID + ".bin");
        if (storable == null) {
            return null;
        }
        tradeListMarket = TradeListMarket.ot_dynamic_cast(storable);
    } else {
        storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_TRADE_LIST_MARKET);
        if (storable == null) {
            return null;
        }
        tradeListMarket = TradeListMarket.ot_dynamic_cast(storable);
    }
    return tradeListMarket;
}
Also used : Storable(org.opentransactions.otapi.Storable) TradeListMarket(org.opentransactions.otapi.TradeListMarket)

Example 13 with Storable

use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.

the class Helpers method getWalletData.

public static WalletData getWalletData() {
    WalletData walletData = null;
    Storable storable = null;
    if (otapi.Exists("moneychanger", "gui_wallet.dat")) {
        storable = otapi.QueryObject(StoredObjectType.STORED_OBJ_WALLET_DATA, "moneychanger", "gui_wallet.dat");
        if (storable == null) {
            return null;
        }
        walletData = WalletData.ot_dynamic_cast(storable);
    } else {
        storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_WALLET_DATA);
        if (storable == null) {
            return null;
        }
        walletData = WalletData.ot_dynamic_cast(storable);
    }
    return walletData;
}
Also used : WalletData(org.opentransactions.otapi.WalletData) Storable(org.opentransactions.otapi.Storable)

Example 14 with Storable

use of org.opentransactions.otapi.Storable in project otapij by FellowTraveler.

the class AddressBookHelper method createContact.

public static String createContact(String name, String email, String publicKey, String memo) {
    String contactID = "error";
    System.out.println("in createContact");
    AddressBook addressBook = Helpers.getAddressBook();
    if (addressBook == null) {
        System.out.println("createContact - addressBook returns null");
        return contactID;
    }
    System.out.println("in createContact,addressBook:" + addressBook);
    Storable storable = otapi.CreateObject(StoredObjectType.STORED_OBJ_CONTACT);
    System.out.println("in createContact, storable:" + storable);
    if (storable != null) {
        Contact contact = Contact.ot_dynamic_cast(storable);
        System.out.println("contact:" + contact);
        if (contact != null) {
            contact.setContact_id(Helpers.generateID());
            contact.setEmail(email);
            contact.setGui_label(name);
            contact.setMemo(memo);
            contact.setPublic_key(publicKey);
            boolean status = addressBook.AddContact(contact);
            System.out.println("status addressBook.AddContact:" + status);
            if (!status) {
                return contactID;
            }
            status = otapi.StoreObject(addressBook, "moneychanger", "gui_contacts.dat");
            System.out.println("status addressBook otapi.StoreObject:" + status);
            if (!status) {
                return contactID;
            }
            contactID = Helpers.generateID();
        }
    }
    return contactID;
}
Also used : AddressBook(org.opentransactions.otapi.AddressBook) Storable(org.opentransactions.otapi.Storable) Contact(org.opentransactions.otapi.Contact)

Aggregations

Storable (org.opentransactions.otapi.Storable)14 AddressBook (org.opentransactions.otapi.AddressBook)4 Contact (org.opentransactions.otapi.Contact)3 WalletData (org.opentransactions.otapi.WalletData)3 StringMap (org.opentransactions.otapi.StringMap)2 OTAPI_Func (com.moneychanger.core.util.OTAPI_Func)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BitcoinServer (org.opentransactions.otapi.BitcoinServer)1 ContactAcct (org.opentransactions.otapi.ContactAcct)1 ContactNym (org.opentransactions.otapi.ContactNym)1 MarketList (org.opentransactions.otapi.MarketList)1 OfferListMarket (org.opentransactions.otapi.OfferListMarket)1 OfferListNym (org.opentransactions.otapi.OfferListNym)1 RippleServer (org.opentransactions.otapi.RippleServer)1 ServerInfo (org.opentransactions.otapi.ServerInfo)1 TradeListMarket (org.opentransactions.otapi.TradeListMarket)1 TradeListNym (org.opentransactions.otapi.TradeListNym)1