Search in sources :

Example 1 with CartServices

use of org.api.mkm.services.CartServices in project MtgDesktopCompanion by nicho92.

the class MagicCardMarketPricer2 method alertDetected.

@Override
public void alertDetected(final List<MagicPrice> p) {
    ThreadManager.getInstance().execute(() -> {
        if (!p.isEmpty() && getString("AUTOMATIC_ADD_CARD_ALERT").equals("true")) {
            CartServices cart = new CartServices();
            try {
                List<Article> list = new ArrayList<>();
                for (MagicPrice mp : p) {
                    Article a = (Article) mp.getShopItem();
                    a.setCount(1);
                    list.add(a);
                }
                boolean res = cart.addArticles(list);
                logger.info("add " + list + " to card :" + res);
            } catch (Exception e) {
                logger.error("Could not add " + p + " to cart", e);
            }
        }
    }, "addCart");
}
Also used : CartServices(org.api.mkm.services.CartServices) MagicPrice(org.magic.api.beans.MagicPrice) Article(org.api.mkm.modele.Article) ArrayList(java.util.ArrayList) IOException(java.io.IOException) MkmException(org.api.mkm.exceptions.MkmException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 MkmException (org.api.mkm.exceptions.MkmException)1 Article (org.api.mkm.modele.Article)1 CartServices (org.api.mkm.services.CartServices)1 MagicPrice (org.magic.api.beans.MagicPrice)1