|
|
|
@ -4,6 +4,9 @@
|
|
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import '../../classes/app_state.dart';
|
|
|
|
|
import '../../utils/enums.dart';
|
|
|
|
|
|
|
|
|
|
User userFromJson(String str) => User.fromJson(json.decode(str));
|
|
|
|
|
|
|
|
|
|
String userToJson(User data) => json.encode(data.toJson());
|
|
|
|
@ -22,18 +25,18 @@ class User {
|
|
|
|
|
String? message;
|
|
|
|
|
|
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) => User(
|
|
|
|
|
totalItemsCount: json["totalItemsCount"],
|
|
|
|
|
data: json["data"] == null ? null : UserData.fromJson(json["data"]),
|
|
|
|
|
messageStatus: json["messageStatus"] == null ? null : json["messageStatus"],
|
|
|
|
|
message: json["message"] == null ? null : json["message"],
|
|
|
|
|
);
|
|
|
|
|
totalItemsCount: json["totalItemsCount"],
|
|
|
|
|
data: json["data"] == null ? null : UserData.fromJson(json["data"]),
|
|
|
|
|
messageStatus: json["messageStatus"],
|
|
|
|
|
message: json["message"],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
|
"totalItemsCount": totalItemsCount,
|
|
|
|
|
"data": data == null ? null : data!.toJson(),
|
|
|
|
|
"messageStatus": messageStatus == null ? null : messageStatus,
|
|
|
|
|
"message": message == null ? null : message,
|
|
|
|
|
};
|
|
|
|
|
"totalItemsCount": totalItemsCount,
|
|
|
|
|
"data": data == null ? null : data!.toJson(),
|
|
|
|
|
"messageStatus": messageStatus,
|
|
|
|
|
"message": message,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UserData {
|
|
|
|
@ -50,18 +53,18 @@ class UserData {
|
|
|
|
|
UserInfo? userInfo;
|
|
|
|
|
|
|
|
|
|
factory UserData.fromJson(Map<String, dynamic> json) => UserData(
|
|
|
|
|
accessToken: json["accessToken"] == null ? null : json["accessToken"],
|
|
|
|
|
refreshToken: json["refreshToken"] == null ? null : json["refreshToken"],
|
|
|
|
|
expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
|
|
|
|
|
userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]),
|
|
|
|
|
);
|
|
|
|
|
accessToken: json["accessToken"],
|
|
|
|
|
refreshToken: json["refreshToken"],
|
|
|
|
|
expiryDate: json["expiryDate"] == null ? null : DateTime.parse(json["expiryDate"]),
|
|
|
|
|
userInfo: json["userInfo"] == null ? null : UserInfo.fromJson(json["userInfo"]),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
|
"accessToken": accessToken == null ? null : accessToken,
|
|
|
|
|
"refreshToken": refreshToken == null ? null : refreshToken,
|
|
|
|
|
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
|
|
|
|
|
"userInfo": userInfo == null ? null : userInfo!.toJson(),
|
|
|
|
|
};
|
|
|
|
|
"accessToken": accessToken,
|
|
|
|
|
"refreshToken": refreshToken,
|
|
|
|
|
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
|
|
|
|
|
"userInfo": userInfo == null ? null : userInfo!.toJson(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UserInfo {
|
|
|
|
@ -107,47 +110,76 @@ class UserInfo {
|
|
|
|
|
int? customerId;
|
|
|
|
|
dynamic dealershipId;
|
|
|
|
|
|
|
|
|
|
factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
|
|
|
|
|
id: json["id"] == null ? null : json["id"],
|
|
|
|
|
userId: json["userID"] == null ? null : json["userID"],
|
|
|
|
|
firstName: json["firstName"] == null ? null : json["firstName"],
|
|
|
|
|
lastName: json["lastName"] == null ? null : json["lastName"],
|
|
|
|
|
mobileNo: json["mobileNo"] == null ? null : json["mobileNo"],
|
|
|
|
|
email: json["email"] == null ? null : json["email"],
|
|
|
|
|
userImageUrl: json["userImageUrl"],
|
|
|
|
|
roleId: json["roleID"] == null ? null : json["roleID"],
|
|
|
|
|
roleName: json["roleName"] == null ? null : json["roleName"],
|
|
|
|
|
isEmailVerified: json["isEmailVerified"] == null ? null : json["isEmailVerified"],
|
|
|
|
|
serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
|
|
|
|
|
isVerified: json["isVerified"] == null ? null : json["isVerified"],
|
|
|
|
|
userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
|
|
|
|
|
isCustomer: json["isCustomer"] == null ? null : json["isCustomer"],
|
|
|
|
|
isProviderDealership: json["isProviderDealership"] == null ? null : json["isProviderDealership"],
|
|
|
|
|
isDealershipUser: json["isDealershipUser"] == null ? null : json["isDealershipUser"],
|
|
|
|
|
providerId: json["providerID"],
|
|
|
|
|
customerId: json["customerID"] == null ? null : json["customerID"],
|
|
|
|
|
dealershipId: json["dealershipID"],
|
|
|
|
|
);
|
|
|
|
|
UserInfo.fromJson(Map<String, dynamic> json) {
|
|
|
|
|
if (json["roleID"] == 5) {
|
|
|
|
|
AppState().userType = UserType.providerDealer;
|
|
|
|
|
} else if (json["roleID"] == 6) {
|
|
|
|
|
AppState().userType = UserType.providerIndividual;
|
|
|
|
|
} else {
|
|
|
|
|
AppState().userType = UserType.customer;
|
|
|
|
|
}
|
|
|
|
|
id = json["id"];
|
|
|
|
|
userId = json["userID"];
|
|
|
|
|
firstName = json["firstName"];
|
|
|
|
|
lastName = json["lastName"];
|
|
|
|
|
mobileNo = json["mobileNo"];
|
|
|
|
|
email = json["email"];
|
|
|
|
|
userImageUrl = json["userImageUrl"];
|
|
|
|
|
roleId = json["roleID"];
|
|
|
|
|
roleName = json["roleName"];
|
|
|
|
|
isEmailVerified = json["isEmailVerified"];
|
|
|
|
|
serviceProviderBranch = json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x));
|
|
|
|
|
isVerified = json["isVerified"];
|
|
|
|
|
userRoles = json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x));
|
|
|
|
|
isCustomer = json["isCustomer"];
|
|
|
|
|
isProviderDealership = json["isProviderDealership"];
|
|
|
|
|
isDealershipUser = json["isDealershipUser"];
|
|
|
|
|
providerId = json["providerID"];
|
|
|
|
|
customerId = json["customerID"];
|
|
|
|
|
dealershipId = json["dealershipID"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
|
|
|
|
|
// id: json["id"],
|
|
|
|
|
// userId: json["userID"],
|
|
|
|
|
// firstName: json["firstName"],
|
|
|
|
|
// lastName: json["lastName"],
|
|
|
|
|
// mobileNo: json["mobileNo"],
|
|
|
|
|
// email: json["email"],
|
|
|
|
|
// userImageUrl: json["userImageUrl"],
|
|
|
|
|
// roleId: json["roleID"],
|
|
|
|
|
// roleName: json["roleName"],
|
|
|
|
|
// isEmailVerified: json["isEmailVerified"],
|
|
|
|
|
// serviceProviderBranch: json["serviceProviderBranch"] == null ? null : List<dynamic>.from(json["serviceProviderBranch"].map((x) => x)),
|
|
|
|
|
// isVerified: json["isVerified"],
|
|
|
|
|
// userRoles: json["userRoles"] == null ? null : List<dynamic>.from(json["userRoles"].map((x) => x)),
|
|
|
|
|
// isCustomer: json["isCustomer"],
|
|
|
|
|
// isProviderDealership: json["isProviderDealership"],
|
|
|
|
|
// isDealershipUser: json["isDealershipUser"],
|
|
|
|
|
// providerId: json["providerID"],
|
|
|
|
|
// customerId: json["customerID"],
|
|
|
|
|
// dealershipId: json["dealershipID"],
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
|
"id": id == null ? null : id,
|
|
|
|
|
"userID": userId == null ? null : userId,
|
|
|
|
|
"firstName": firstName == null ? null : firstName,
|
|
|
|
|
"lastName": lastName == null ? null : lastName,
|
|
|
|
|
"mobileNo": mobileNo == null ? null : mobileNo,
|
|
|
|
|
"email": email == null ? null : email,
|
|
|
|
|
"userImageUrl": userImageUrl,
|
|
|
|
|
"roleID": roleId == null ? null : roleId,
|
|
|
|
|
"roleName": roleName == null ? null : roleName,
|
|
|
|
|
"isEmailVerified": isEmailVerified == null ? null : isEmailVerified,
|
|
|
|
|
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
|
|
|
|
|
"isVerified": isVerified == null ? null : isVerified,
|
|
|
|
|
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
|
|
|
|
|
"isCustomer": isCustomer == null ? null : isCustomer,
|
|
|
|
|
"isProviderDealership": isProviderDealership == null ? null : isProviderDealership,
|
|
|
|
|
"isDealershipUser": isDealershipUser == null ? null : isDealershipUser,
|
|
|
|
|
"providerID": providerId,
|
|
|
|
|
"customerID": customerId == null ? null : customerId,
|
|
|
|
|
"dealershipID": dealershipId,
|
|
|
|
|
};
|
|
|
|
|
"id": id,
|
|
|
|
|
"userID": userId,
|
|
|
|
|
"firstName": firstName,
|
|
|
|
|
"lastName": lastName,
|
|
|
|
|
"mobileNo": mobileNo,
|
|
|
|
|
"email": email,
|
|
|
|
|
"userImageUrl": userImageUrl,
|
|
|
|
|
"roleID": roleId,
|
|
|
|
|
"roleName": roleName,
|
|
|
|
|
"isEmailVerified": isEmailVerified,
|
|
|
|
|
"serviceProviderBranch": serviceProviderBranch == null ? null : List<dynamic>.from(serviceProviderBranch!.map((x) => x)),
|
|
|
|
|
"isVerified": isVerified,
|
|
|
|
|
"userRoles": userRoles == null ? null : List<dynamic>.from(userRoles!.map((x) => x)),
|
|
|
|
|
"isCustomer": isCustomer,
|
|
|
|
|
"isProviderDealership": isProviderDealership,
|
|
|
|
|
"isDealershipUser": isDealershipUser,
|
|
|
|
|
"providerID": providerId,
|
|
|
|
|
"customerID": customerId,
|
|
|
|
|
"dealershipID": dealershipId,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|