Cleanup
This commit is contained in:
@@ -33,6 +33,7 @@ public class OfferIdentifier {
|
||||
for (ProductCatalogue pCat : pCats) {
|
||||
|
||||
// Call price finder for all catalogue
|
||||
try {
|
||||
ProductPair pair = getHighestMarginProducts(pCat);
|
||||
Offer possibleOffer = new Offer();
|
||||
possibleOffer.setLastUpdate(Timestamp.now());
|
||||
@@ -48,6 +49,9 @@ public class OfferIdentifier {
|
||||
pair.getProduct1().getDataOrigin(),
|
||||
pair.getProduct2().getDataOrigin(),
|
||||
marginFormatted);
|
||||
} catch (InvalidOfferException e) {
|
||||
// Don't include offer if deemed invalid
|
||||
}
|
||||
}
|
||||
|
||||
return identifiedOffers;
|
||||
|
||||
@@ -10,7 +10,6 @@ import de.rwu.easydrop.api.client.PurchaserFactory;
|
||||
import de.rwu.easydrop.api.client.SellerFactory;
|
||||
import de.rwu.easydrop.data.connector.OfferPersistenceInterface;
|
||||
import de.rwu.easydrop.model.Offer;
|
||||
import de.rwu.easydrop.model.Webshop;
|
||||
import de.rwu.easydrop.service.mapping.ProductMapper;
|
||||
import de.rwu.easydrop.service.writer.OfferWriter;
|
||||
import de.rwu.easydrop.util.FormattingUtil;
|
||||
@@ -51,15 +50,13 @@ public class OfferProvisioner {
|
||||
* @param offer
|
||||
*/
|
||||
private void toSeller(final Offer offer) throws IllegalArgumentException {
|
||||
if (offer.getTargetProduct().getDataOrigin() == Webshop.EBAY) {
|
||||
this.ebaySeller.sellProduct(ProductMapper.mapProductToDTO(offer.getTargetProduct()));
|
||||
|
||||
} else if (offer.getTargetProduct().getDataOrigin().equals(Webshop.AMAZON)) {
|
||||
this.amazonSeller.sellProduct(ProductMapper.mapProductToDTO(offer.getTargetProduct()));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported target plattform");
|
||||
switch (offer.getTargetProduct().getDataOrigin()) {
|
||||
case EBAY -> this.ebaySeller.sellProduct(
|
||||
ProductMapper.mapProductToDTO(offer.getTargetProduct()));
|
||||
case AMAZON -> this.amazonSeller.sellProduct(
|
||||
ProductMapper.mapProductToDTO(offer.getTargetProduct()));
|
||||
default -> throw new IllegalArgumentException("Unsupported source plattform");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,17 +65,13 @@ public class OfferProvisioner {
|
||||
* @param offer
|
||||
*/
|
||||
private void toBuyer(final Offer offer) throws IllegalArgumentException {
|
||||
if (offer.getSourceProduct().getDataOrigin() == Webshop.EBAY) {
|
||||
this.ebayPurchaser.purchaseProduct(
|
||||
switch (offer.getSourceProduct().getDataOrigin()) {
|
||||
case EBAY -> ebayPurchaser.purchaseProduct(
|
||||
ProductMapper.mapProductToDTO(offer.getSourceProduct()));
|
||||
|
||||
} else if (offer.getTargetProduct().getDataOrigin().equals(Webshop.AMAZON)) {
|
||||
this.amazonPurchaser.purchaseProduct(
|
||||
case AMAZON -> amazonPurchaser.purchaseProduct(
|
||||
ProductMapper.mapProductToDTO(offer.getSourceProduct()));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported target plattform");
|
||||
default -> throw new IllegalArgumentException("Unsupported target plattform");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -93,13 +93,9 @@ public class ProductRetriever {
|
||||
* @return Product from that data source or null if data source not available
|
||||
*/
|
||||
public Product getProductFromWebshop(final Webshop shop, final String productIdentifier) {
|
||||
switch (shop) {
|
||||
case AMAZON:
|
||||
return getProductFromAmazon(productIdentifier);
|
||||
case EBAY:
|
||||
return getProductFromEbay(productIdentifier);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (shop) {
|
||||
case AMAZON -> getProductFromAmazon(productIdentifier);
|
||||
case EBAY -> getProductFromEbay(productIdentifier);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user