fromJson static method

CallModel? fromJson(
  1. Map jsonMap,
  2. ILogsModel? logs
)

Creates instance of CallModel with values read from json

Implementation

static CallModel? fromJson(Map<dynamic, dynamic> jsonMap, ILogsModel? logs) {
  //Read required attributes
  int? myCallId_; String? accUri_, remoteExt_;
  bool? isIncoming_, hasSecureMedia_, hasVideo_;
  jsonMap.forEach((key, value) {
    if((key == 'myCallId')&&(value is int))        { myCallId_   = value; } else
    if((key == 'accUri')&&(value is String))       { accUri_     = value; } else
    if((key == 'remoteExt')&&(value is String))    { remoteExt_  = value; } else
    if((key == 'isIncoming')&&(value is bool))     { isIncoming_ = value; } else
    if((key == 'hasSecureMedia')&&(value is bool)) { hasSecureMedia_ = value;} else
    if((key == 'hasVideo')&&(value is bool))       { hasVideo_   = value; }
  });
  //Check if present
  if((myCallId_==null)||(accUri_==null)||(remoteExt_==null)||
     (isIncoming_==null)||(hasSecureMedia_==null)||(hasVideo_==null)) {
      return null;
  }

  //Create new inst
  CallModel call = CallModel(myCallId_!, accUri_!, remoteExt_!, isIncoming_!, hasSecureMedia_!, hasVideo_!, logs);

  //Read the rest values
  jsonMap.forEach((key, value) {
    if((key == 'displName')&&(value is String))    { call.displName = value;     } else
    if((key == 'receivedDtmf')&&(value is String)) { call._receivedDtmf = value; } else
    if((key == 'response')&&(value is String))     { call._response = value;     } else
    if((key == 'state')&&(value is int))           { call._state = CallState.from(value);} else
    if((key == 'holdState')&&(value is int))       { call._holdState = HoldState.from(value);} else
    if((key == 'startTime')&&(value is int))       { call._startTime = DateTime.fromMillisecondsSinceEpoch(value); }
    if((key == 'playerId')&&(value is int))        { call._playerId = value;    } else
    if((key == 'isMicMuted')&&(value is bool))     { call._isMicMuted = value;  } else
    if((key == 'isCamMuted')&&(value is bool))     { call._isCamMuted = value;  } else
    if((key == 'isRecStarted')&&(value is bool))   { call._isRecStarted = value;} else
    if((key == 'isUpgradingToVideo')&&(value is bool)) { call._isUpgradingToVideo = value;} else
    if((key == 'hasVideoUpgradeRequest')&&(value is bool)) { call._hasVideoUpgradeRequest = value;}
  });
  //Update duration
  call.calcDuration();
  return call;
}