|
2 | 2 |
|
3 | 3 | import java.io.File; |
4 | 4 | import java.io.IOException; |
| 5 | +import java.util.Currency; |
5 | 6 | import java.util.List; |
6 | 7 |
|
7 | | -import org.api.cardtrader.tools.URLCallInfo; |
| 8 | +import org.apache.http.client.methods.HttpRequestBase; |
| 9 | +import org.api.manapool.listener.URLCallInfo; |
8 | 10 | import org.api.manapool.model.EnumCondition; |
9 | 11 | import org.api.manapool.model.EnumFinish; |
10 | 12 | import org.api.manapool.model.EnumLangages; |
|
16 | 18 | import org.magic.api.beans.technical.audit.NetworkInfo; |
17 | 19 | import org.magic.api.interfaces.abstracts.AbstractCardExport; |
18 | 20 | import org.magic.api.interfaces.abstracts.AbstractTechnicalServiceManager; |
| 21 | +import org.magic.services.MTGControler; |
19 | 22 |
|
20 | 23 | public class ManaPoolExport extends AbstractCardExport { |
21 | 24 |
|
@@ -62,24 +65,36 @@ public String getVersion() { |
62 | 65 | public void exportStock(List<MTGCardStock> stock, File f) throws IOException { |
63 | 66 |
|
64 | 67 | var inventoryManager = new InventoryService(getAuthenticator().get("EMAIL"), getAuthenticator().get("TOKEN")); |
65 | | -// inventoryManager.setListener((URLCallInfo callInfo)->{ |
66 | | -// var netinfo = new NetworkInfo(); |
67 | | -// netinfo.setEnd(callInfo.getEnd()); |
68 | | -// netinfo.setStart(callInfo.getStart()); |
69 | | -// netinfo.setRequest(callInfo.getRequest()); |
70 | | -// netinfo.setReponse(callInfo.getResponse()); |
71 | | -// |
72 | | -// AbstractTechnicalServiceManager.inst().store(netinfo); |
73 | | -// |
74 | | -// }); |
| 68 | + inventoryManager.getClient().setCallListener((URLCallInfo callInfo)->{ |
| 69 | + var netinfo = new NetworkInfo(); |
| 70 | + netinfo.setEnd(callInfo.getEnd()); |
| 71 | + netinfo.setStart(callInfo.getStart()); |
| 72 | + netinfo.setRequest((HttpRequestBase)callInfo.getRequest()); |
| 73 | + netinfo.setReponse(callInfo.getResponse()); |
| 74 | + |
| 75 | + AbstractTechnicalServiceManager.inst().store(netinfo); |
| 76 | + |
| 77 | + }); |
75 | 78 |
|
76 | 79 | var items = stock.stream().map(mcs->{ |
77 | 80 |
|
78 | 81 | var item = new ProductQueryEntry(); |
79 | 82 | item.setScryfallId(mcs.getProduct().getScryfallId()); |
80 | 83 | item.setQuantity(mcs.getQte()); |
81 | | - item.setPrice(mcs.getValue().doubleValue()); |
82 | | - item.setCondition( EnumCondition.valueOf(aliases.getConditionFor(this, mcs.getCondition()))); |
| 84 | + |
| 85 | + if(MTGControler.getInstance().getCurrencyService().isEnable()) |
| 86 | + item.setPrice(MTGControler.getInstance().getCurrencyService().convertTo(Currency.getInstance("USD"), mcs.getValue().doubleValue())); |
| 87 | + else |
| 88 | + item.setPrice(mcs.getValue().doubleValue()); |
| 89 | + |
| 90 | + try { |
| 91 | + item.setCondition( EnumCondition.valueOf(aliases.getConditionFor(this, mcs.getCondition()))); |
| 92 | + } |
| 93 | + catch(IllegalArgumentException _) |
| 94 | + { |
| 95 | + logger.warn("EnumCondition {} is not found",mcs.getCondition().name() ); |
| 96 | + item.setCondition(EnumCondition.NM); |
| 97 | + } |
83 | 98 | item.setFinishId(mcs.isFoil()?EnumFinish.FO:EnumFinish.NF); |
84 | 99 | item.setLanguage(EnumLangages.FR); |
85 | 100 |
|
|
0 commit comments