From c4392eb697e507340454a8735e7b4d3bd297f5f1 Mon Sep 17 00:00:00 2001 From: Cow Date: Fri, 23 Apr 2021 14:43:24 +0200 Subject: Added Chest Tracker & Analyzer --- .../cowlection/chestTracker/HyBazaarData.java | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java (limited to 'src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java') diff --git a/src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java b/src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java new file mode 100644 index 0000000..6480244 --- /dev/null +++ b/src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java @@ -0,0 +1,61 @@ +package de.cowtipper.cowlection.chestTracker; + +import com.google.gson.annotations.SerializedName; + +import java.util.Map; + +@SuppressWarnings("unused") +public class HyBazaarData { + private boolean success; + private long lastUpdated; + @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") + private Map products; + + public boolean isSuccess() { + return success; + } + + /** + * Returns {@link Product} from bazaar reply. + * Returns null if product does not exist + * + * @param productId product in bazaar + * @return instance of Product + */ + public Product getProduct(String productId) { + return products.get(productId); + } + + /** + * Refresh only allowed once per minute + */ + public boolean allowRefreshData() { + return (System.currentTimeMillis() - lastUpdated) > 60000; + } + + public static class Product { + @SerializedName("quick_status") + private Status quickStatus; + + public double getInstantSellPrice() { + return quickStatus.getSellPrice(); + } + + public double getSellOfferPrice() { + return quickStatus.getBuyPrice(); + } + + public static class Status { + private double sellPrice; + private double buyPrice; + + public double getSellPrice() { + return sellPrice; + } + + public double getBuyPrice() { + return buyPrice; + } + } + } +} -- cgit