fromJson static method
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;
}