Public Access
feat(route building): add time constraint for departure requests
This commit is contained in:
+12
-1
@@ -6,6 +6,14 @@ import 'dart:convert';
|
||||
|
||||
import 'transport_helper.dart';
|
||||
|
||||
String timeOf(DateTime fullDT) {
|
||||
// doing it this way so we always get two digits on the hour
|
||||
String full = fullDT.toString();
|
||||
List<String> splits = full.split(" ")[1].split(":");
|
||||
String time = '${splits[0]}:${splits[1]}';
|
||||
return time;
|
||||
}
|
||||
|
||||
class ApiHandler {
|
||||
// TODO: Split next line for better Error Handling
|
||||
static final String baseUrl = dotenv.get("VBB_API_URL");
|
||||
@@ -79,6 +87,7 @@ class ApiHandler {
|
||||
static Future<List<Departure>> departures(
|
||||
String stationId, {
|
||||
int? maxDepartures = -1,
|
||||
DateTime? time,
|
||||
int? duration = 0,
|
||||
}) async {
|
||||
String urlPath = '/api/fahrinfo/latest/departureBoard';
|
||||
@@ -87,7 +96,9 @@ class ApiHandler {
|
||||
Uri url = Uri.https(baseUrl, urlPath, {
|
||||
'accessId': accessID,
|
||||
'id': stationString,
|
||||
////'time': /current time //time from which departures will be shown
|
||||
'time': timeOf(
|
||||
time ?? DateTime.now(),
|
||||
), //time from which departures will be shown
|
||||
'duration': duration.toString(), //interval time in minutes
|
||||
'maxJourneys': maxDepartures.toString(),
|
||||
//'type': 'S', // Station/Stops only
|
||||
|
||||
Reference in New Issue
Block a user