fromJson static method
Returns a new Contact instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Contact? 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'id'), 'Required key "Contact[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "Contact[id]" has a null value in JSON.');
return true;
}());
return Contact(
id: mapValueOfType<String>(json, r'id')!,
userId: mapValueOfType<String>(json, r'user_id'),
organizationId: mapValueOfType<String>(json, r'organization_id'),
firstName: mapValueOfType<String>(json, r'first_name'),
lastName: mapValueOfType<String>(json, r'last_name'),
email: mapValueOfType<String>(json, r'email'),
phone: mapValueOfType<String>(json, r'phone'),
company: mapValueOfType<String>(json, r'company'),
title: mapValueOfType<String>(json, r'title'),
notes: mapValueOfType<String>(json, r'notes'),
scope: mapValueOfType<String>(json, r'scope'),
provider: mapValueOfType<String>(json, r'provider'),
metadata: mapCastOfType<String, Object>(json, r'metadata') ?? const {},
createdAt: mapDateTime(json, r'created_at', r''),
updatedAt: mapDateTime(json, r'updated_at', r''),
);
}
return null;
}