fromJson static method

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

Implementation

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

    return QueryCallSessionParticipantStatsTimelineResponse(
      callId: mapValueOfType<String>(json, r'call_id')!,
      callSessionId: mapValueOfType<String>(json, r'call_session_id')!,
      callType: mapValueOfType<String>(json, r'call_type')!,
      duration: mapValueOfType<String>(json, r'duration')!,
      events: CallParticipantTimeline.listFromJson(json[r'events']),
      userId: mapValueOfType<String>(json, r'user_id')!,
      userSessionId: mapValueOfType<String>(json, r'user_session_id')!,
    );
  }
  return null;
}