fromJson static method
Returns a new SessionDetail instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static SessionDetail? 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 "SessionDetail[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "SessionDetail[$key]" has a null value in JSON.');
});
return true;
}());
return SessionDetail(
account: mapValueOfType<String>(json, r'account'),
actor: mapValueOfType<String>(json, r'actor'),
agent: mapValueOfType<String>(json, r'agent'),
childSessions: SessionView.listFromJson(json[r'childSessions']),
children: mapValueOfType<int>(json, r'children'),
createdAt: mapValueOfType<String>(json, r'createdAt'),
cwd: mapValueOfType<String>(json, r'cwd'),
endedAt: mapValueOfType<String>(json, r'endedAt'),
events: mapValueOfType<int>(json, r'events'),
host: mapValueOfType<String>(json, r'host'),
id: mapValueOfType<String>(json, r'id'),
lastEvent: LastEventView.fromJson(json[r'lastEvent']),
org: mapValueOfType<String>(json, r'org'),
parentSessionId: mapValueOfType<String>(json, r'parentSessionId'),
progress: SessionProgress.fromJson(json[r'progress']),
project: mapValueOfType<String>(json, r'project'),
provider: mapValueOfType<String>(json, r'provider'),
published: mapValueOfType<bool>(json, r'published'),
recentEvents: EventView.listFromJson(json[r'recentEvents']),
repo: mapValueOfType<String>(json, r'repo'),
room: mapValueOfType<String>(json, r'room'),
rootSessionId: mapValueOfType<String>(json, r'rootSessionId'),
startedAt: mapValueOfType<String>(json, r'startedAt'),
status: mapValueOfType<String>(json, r'status'),
target: mapValueOfType<String>(json, r'target'),
taskRunId: mapValueOfType<String>(json, r'taskRunId'),
taskWorkflowId: mapValueOfType<String>(json, r'taskWorkflowId'),
terminal: mapValueOfType<String>(json, r'terminal'),
title: mapValueOfType<String>(json, r'title'),
updatedAt: mapValueOfType<String>(json, r'updatedAt'),
);
}
return null;
}