list method

Future<List<Room>> list()

Implementation

Future<List<Room>> list() async {
  var availabilitiesUrl = student.buildUrl(
      "SkemaAvanceret.aspx?type=aktuelleallelokaler&nosubnav=1&prevurl=FindSkemaAdv.aspx");
  var availabilityReq = await request(availabilitiesUrl);
  var roomAvailabilities =
      extractRoomAvailabilities(BeautifulSoup(availabilityReq.data));

  var roomsUrl = student.buildUrl("FindSkema.aspx?type=lokale");
  var roomsReq = await request(roomsUrl);
  var rooms = extractRooms(BeautifulSoup(roomsReq.data));
  var joinedRooms = rooms.map((room) {
    var roomAvailMatch = roomAvailabilities
        .where((element) => element.name == room.name)
        .firstOrNull;
    if (roomAvailMatch != null) {
      return room.copyWith(inUse: roomAvailMatch.inUse);
    }
    return room;
  }).toList();
  return joinedRooms;
}