fromJson static method

StorageEngines? fromJson(
  1. dynamic value
)

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

Implementation

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

    return StorageEngines(
      dateCreated: mapDateTime(json, r'date_created', r''),
      lastUpdated: mapDateTime(json, r'last_updated', r''),
      engineId: mapValueOfType<int>(json, r'engine_id'),
      providerId: mapValueOfType<int>(json, r'provider_id')!,
      serviceName: mapValueOfType<String>(json, r'service_name')!,
      engineType: StorageEnginesEngineTypeEnum.fromJson(json[r'engine_type'])!,
      integrationComplete: mapValueOfType<bool>(json, r'integration_complete'),
      testFuncComplete: mapValueOfType<bool>(json, r'test_func_complete'),
    );
  }
  return null;
}