fromJson static method
Returns a new Connection instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Connection? 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 "Connection[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Connection[$key]" has a null value in JSON.');
});
return true;
}());
return Connection(
connectionId: mapValueOfType<String>(json, r'connection_id'),
userId: mapValueOfType<String>(json, r'user_id'),
engineId: mapValueOfType<String>(json, r'engine_id')!,
companyId: mapValueOfType<String>(json, r'company_id')!,
credentialType: mapValueOfType<String>(json, r'credential_type'),
apiProvider: mapValueOfType<String>(json, r'api_provider'),
apiEndpoint: mapValueOfType<String>(json, r'api_endpoint'),
apiKeyLocation: mapValueOfType<String>(json, r'api_key_location'),
apiKeyParam: mapValueOfType<String>(json, r'api_key_param'),
apiKeyValue: mapValueOfType<String>(json, r'api_key_value'),
visibility: mapValueOfType<String>(json, r'visibility')!,
name: mapValueOfType<String>(json, r'name'),
description: mapValueOfType<String>(json, r'description'),
gcpSecretId: mapValueOfType<String>(json, r'gcp_secret_id'),
providerDomain: mapValueOfType<String>(json, r'provider_domain'),
verifiedUsageAbility: mapValueOfType<String>(json, r'verified_usage_ability'),
dateCreated: mapValueOfType<String>(json, r'date_created'),
lastUpdated: mapValueOfType<String>(json, r'last_updated'),
active: mapValueOfType<String>(json, r'active'),
);
}
return null;
}