api
This commit is contained in:
parent
2f24e02696
commit
167a4620fe
1 changed files with 32 additions and 1 deletions
33
lib/api.dart
33
lib/api.dart
|
@ -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"];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue