fromJson static method
Returns a new WorkspaceInvitation instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static WorkspaceInvitation? 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 "WorkspaceInvitation[id]" is missing from JSON.');
assert(json[r'id'] != null, 'Required key "WorkspaceInvitation[id]" has a null value in JSON.');
assert(json.containsKey(r'email'), 'Required key "WorkspaceInvitation[email]" is missing from JSON.');
assert(json[r'email'] != null, 'Required key "WorkspaceInvitation[email]" has a null value in JSON.');
assert(json.containsKey(r'role'), 'Required key "WorkspaceInvitation[role]" is missing from JSON.');
assert(json[r'role'] != null, 'Required key "WorkspaceInvitation[role]" has a null value in JSON.');
assert(json.containsKey(r'createdAt'), 'Required key "WorkspaceInvitation[createdAt]" is missing from JSON.');
assert(json[r'createdAt'] != null, 'Required key "WorkspaceInvitation[createdAt]" has a null value in JSON.');
return true;
}());
return WorkspaceInvitation(
id: mapValueOfType<String>(json, r'id')!,
workspaceId: mapValueOfType<String>(json, r'workspaceId'),
email: mapValueOfType<String>(json, r'email')!,
role: mapValueOfType<String>(json, r'role')!,
expiresAt: mapDateTime(json, r'expiresAt', r''),
createdAt: mapDateTime(json, r'createdAt', r'')!,
acceptedAt: mapDateTime(json, r'acceptedAt', r''),
revokedAt: mapDateTime(json, r'revokedAt', r''),
status: WorkspaceInvitationStatusEnum.fromJson(json[r'status']),
);
}
return null;
}