WT1.1.0+41 error fixing

This commit is contained in:
bossanyit
2020-12-29 13:20:35 +01:00
parent 9755cc764a
commit 2aecb9d431
22 changed files with 492 additions and 137 deletions
@@ -11,6 +11,7 @@ class CustomerExerciseDeviceApi with Logging {
Future<List<CustomerExerciseDevice>> getDevices(int customerId) async {
List<CustomerExerciseDevice> devices;
try {
log(" --- get customer_exercise_devices: ");
final body = await _client.get("customer_exercise_device/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
devices = json.map((device) => CustomerExerciseDevice.fromJson(device)).toList();
+10 -4
View File
@@ -1,6 +1,7 @@
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/purchase.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/util/not_found_exception.dart';
import 'dart:convert';
import 'api.dart';
@@ -8,10 +9,15 @@ class PurchaseApi with Logging {
final APIClient _client = new APIClient();
Future<List<Purchase>> getPurchasesByCustomer(int customerId) async {
final body = await _client.get("purchase/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
Cache().setPurchases(purchases);
List<Purchase> purchases = List();
try {
final body = await _client.get("purchase/customer/" + customerId.toString(), "");
final Iterable json = jsonDecode(body);
final List<Purchase> purchases = json.map((purchase) => Purchase.fromJson(purchase)).toList();
Cache().setPurchases(purchases);
} on NotFoundException catch (e) {
log("No purchases found");
}
return purchases;
}