simplify: dedupe boilerplate and remove dead code across all layers
This commit is contained in:
+5
-10
@@ -13,14 +13,9 @@ class TimetableGetElementWeek extends MarianumConnectQuery {
|
||||
required int id,
|
||||
required DateTime from,
|
||||
required DateTime until,
|
||||
}) => guard(() async {
|
||||
final response = await dio.get<Map<String, dynamic>>(
|
||||
endpoint('timetable/${type.pathSegment}/$id'),
|
||||
queryParameters: {'from': _format(from), 'until': _format(until)},
|
||||
);
|
||||
return TimetableGetWeekResponse.fromJson(response.data!);
|
||||
});
|
||||
|
||||
String _format(DateTime d) =>
|
||||
'${d.year.toString().padLeft(4, '0')}-${d.month.toString().padLeft(2, '0')}-${d.day.toString().padLeft(2, '0')}';
|
||||
}) => getObject(
|
||||
'timetable/${type.pathSegment}/$id',
|
||||
TimetableGetWeekResponse.fromJson,
|
||||
queryParameters: {'from': isoDate(from), 'until': isoDate(until)},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user