fromJson static method

CallStatsParticipantCounts? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallStatsParticipantCounts? 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(() {
      assert(json.containsKey(r'live_sessions'),
          'Required key "CallStatsParticipantCounts[live_sessions]" is missing from JSON.');
      assert(json[r'live_sessions'] != null,
          'Required key "CallStatsParticipantCounts[live_sessions]" has a null value in JSON.');
      assert(json.containsKey(r'participants'),
          'Required key "CallStatsParticipantCounts[participants]" is missing from JSON.');
      assert(json[r'participants'] != null,
          'Required key "CallStatsParticipantCounts[participants]" has a null value in JSON.');
      assert(json.containsKey(r'peak_concurrent_sessions'),
          'Required key "CallStatsParticipantCounts[peak_concurrent_sessions]" is missing from JSON.');
      assert(json[r'peak_concurrent_sessions'] != null,
          'Required key "CallStatsParticipantCounts[peak_concurrent_sessions]" has a null value in JSON.');
      assert(json.containsKey(r'peak_concurrent_users'),
          'Required key "CallStatsParticipantCounts[peak_concurrent_users]" is missing from JSON.');
      assert(json[r'peak_concurrent_users'] != null,
          'Required key "CallStatsParticipantCounts[peak_concurrent_users]" has a null value in JSON.');
      assert(json.containsKey(r'publishers'),
          'Required key "CallStatsParticipantCounts[publishers]" is missing from JSON.');
      assert(json[r'publishers'] != null,
          'Required key "CallStatsParticipantCounts[publishers]" has a null value in JSON.');
      assert(json.containsKey(r'sessions'),
          'Required key "CallStatsParticipantCounts[sessions]" is missing from JSON.');
      assert(json[r'sessions'] != null,
          'Required key "CallStatsParticipantCounts[sessions]" has a null value in JSON.');
      assert(json.containsKey(r'sfus_used'),
          'Required key "CallStatsParticipantCounts[sfus_used]" is missing from JSON.');
      assert(json[r'sfus_used'] != null,
          'Required key "CallStatsParticipantCounts[sfus_used]" has a null value in JSON.');
      return true;
    }());

    return CallStatsParticipantCounts(
      averageJitterMs: mapValueOfType<int>(json, r'average_jitter_ms'),
      averageLatencyMs: mapValueOfType<int>(json, r'average_latency_ms'),
      callEventCount: mapValueOfType<int>(json, r'call_event_count'),
      cqScore: mapValueOfType<int>(json, r'cq_score'),
      liveSessions: mapValueOfType<int>(json, r'live_sessions')!,
      maxFreezesDurationMs:
          mapValueOfType<int>(json, r'max_freezes_duration_ms'),
      participants: mapValueOfType<int>(json, r'participants')!,
      peakConcurrentSessions:
          mapValueOfType<int>(json, r'peak_concurrent_sessions')!,
      peakConcurrentUsers:
          mapValueOfType<int>(json, r'peak_concurrent_users')!,
      publishers: mapValueOfType<int>(json, r'publishers')!,
      sessions: mapValueOfType<int>(json, r'sessions')!,
      sfusUsed: mapValueOfType<int>(json, r'sfus_used')!,
      totalParticipantDuration:
          mapValueOfType<int>(json, r'total_participant_duration'),
    );
  }
  return null;
}