import 'package:dio/dio.dart' hide Headers;

import 'package:retrofit/retrofit.dart';
import '../models/common/base_structure_result.dart';
import '../models/meeting_room_info.dart';
import '../models/meeting_room_item.dart';
import '../models/meeting_room_user.dart';
import '../models/user_info_entity.dart';

part 'retrofit_client.g.dart';

@RestApi(parser: Parser.JsonSerializable)
@Headers(<String, dynamic>{"Content-Type": "application/json"})
abstract class RetrofitClient {
  factory RetrofitClient(Dio dio, {String? baseUrl}) = _RetrofitClient;

  /// 账号密码登录
  @POST("/auth/login")
  Future<BaseStructureResult<UserInfoEntity>> login(
      @Field("account") String account,
      @Field("pwd") String pwd
      );

  /// 会议号昵称登录
  @POST("/auth/anon-login")
  Future<BaseStructureResult<UserInfoEntity>> anonLogin(
      @Field("deviceId") String deviceId,
      @Field("nickName") String nickName,
      @Field("roomNum") String roomNum
      );

  /// 获取会议列表
  @GET("/home/room")
  Future<BaseStructureResult<MeetingRoomItem>> getMeetingRoomList(
      @Query("PageIndex") int PageIndex,
      @Query("PageSize") int PageSize,
      );

  /// 获取会议室信息
  @GET("/room/{roomNum}")
  Future<BaseStructureResult<MeetingRoomInfo>> getMeetingRoomInfo(
      @Path("roomNum") String roomNum,
      );

  /// 检验房间是否存在
  @GET("/room/checkout")
  Future<BaseStructureResult<bool>> checkout(
      @Query("roomNum") String roomNum,
      );

  /// 获取会议室所有用户
  @GET("/room/user")
  Future<BaseStructureResult<List<MeetingRoomUser>>> getMeetingRoomAllUser(
      @Query("roomNum") String roomNum,
      );

  /// 获取会议室Token
  @GET("/room/tk/rtc")
  Future<BaseStructureResult<String>> getMeetingToken(
      @Query("roomNum") String roomNum,
      );

  /// 申请发言
  @GET("/room/apply-speak")
  Future<BaseStructureResult> applySpeak(
      @Query("roomNum") String roomNum,
      );

  /// 结束发言
  @DELETE("/room/manager")
  Future<BaseStructureResult> cancelSpeak(
      @Field("roomId") String roomId,
      @Field("roomNum") String roomNum,
      @Field("userId") String userId,
      );

  /// 获取当前全员观看视频主播
  @GET("/room/show-user")
  Future<BaseStructureResult<String>> getTvAnchor(
      @Query("roomNum") String roomNum,
      );

  /// 设置当前全员观看视频主播
  @POST("/room/show-user")
  Future<BaseStructureResult> setTvAnchor(
      @Query("roomNum") String roomNum,
      @Query("uid") String uid,
      @Query("uname") String uname,
      );

  /// 用户开闭麦
  @GET("/room/oper-micr")
  Future<BaseStructureResult<String>> setMicr(
      @Query("roomNum") String roomNum,
      @Query("enableMicr") bool enableMicr,
      @Query("uid") String uid,
      );

  /// 用户开闭摄像头
  @GET("/room/oper-camera")
  Future<BaseStructureResult<String>> setCamera(
      @Query("roomNum") String roomNum,
      @Query("enableCamera") bool enableCamera,
      @Query("uid") String uid,
      );

  /// 刷新登录Token
  @POST("/auth/refresh")
  Future<BaseStructureResult<UserInfoEntity>> refreshToken(
      @Query("refreshToken") String refreshToken,
      );
}
