This commit is contained in:
JMARyA 2024-09-27 09:27:29 +02:00
parent 2f24e02696
commit 167a4620fe
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -198,7 +198,13 @@ class API {
}
// /item/<item_id>/<variant_id>/stat
Future<ItemVariantStat> getStat(String item, String variant) async {
Future<dynamic> getStat(String item, String variant,
{bool full = false}) async {
if (full) {
return FullItemVariantStat(jsonDecode(
await getRequest("$instance/item/$item/$variant/stat?full=true")));
}
return ItemVariantStat(
jsonDecode(await getRequest("$instance/item/$item/$variant/stat")));
}
@ -570,3 +576,28 @@ class GlobalItemStat {
var split = iv.split("::");
return (split[0], split[1]);
}
class FullItemVariantStat {
late int amount;
late double totalPrice;
late double expiryRate;
late Map<String, OriginStat> origins;
FullItemVariantStat(Map<String, dynamic> json) {
amount = json["amount"];
totalPrice = json["total_price"];
expiryRate = json["expiry_rate"];
origins = (json["origins"] as Map<String, dynamic>)
.map((key, value) => MapEntry(key, OriginStat(value)));
}
}
class OriginStat {
late double average_price;
late int inventory;
OriginStat(Map<String, dynamic> json) {
average_price = json["average_price"];
inventory = json["inventory"];
}
}