User.fromJson constructor
User.fromJson(
- Map<String, dynamic> jsonData
)
Implementation
factory User.fromJson(Map<String, dynamic> jsonData) {
return User(
id: jsonData['id'],
gender: jsonData['gender'] ?? '',
jobTitle: jsonData['jobTitle'] ?? '',
username: jsonData['username'],
password: jsonData['password'],
firstName: jsonData['firstName'],
surname: jsonData['surname'],
token: jsonData['token'],
tokenType: jsonData['tokenType'],
refreshToken: jsonData['refreshToken'],
tokenExpiry: jsonData['tokenExpiry'],
authType: jsonData['authType'],
name: jsonData['name'],
phoneNumber: jsonData['phoneNumber'],
baseUrl: jsonData['baseUrl'] ?? '',
created: jsonData['created'],
lastUpdated: jsonData['lastUpdated'],
teiSearchOrganisationUnits:
jsonData['teiSearchOrganisationUnits'].toString(),
organisationUnits: jsonData['organisationUnits'],
authorities: (jsonData['authorities'] ?? [])
.map<UserAuthority>((authority) => UserAuthority(
id: authority['id'],
name: authority['name'],
authority: authority['authority'],
user: authority['user'],
dirty: authority['dirty'] ?? false))
.toList(),
roles: (jsonData['roles'] ?? [])
.map<UserRole>((role) => UserRole(
id: role['id'],
name: role['name'],
user: role['user'],
dirty: role['dirty'] ?? false))
.toList(),
dataViewOrganisationUnits: jsonData['dataViewOrganisationUnits'],
programs: jsonData['programs'].toString(),
dataSets: jsonData['datasets'].toString(),
isLoggedIn: jsonData['isLoggedIn'],
userGroups: jsonData['userGroups'],
dirty: jsonData['dirty']);
}