import 'dart:convert';
import 'dart:developer';

import '../../webuntisApi.dart';
import 'getRoomsResponse.dart';

class GetRooms extends WebuntisApi {
  GetRooms() : super("getRooms", null);

  @override
  Future<GetRoomsResponse> run() async {
    String rawAnswer = await query(this);
    try {
      return finalize(GetRoomsResponse.fromJson(jsonDecode(rawAnswer)));
    } catch(e, trace) {
      log(trace.toString());
      log("Failed to parse getRoom data with server response: $rawAnswer");
    }

    throw Exception("Failed to parse getRoom server response");
  }

}