All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.pvanassen.steam.store.marketpage.Wallet Maven / Gradle / Ivy

Go to download

A Java API to access the Steam community market through the HTTP interface. This may be against the TOS so be careful using it!

There is a newer version: 3.0.8
Show newest version
package nl.pvanassen.steam.store.marketpage;

import nl.pvanassen.steam.store.helper.AmountHelper;
import nl.pvanassen.steam.store.xpath.XPathHelper;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;

import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;

class Wallet {
    private static final XPathExpression WALLET_XPATH = XPathHelper.getXpathExpression("//SPAN[@id='marketWalletBalanceAmount']");

    private Wallet() {

    }

    static int getWallet(Document document) throws XPathExpressionException {
        int wallet = 0;
        Node walletNode = (Node) WALLET_XPATH.evaluate(document, XPathConstants.NODE);
        if (walletNode != null) {
            wallet = AmountHelper.getAmount(walletNode.getTextContent().trim());
        }
        else {
            LoggerFactory.getLogger(Wallet.class).error("Wallet node is null!");
        }
        if (wallet == 0) {
            LoggerFactory.getLogger(Wallet.class).error("No cash in this account, that's weird?");
        }
        return wallet;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy