import '../controllers/notification/firebase_notification_manger.dart'; class User { String? clientId; String? clientName; int? departmentId; String? departmentName; String? message; String? username; String? userID; String? email; String? password; String? token; String? roles; List? userRoles; String? tokenlife; bool? isAuthenticated; bool? hasError; String? profilePhotoName; String? id; String? userName; String? normalizedUserName; String? normalizedEmail; bool? emailConfirmed; String? passwordHash; String? securityStamp; String? concurrencyStamp; ///I'm not sure from the datatype String? phoneNumber; bool? phoneNumberConfirmed; bool? twoFactorEnabled; ///I'm not sure from the datatype String? lockoutEnd; bool? lockoutEnabled; int? accessFailedCount; User({ this.clientId, this.clientName, this.departmentId, this.departmentName, this.message, this.username, this.userID, this.email, this.password, this.token, this.roles, this.userRoles, this.tokenlife, this.isAuthenticated, this.hasError, this.profilePhotoName, this.id, this.userName, this.normalizedUserName, this.normalizedEmail, this.emailConfirmed, this.passwordHash, this.securityStamp, this.concurrencyStamp, this.phoneNumber, this.phoneNumberConfirmed, this.twoFactorEnabled, this.lockoutEnd, this.lockoutEnabled, this.accessFailedCount, }); User.fromJson(Map json) { clientId = json['client_id']; clientName = json['client_name']; departmentId = json['department_id']; departmentName = json['department_name']; message = json['message']; username = json['username']; userID = json['userID']; email = json['email']; password = json['password']; token = json['token']; roles = json['roles']; if (json['userRoles'] != null) { userRoles = []; json['userRoles'].forEach((v) { userRoles!.add(v); }); } tokenlife = json['tokenlife']; isAuthenticated = json['isAuthenticated']; hasError = json['hasError']; profilePhotoName = json['profilePhotoName']; id = json['id']; userName = json['userName']; normalizedUserName = json['normalizedUserName']; normalizedEmail = json['normalizedEmail']; emailConfirmed = json['emailConfirmed']; passwordHash = json['passwordHash']; securityStamp = json['securityStamp']; concurrencyStamp = json['concurrencyStamp']; phoneNumber = json['phoneNumber']; phoneNumberConfirmed = json['phoneNumberConfirmed']; twoFactorEnabled = json['twoFactorEnabled']; lockoutEnd = json['lockoutEnd']; lockoutEnabled = json['lockoutEnabled']; accessFailedCount = json['accessFailedCount']; } Map toJson() { final Map data = {}; data['client_id'] = clientId; data['client_name'] = clientName; data['department_id'] = departmentId; data['department_name'] = departmentName; data['message'] = message; data['username'] = username; data['userID'] = userID; data['email'] = email; data['password'] = password; data['token'] = token; data['roles'] = roles; data['userRoles'] = userRoles; data['tokenlife'] = tokenlife; data['isAuthenticated'] = isAuthenticated; data['hasError'] = hasError; data['profilePhotoName'] = profilePhotoName; data['id'] = id; data['userName'] = userName; data['normalizedUserName'] = normalizedUserName; data['normalizedEmail'] = normalizedEmail; data['emailConfirmed'] = emailConfirmed; data['passwordHash'] = passwordHash; data['securityStamp'] = securityStamp; data['concurrencyStamp'] = concurrencyStamp; data['phoneNumber'] = phoneNumber; data['phoneNumberConfirmed'] = phoneNumberConfirmed; data['twoFactorEnabled'] = twoFactorEnabled; data['lockoutEnd'] = lockoutEnd; data['lockoutEnabled'] = lockoutEnabled; data['accessFailedCount'] = accessFailedCount; return data; } Future> toLoginJson() async { if (FirebaseNotificationManger.token == null) await FirebaseNotificationManger.getToken(); return { "username": userName, "password": password, "fireBaseToken": FirebaseNotificationManger.token ?? "", }; } Map toUpdateProfileJson() { Map jsonObject = {}; // if (department?.id != null && (department?.id?.isNotEmpty ?? false)) jsonObject["department"] = department?.id ?? ""; // if (whatsApp != null && (whatsApp?.isNotEmpty ?? false)) jsonObject["whatsapp"] = whatsApp; // if (phoneNumber != null && (phoneNumber?.isNotEmpty ?? false)) jsonObject["phoneNumber"] = phoneNumber; return jsonObject; } Future> toRegisterJson() async { if (FirebaseNotificationManger.token == null) await FirebaseNotificationManger.getToken(); return { "username": userName, "email": email, // "whatsapp": whatsApp, // "client": hospital?.id, // "department": department?.id, "phoneNumber": phoneNumber, "password": password, "fireBaseToken": FirebaseNotificationManger.token ?? "", }; } }