Public Access
feat(api_handler): properly return more types for API requests
This commit is contained in:
+29
-14
@@ -67,9 +67,12 @@ class ApiHandler {
|
||||
);
|
||||
final httpPackageJson =
|
||||
json.decode(jsonResponse.body) as Map<String, dynamic>;
|
||||
final stationList = httpPackageJson["stopLocationOrCoordLocation"].map(
|
||||
(x) => Station.fromJson(x["StopLocation"]),
|
||||
);
|
||||
final stationList = httpPackageJson["stopLocationOrCoordLocation"]
|
||||
.map(
|
||||
(x) => Station.fromJson(x["StopLocation"]),
|
||||
)
|
||||
.toList()
|
||||
.cast<Station>();
|
||||
return stationList;
|
||||
}
|
||||
|
||||
@@ -139,13 +142,16 @@ class ApiHandler {
|
||||
);
|
||||
final httpPackageJson =
|
||||
json.decode(jsonResponse.body) as Map<String, dynamic>;
|
||||
List<Departure> departureList = httpPackageJson["Departure"].map(
|
||||
(x) => Departure.fromJson(x),
|
||||
);
|
||||
List<Departure> departureList = httpPackageJson["Departure"]
|
||||
.map(
|
||||
(x) => Departure.fromJson(x),
|
||||
)
|
||||
.toList()
|
||||
.cast<Departure>();
|
||||
return departureList;
|
||||
}
|
||||
|
||||
static Future<List<String>> trip(
|
||||
static Future<List<Segment>> trip(
|
||||
String originId,
|
||||
String destinationId, {
|
||||
String? via,
|
||||
@@ -179,13 +185,17 @@ class ApiHandler {
|
||||
);
|
||||
final httpPackageJson =
|
||||
json.decode(jsonResponse.body) as Map<String, dynamic>;
|
||||
final idList = httpPackageJson["Trip"].map(
|
||||
(x) => x["LegList"]["Leg"].map((y) => y["JourneyDetail"]["ref"]),
|
||||
);
|
||||
return idList;
|
||||
// TODO: here lurk problems - do we get a list of list of segments? can't cast it–
|
||||
// what do we want from this?
|
||||
List<Segment> SegmentList = httpPackageJson["Trip"]
|
||||
.map(
|
||||
(x) => x["LegList"]["Leg"].map((y) => Segment.fromJson(y)),
|
||||
)
|
||||
.toList();
|
||||
return SegmentList;
|
||||
}
|
||||
|
||||
static Future<List<String>> tripDetail(
|
||||
static Future<List<Departure>> tripDetail(
|
||||
String id, {
|
||||
String? date,
|
||||
String? fromId,
|
||||
@@ -206,7 +216,12 @@ class ApiHandler {
|
||||
);
|
||||
final httpPackageJson =
|
||||
json.decode(jsonResponse.body) as Map<String, dynamic>;
|
||||
final idList = httpPackageJson["Stops"]["Stop"].map((x) => x["id"]);
|
||||
return idList;
|
||||
final DepartureList = httpPackageJson["Stops"]["Stop"]
|
||||
.map(
|
||||
(x) => Departure.fromJson(x),
|
||||
)
|
||||
.toList()
|
||||
.cast<Departure>();
|
||||
return DepartureList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user