import 'package:fis_jsonrpc/rpc.dart';

import 'consultation_member.dart';

class LiveConsultation {
  ///会诊编码
  String? consultationCode;

  ///发起人编码
  String? initiatorCode;

  ///用户编码
  String? userCode;

  ///房间号
  int roomNo;

  ///sdk app id
  int appId;

  ///用户签名
  String? userSign;

  ///设备成员or用户成员列表
  List<ConsultationMember>? memberLiveDatas;

  ///操作者
  LiveConsultationMember? operator;

  /// 互动白板数据集合
  List<InteractiveBoardDataDTO>? interactiveBoardDatas;

  LiveConsultation({
    this.consultationCode,
    this.initiatorCode = '',
    this.userCode = '',
    this.roomNo = 0,
    this.appId = 0,
    this.userSign,
    this.memberLiveDatas,
    this.operator,
    this.interactiveBoardDatas,
  });

  ///dto转为memberLiveDatas
  List<ConsultationMember> consultationMemberConvert(
      List<LiveConsultationMember> liveConsultationMembers) {
    List<ConsultationMember> memberLiveDatas = [];
    for (var member in liveConsultationMembers) {
      memberLiveDatas.add(ConsultationMember.fromDto(member)
          .fixMergedVideoOutputSize()
          .fixOnlyCamera());
    }
    this.memberLiveDatas = memberLiveDatas;
    return memberLiveDatas;
  }

  Map<String, dynamic> toJson() {
    final map = Map<String, dynamic>();
    if (consultationCode != null) map['consultationCode'] = consultationCode;
    if (userCode != null) map['userCode'] = userCode;
    map['roomNo'] = roomNo;
    map['appId'] = appId;
    if (userCode != null) {
      map['userCode'] = userCode;
    }
    if (userSign != null) map['userSign'] = userSign;
    if (memberLiveDatas != null) map['memberLiveDatas'] = memberLiveDatas;
    return map;
  }
}
