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");
}
Aggregations