CallLog.fromJson constructor

CallLog.fromJson(
  1. Map<String, dynamic> json
)

Implementation

CallLog.fromJson(Map<String, dynamic> json) {
  sessionId = json['sessionId'];
  if (json['totalAudioMinutes'] != null) {
    totalAudioMinutes = json['totalAudioMinutes'].toDouble();
  }
  if (json['totalVideoMinutes'] != null) {
    totalVideoMinutes = json['totalVideoMinutes'].toDouble();
  }
  totalDuration = json['totalDuration'];
  hasRecording = json['hasRecording'];
  if (json['initiatedAt'] != null) initiatedAt = json['initiatedAt'];
  mode = json['mode'];
  receiverType = json['receiverType'];
  status = json['status'];
  if (json['totalDurationInMinutes'] != null) {
    totalDurationInMinutes = json['totalDurationInMinutes'].toDouble();
  }
  totalParticipants = json['totalParticipants'];
  type = json['type'];
  mid = json['mid'];
  if (json['startedAt'] != null) startedAt = json['startedAt'];
  if (json['endedAt'] != null) endedAt = json['endedAt'];
  if (json['data'] != null) {
    if (json['data']['entities'] != null) {
      debugPrint(
          "json['data']['entities']['initiator']: ${json['data']['entities']['initiator']}");
      if (json['data']['entities']['initiator'] != null) {
        initiator = CallUser.fromJson(
            json['data']['entities']['initiator']['entity']);
      }
      if (receiverType == CometChatCallsConstants.receiverTypeGroup) {
        receiver = CallGroup.fromJson(
            json['data']['entities']['receiver']['entity']);
      } else {
        receiver =
            CallUser.fromJson(json['data']['entities']['receiver']['entity']);
      }
    }
  }
  if (json['participants'] != null) {
    participants = <Participants>[];
    json['participants'].forEach((v) {
      Participants p = Participants.fromJson(v);
      participants!.add(p);
    });
  }
  if (json['recordings'] != null) {
    recordings = <Recordings>[];
    json['recordings'].forEach((v) {
      recordings!.add(Recordings.fromJson(v));
    });
  }
}