fromJson static method
Returns a new ValidationResponse instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ValidationResponse? 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 "ValidationResponse[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "ValidationResponse[$key]" has a null value in JSON.');
});
return true;
}());
return ValidationResponse(
schemaVersion: mapValueOfType<String>(json, r'schema_version')!,
email: mapValueOfType<String>(json, r'email')!,
status: ValidationResponseStatusEnum.fromJson(json[r'status'])!,
action: ValidationResponseActionEnum.fromJson(json[r'action'])!,
subStatus: ValidationResponseSubStatusEnum.fromJson(json[r'sub_status']),
domain: mapValueOfType<String>(json, r'domain')!,
mxFound: mapValueOfType<bool>(json, r'mx_found')!,
mxHost: mapValueOfType<String>(json, r'mx_host'),
smtpCheck: mapValueOfType<bool>(json, r'smtp_check'),
catchAll: mapValueOfType<bool>(json, r'catch_all'),
disposable: mapValueOfType<bool>(json, r'disposable')!,
roleAccount: mapValueOfType<bool>(json, r'role_account')!,
freeProvider: mapValueOfType<bool>(json, r'free_provider')!,
depth: ValidationResponseDepthEnum.fromJson(json[r'depth'])!,
processedAt: mapDateTime(json, r'processed_at', r'')!,
suggestedEmail: mapValueOfType<String>(json, r'suggested_email'),
retryAfterMs: mapValueOfType<int>(json, r'retry_after_ms'),
suppressionMatch: ValidationResponseSuppressionMatch.fromJson(json[r'suppression_match']),
policyApplied: ValidationResponsePolicyApplied.fromJson(json[r'policy_applied']),
);
}
return null;
}