Files
CityCards_Customer_Flutter/lib/profile/models/profile_model.dart

131 lines
3.3 KiB
Dart

class ProfileModel {
final int id;
final String firstName;
final String lastName;
final int roleXid;
final String emailAddress;
final String isdCode;
final String mobileNumber;
final String? profileImage; // ✅ NEW
final String? address1;
final String? address2;
final String? cityName;
final String? zipCode;
final String? stateName;
final String? country;
final String? timezone;
final String? lastLogin;
final bool isActive;
final String createdAt;
final String updatedAt;
final RoleModel? role;
ProfileModel({
required this.id,
required this.firstName,
required this.lastName,
required this.roleXid,
required this.emailAddress,
required this.isdCode,
required this.mobileNumber,
this.profileImage,
this.address1,
this.address2,
this.cityName,
this.zipCode,
this.stateName,
this.country,
this.timezone,
this.lastLogin,
required this.isActive,
required this.createdAt,
required this.updatedAt,
this.role,
});
factory ProfileModel.fromJson(Map<String, dynamic> json) {
return ProfileModel(
id: json['id'] ?? 0,
firstName: json['firstName'] ?? 'N/A',
lastName: json['lastName'] ?? 'N/A',
roleXid: json['roleXid'] ?? 0,
emailAddress: json['emailAddress'] ?? 'N/A',
isdCode: json['isdCode'] ?? 'N/A',
mobileNumber: json['mobileNumber'] ?? 'N/A',
profileImage: json['profileImage'], // ✅ added
address1: json['address1'],
address2: json['address2'],
cityName: json['cityName'],
zipCode: json['zipCode'],
stateName: json['stateName'],
country: json['country'],
timezone: json['timezone'],
lastLogin: json['lastLogin']?.toString(),
isActive: json['isActive'] ?? false,
createdAt: json['createdAt'] ?? '',
updatedAt: json['updatedAt'] ?? '',
role: json['role'] != null ? RoleModel.fromJson(json['role']) : null,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'firstName': firstName,
'lastName': lastName,
'roleXid': roleXid,
'emailAddress': emailAddress,
'isdCode': isdCode,
'mobileNumber': mobileNumber,
'profileImage': profileImage,
'address1': address1,
'address2': address2,
'cityName': cityName,
'zipCode': zipCode,
'stateName': stateName,
'country': country,
'timezone': timezone,
'lastLogin': lastLogin,
'isActive': isActive,
'createdAt': createdAt,
'updatedAt': updatedAt,
if (role != null) 'role': role!.toJson(),
};
}
}
class RoleModel {
final int id;
final String name;
final bool isActive;
final String createdAt;
final String updatedAt;
RoleModel({
required this.id,
required this.name,
required this.isActive,
required this.createdAt,
required this.updatedAt,
});
factory RoleModel.fromJson(Map<String, dynamic> json) {
return RoleModel(
id: json['id'] ?? 0,
name: json['name'] ?? 'N/A',
isActive: json['isActive'] ?? false,
createdAt: json['createdAt'] ?? 'N/A',
updatedAt: json['updatedAt'] ?? 'N/A',
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'isActive': isActive,
'createdAt': createdAt,
'updatedAt': updatedAt,
};
}
}