fromJson static method

CallRecordingStoppedEvent? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallRecordingStoppedEvent? 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_cid'),
          'Required key "CallRecordingStoppedEvent[call_cid]" is missing from JSON.');
      assert(json[r'call_cid'] != null,
          'Required key "CallRecordingStoppedEvent[call_cid]" has a null value in JSON.');
      assert(json.containsKey(r'created_at'),
          'Required key "CallRecordingStoppedEvent[created_at]" is missing from JSON.');
      assert(json[r'created_at'] != null,
          'Required key "CallRecordingStoppedEvent[created_at]" has a null value in JSON.');
      assert(json.containsKey(r'egress_id'),
          'Required key "CallRecordingStoppedEvent[egress_id]" is missing from JSON.');
      assert(json[r'egress_id'] != null,
          'Required key "CallRecordingStoppedEvent[egress_id]" has a null value in JSON.');
      assert(json.containsKey(r'recording_type'),
          'Required key "CallRecordingStoppedEvent[recording_type]" is missing from JSON.');
      assert(json[r'recording_type'] != null,
          'Required key "CallRecordingStoppedEvent[recording_type]" has a null value in JSON.');
      assert(json.containsKey(r'type'),
          'Required key "CallRecordingStoppedEvent[type]" is missing from JSON.');
      assert(json[r'type'] != null,
          'Required key "CallRecordingStoppedEvent[type]" has a null value in JSON.');
      return true;
    }());

    return CallRecordingStoppedEvent(
      callCid: mapValueOfType<String>(json, r'call_cid')!,
      createdAt: mapDateTime(json, r'created_at', r'')!,
      egressId: mapValueOfType<String>(json, r'egress_id')!,
      recordingType: CallRecordingStoppedEventRecordingTypeEnum.fromJson(
          json[r'recording_type'])!,
      type: mapValueOfType<String>(json, r'type')!,
    );
  }
  return null;
}