fromJson static method

QueryCallSessionParticipantStatsResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static QueryCallSessionParticipantStatsResponse? 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'call_id'),
          'Required key "QueryCallSessionParticipantStatsResponse[call_id]" is missing from JSON.');
      assert(json[r'call_id'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[call_id]" has a null value in JSON.');
      assert(json.containsKey(r'call_session_id'),
          'Required key "QueryCallSessionParticipantStatsResponse[call_session_id]" is missing from JSON.');
      assert(json[r'call_session_id'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[call_session_id]" has a null value in JSON.');
      assert(json.containsKey(r'call_type'),
          'Required key "QueryCallSessionParticipantStatsResponse[call_type]" is missing from JSON.');
      assert(json[r'call_type'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[call_type]" has a null value in JSON.');
      assert(json.containsKey(r'counts'),
          'Required key "QueryCallSessionParticipantStatsResponse[counts]" is missing from JSON.');
      assert(json[r'counts'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[counts]" has a null value in JSON.');
      assert(json.containsKey(r'duration'),
          'Required key "QueryCallSessionParticipantStatsResponse[duration]" is missing from JSON.');
      assert(json[r'duration'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[duration]" has a null value in JSON.');
      assert(json.containsKey(r'participants'),
          'Required key "QueryCallSessionParticipantStatsResponse[participants]" is missing from JSON.');
      assert(json[r'participants'] != null,
          'Required key "QueryCallSessionParticipantStatsResponse[participants]" has a null value in JSON.');
      return true;
    }());

    return QueryCallSessionParticipantStatsResponse(
      callEndedAt: mapDateTime(json, r'call_ended_at', r''),
      callEvents: CallLevelEventPayload.listFromJson(json[r'call_events']),
      callId: mapValueOfType<String>(json, r'call_id')!,
      callSessionId: mapValueOfType<String>(json, r'call_session_id')!,
      callStartedAt: mapDateTime(json, r'call_started_at', r''),
      callType: mapValueOfType<String>(json, r'call_type')!,
      counts: CallStatsParticipantCounts.fromJson(json[r'counts'])!,
      duration: mapValueOfType<String>(json, r'duration')!,
      next: mapValueOfType<String>(json, r'next'),
      participants: CallStatsParticipant.listFromJson(json[r'participants']),
      prev: mapValueOfType<String>(json, r'prev'),
      tmpDataSource: mapValueOfType<String>(json, r'tmp_data_source'),
    );
  }
  return null;
}