fromJson static method
Returns a new TenantBadge instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static TenantBadge? 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 "TenantBadge[_id]" is missing from JSON.');
assert(json[r'_id'] != null, 'Required key "TenantBadge[_id]" has a null value in JSON.');
assert(json.containsKey(r'tenantId'), 'Required key "TenantBadge[tenantId]" is missing from JSON.');
assert(json[r'tenantId'] != null, 'Required key "TenantBadge[tenantId]" has a null value in JSON.');
assert(json.containsKey(r'createdByUserId'), 'Required key "TenantBadge[createdByUserId]" is missing from JSON.');
assert(json[r'createdByUserId'] != null, 'Required key "TenantBadge[createdByUserId]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "TenantBadge[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "TenantBadge[createdAt]" has a null value in JSON.');
assert(json.containsKey(r'enabled'), 'Required key "TenantBadge[enabled]" is missing from JSON.');
assert(json[r'enabled'] != null, 'Required key "TenantBadge[enabled]" has a null value in JSON.');
assert(json.containsKey(r'type'), 'Required key "TenantBadge[type]" is missing from JSON.');
assert(json[r'type'] != null, 'Required key "TenantBadge[type]" has a null value in JSON.');
assert(json.containsKey(r'threshold'), 'Required key "TenantBadge[threshold]" is missing from JSON.');
assert(json[r'threshold'] != null, 'Required key "TenantBadge[threshold]" has a null value in JSON.');
assert(json.containsKey(r'uses'), 'Required key "TenantBadge[uses]" is missing from JSON.');
assert(json[r'uses'] != null, 'Required key "TenantBadge[uses]" has a null value in JSON.');
assert(json.containsKey(r'name'), 'Required key "TenantBadge[name]" is missing from JSON.');
assert(json[r'name'] != null, 'Required key "TenantBadge[name]" has a null value in JSON.');
assert(json.containsKey(r'description'), 'Required key "TenantBadge[description]" is missing from JSON.');
assert(json[r'description'] != null, 'Required key "TenantBadge[description]" has a null value in JSON.');
assert(json.containsKey(r'displayLabel'), 'Required key "TenantBadge[displayLabel]" is missing from JSON.');
assert(json[r'displayLabel'] != null, 'Required key "TenantBadge[displayLabel]" has a null value in JSON.');
assert(json.containsKey(r'displaySrc'), 'Required key "TenantBadge[displaySrc]" is missing from JSON.');
assert(json.containsKey(r'backgroundColor'), 'Required key "TenantBadge[backgroundColor]" is missing from JSON.');
assert(json.containsKey(r'borderColor'), 'Required key "TenantBadge[borderColor]" is missing from JSON.');
assert(json.containsKey(r'textColor'), 'Required key "TenantBadge[textColor]" is missing from JSON.');
assert(json.containsKey(r'isAwaitingReprocess'), 'Required key "TenantBadge[isAwaitingReprocess]" is missing from JSON.');
assert(json[r'isAwaitingReprocess'] != null, 'Required key "TenantBadge[isAwaitingReprocess]" has a null value in JSON.');
assert(json.containsKey(r'isAwaitingDeletion'), 'Required key "TenantBadge[isAwaitingDeletion]" is missing from JSON.');
assert(json[r'isAwaitingDeletion'] != null, 'Required key "TenantBadge[isAwaitingDeletion]" has a null value in JSON.');
return true;
}());
return TenantBadge(
id: mapValueOfType<String>(json, r'_id')!,
tenantId: mapValueOfType<String>(json, r'tenantId')!,
createdByUserId: mapValueOfType<String>(json, r'createdByUserId')!,
createdAt: mapDateTime(json, r'createdAt', r'')!,
enabled: mapValueOfType<bool>(json, r'enabled')!,
urlId: mapValueOfType<String>(json, r'urlId'),
type: mapValueOfType<double>(json, r'type')!,
threshold: mapValueOfType<double>(json, r'threshold')!,
uses: mapValueOfType<double>(json, r'uses')!,
name: mapValueOfType<String>(json, r'name')!,
description: mapValueOfType<String>(json, r'description')!,
displayLabel: mapValueOfType<String>(json, r'displayLabel')!,
displaySrc: mapValueOfType<String>(json, r'displaySrc'),
backgroundColor: mapValueOfType<String>(json, r'backgroundColor'),
borderColor: mapValueOfType<String>(json, r'borderColor'),
textColor: mapValueOfType<String>(json, r'textColor'),
cssClass: mapValueOfType<String>(json, r'cssClass'),
veteranUserThresholdMillis: mapValueOfType<double>(json, r'veteranUserThresholdMillis'),
isAwaitingReprocess: mapValueOfType<bool>(json, r'isAwaitingReprocess')!,
isAwaitingDeletion: mapValueOfType<bool>(json, r'isAwaitingDeletion')!,
replacesBadgeId: mapValueOfType<String>(json, r'replacesBadgeId'),
);
}
return null;
}