import 'package:app/request/dto/room/board_token_dto.dart';
import 'package:app/request/dto/room/rtc_token_dto.dart';
import 'package:app/request/network/request.dart';

import '../dto/room/room_list_item_dto.dart';

/// 获取房间列表
Future<List<RoomListItemDto>> getRoomListApi() async {
  var res = await Request().get('/study_room/get_study_room_list');
  return List<RoomListItemDto>.from(res.map((x) => RoomListItemDto.fromJson(x)));
}

///获取自习室的websocket令牌
Future<String> getWsTokenApi(int roomId) async {
  var res = await Request().get('/study_room/get_ws_token', {
    "study_room_id": roomId,
  });
  return res['token'];
}

///获取自习室的RTC令牌
Future<RtcTokenDto> getRtcTokenApi(int roomId) async {
  var res = await Request().get('/study_room/get_rtc_token', {
    "study_room_id": roomId,
  });
  return RtcTokenDto.fromJson(res);
}

///获取白板的令牌
Future<BoardTokenDto> getBoardTokenApi(int roomId) async {
  var res = await Request().get('/study_room/get_whiteboard_token', {
    "study_room_id": roomId,
  });
  return BoardTokenDto.fromJson(res);
}
