fromJson static method

CallResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallResponse? 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 "CallResponse[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "CallResponse[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return CallResponse(
      backstage: mapValueOfType<bool>(json, r'backstage')!,
      blockedUserIds: json[r'blocked_user_ids'] is Iterable
          ? (json[r'blocked_user_ids'] as Iterable).cast<String>().toList(growable: false)
          : const [],
      cid: mapValueOfType<String>(json, r'cid')!,
      createdAt: mapDateTime(json, r'created_at', r'')!,
      createdBy: UserResponse.fromJson(json[r'created_by'])!,
      currentSessionId: mapValueOfType<String>(json, r'current_session_id')!,
      custom: mapCastOfType<String, Object>(json, r'custom')!,
      egress: EgressResponse.fromJson(json[r'egress'])!,
      endedAt: mapDateTime(json, r'ended_at', r''),
      id: mapValueOfType<String>(json, r'id')!,
      ingress: CallIngressResponse.fromJson(json[r'ingress'])!,
      joinAheadTimeSeconds: mapValueOfType<int>(json, r'join_ahead_time_seconds'),
      recording: mapValueOfType<bool>(json, r'recording')!,
      session: CallSessionResponse.fromJson(json[r'session']),
      settings: CallSettingsResponse.fromJson(json[r'settings'])!,
      startsAt: mapDateTime(json, r'starts_at', r''),
      team: mapValueOfType<String>(json, r'team'),
      thumbnails: ThumbnailResponse.fromJson(json[r'thumbnails']),
      transcribing: mapValueOfType<bool>(json, r'transcribing')!,
      type: mapValueOfType<String>(json, r'type')!,
      updatedAt: mapDateTime(json, r'updated_at', r'')!,
    );
  }
  return null;
}