fromJson static method

ProgramApplication? fromJson(
  1. dynamic value
)

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

Implementation

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

    return ProgramApplication(
      company: mapValueOfType<String>(json, r'company'),
      companyId: mapValueOfType<String>(json, r'companyId'),
      contactId: mapValueOfType<String>(json, r'contactId'),
      contactName: mapValueOfType<String>(json, r'contactName'),
      createdAt: mapValueOfType<int>(json, r'createdAt'),
      email: mapValueOfType<String>(json, r'email'),
      events: StageEvent.listFromJson(json[r'events']),
      id: mapValueOfType<String>(json, r'id'),
      metadata: mapCastOfType<String, Object>(json, r'metadata') ?? const {},
      reason: mapValueOfType<String>(json, r'reason'),
      role: mapValueOfType<String>(json, r'role'),
      screen: ScreenResult.fromJson(json[r'screen']),
      stage: mapValueOfType<String>(json, r'stage'),
      tier1: mapValueOfType<bool>(json, r'tier1'),
      updatedAt: mapValueOfType<int>(json, r'updatedAt'),
      website: mapValueOfType<String>(json, r'website'),
    );
  }
  return null;
}