fromJson static method

GetCallStatsResponse? fromJson(
  1. dynamic value
)

Returns a new GetCallStatsResponse instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static GetCallStatsResponse? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "GetCallStatsResponse[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "GetCallStatsResponse[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return GetCallStatsResponse(
      aggregated: AggregatedStats.fromJson(json[r'aggregated']),
      callDurationSeconds: mapValueOfType<int>(json, r'call_duration_seconds')!,
      callStatus: mapValueOfType<String>(json, r'call_status')!,
      callTimeline: CallTimeline.fromJson(json[r'call_timeline']),
      duration: mapValueOfType<String>(json, r'duration')!,
      jitter: TimeStats.fromJson(json[r'jitter']),
      latency: TimeStats.fromJson(json[r'latency']),
      maxFreezesDurationSeconds: mapValueOfType<int>(json, r'max_freezes_duration_seconds')!,
      maxParticipants: mapValueOfType<int>(json, r'max_participants')!,
      maxTotalQualityLimitationDurationSeconds: mapValueOfType<int>(json, r'max_total_quality_limitation_duration_seconds')!,
      participantReport: UserStats.listFromJson(json[r'participant_report']),
      publishingParticipants: mapValueOfType<int>(json, r'publishing_participants')!,
      qualityScore: mapValueOfType<int>(json, r'quality_score')!,
      sfuCount: mapValueOfType<int>(json, r'sfu_count')!,
      sfus: SFULocationResponse.listFromJson(json[r'sfus']),
    );
  }
  return null;
}