import '../../marianumconnect_query.dart';
import '../timetable_get_week/timetable_get_week_response.dart';
import 'timetable_element_type.dart';

/// Fetches a foreign element's weekly timetable from
/// `timetable/{student|teacher|room|class}/{id}`. The response shape is
/// identical to `timetable/me`, so [TimetableGetWeekResponse] is reused.
class TimetableGetElementWeek extends MarianumConnectQuery {
  TimetableGetElementWeek({super.dio});

  Future<TimetableGetWeekResponse> run({
    required TimetableElementType type,
    required int id,
    required DateTime from,
    required DateTime until,
  }) => getObject(
    'timetable/${type.pathSegment}/$id',
    TimetableGetWeekResponse.fromJson,
    queryParameters: {'from': isoDate(from), 'until': isoDate(until)},
  );
}
