WT 1.1.14 Tutorial, Sports, New goals
This commit is contained in:
@@ -59,16 +59,17 @@ class APIClient with Common, Logging {
|
||||
final responseCode = response.statusCode;
|
||||
if (responseCode != 200) {
|
||||
trace("authentication response: $responseCode");
|
||||
return {
|
||||
throw Exception("Network error, try again later!");
|
||||
/* return {
|
||||
"error": "Authentication error, total failure",
|
||||
};
|
||||
}; */
|
||||
}
|
||||
|
||||
final responseJson = json.decode(response.body);
|
||||
return responseJson;
|
||||
} catch (exception) {
|
||||
print(exception.toString());
|
||||
return {"error": "Network error, try again later " + exception.toString()};
|
||||
throw Exception("Network error, try again later!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/customer_activity.dart';
|
||||
import 'package:aitrainer_app/model/customer_exercise_device.dart';
|
||||
import 'package:aitrainer_app/model/customer_property.dart';
|
||||
import 'package:aitrainer_app/model/evaluation.dart';
|
||||
@@ -15,10 +16,12 @@ import 'package:aitrainer_app/model/product.dart';
|
||||
import 'package:aitrainer_app/model/product_test.dart';
|
||||
import 'package:aitrainer_app/model/property.dart';
|
||||
import 'package:aitrainer_app/model/purchase.dart';
|
||||
import 'package:aitrainer_app/model/tutorial.dart';
|
||||
import 'package:aitrainer_app/service/api.dart';
|
||||
import 'package:aitrainer_app/service/exercise_type_service.dart';
|
||||
import 'package:aitrainer_app/util/not_found_exception.dart';
|
||||
|
||||
import '../model/sport.dart';
|
||||
import 'customer_service.dart';
|
||||
import 'exercise_tree_service.dart';
|
||||
|
||||
@@ -63,6 +66,14 @@ class PackageApi {
|
||||
} else if (headRecord[0] == "Evaluation") {
|
||||
final List<Evaluation> evaluations = json.map((evaluation) => Evaluation.fromJson(evaluation)).toList();
|
||||
Cache().evaluations = evaluations;
|
||||
} else if (headRecord[0] == "Sport") {
|
||||
final List<Sport> sports = json.map((sport) => Sport.fromJson(sport)).toList();
|
||||
Cache().setSports(sports);
|
||||
} else if (headRecord[0] == "Tutorial") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<Tutorial> tutorials = json.map((tutorial) => Tutorial.fromJson(tutorial)).toList();
|
||||
print("Tutorial: $tutorials");
|
||||
Cache().setTutorials(tutorials);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,6 +156,10 @@ class PackageApi {
|
||||
return item;
|
||||
}).toList();
|
||||
// ToDo */
|
||||
} else if (headRecord[0] == "CustomerActivity") {
|
||||
final Iterable json = jsonDecode(headRecord[1]);
|
||||
final List<CustomerActivity> customerActivities = json.map((activity) => CustomerActivity.fromJson(activity)).toList();
|
||||
Cache().setCustomerActivities(customerActivities);
|
||||
}
|
||||
});
|
||||
} on NotFoundException catch (_) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/property.dart';
|
||||
import 'package:aitrainer_app/service/api.dart';
|
||||
|
||||
import '../model/property.dart';
|
||||
|
||||
class PropertyApi {
|
||||
final APIClient _client = new APIClient();
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/service/api.dart';
|
||||
|
||||
import '../model/sport.dart';
|
||||
|
||||
class SportApi {
|
||||
final APIClient _client = new APIClient();
|
||||
|
||||
Future<List<Sport>> getSports() async {
|
||||
final body = await _client.get("sports/", "");
|
||||
final Iterable json = jsonDecode(body);
|
||||
final List<Sport> sports = json.map((sport) => Sport.fromJson(sport)).toList();
|
||||
Cache().setSports(sports);
|
||||
return sports;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user