diff options
author | Cow <cow@volloeko.de> | 2021-04-23 14:43:24 +0200 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2021-04-23 14:43:24 +0200 |
commit | c4392eb697e507340454a8735e7b4d3bd297f5f1 (patch) | |
tree | f5cc857d8b9e5c8f9032d590b456663d5ad3123b /src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java | |
parent | 35f5d00656a968a003dd42b9150c9f19b1f3c9fd (diff) | |
download | Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.tar.gz Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.tar.bz2 Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.zip |
Added Chest Tracker & Analyzer
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java')
-rw-r--r-- | src/main/java/de/cowtipper/cowlection/chestTracker/HyBazaarData.java | 61 |
1 files changed, 61 insertions, 0 deletions
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<String, Product> 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; + } + } + } +} |