32 lines
781 B
Dart
32 lines
781 B
Dart
import 'dart:convert';
|
|
|
|
import '../../connect_api.dart';
|
|
import '../rmv_models.dart';
|
|
import '_query_format.dart';
|
|
|
|
class SearchTrips extends ConnectApi<TripSearchResult> {
|
|
final String fromStopId;
|
|
final String toStopId;
|
|
final DateTime? when;
|
|
final bool searchByArrival;
|
|
|
|
SearchTrips({
|
|
required this.fromStopId,
|
|
required this.toStopId,
|
|
this.when,
|
|
this.searchByArrival = false,
|
|
}) : super('rmv/trips');
|
|
|
|
@override
|
|
Map<String, String>? get queryParameters => {
|
|
'from': fromStopId,
|
|
'to': toStopId,
|
|
if (when != null) 'when': formatLocalDateTime(when!),
|
|
'searchByArrival': searchByArrival.toString(),
|
|
};
|
|
|
|
@override
|
|
TripSearchResult assemble(String raw) =>
|
|
TripSearchResult.fromJson(jsonDecode(raw) as Map<String, dynamic>);
|
|
}
|