You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
4.0 KiB
Dart
118 lines
4.0 KiB
Dart
// To parse this JSON data, do
|
|
//
|
|
// final user = userFromMap(jsonString);
|
|
|
|
import 'dart:convert';
|
|
|
|
User userFromMap(String str) => User.fromMap(json.decode(str));
|
|
|
|
String userToMap(User data) => json.encode(data.toMap());
|
|
|
|
class User {
|
|
User({
|
|
this.accessToken,
|
|
this.refreshToken,
|
|
this.expiryDate,
|
|
this.userInfo,
|
|
});
|
|
|
|
String? accessToken;
|
|
String? refreshToken;
|
|
DateTime? expiryDate;
|
|
UserInfo? userInfo;
|
|
|
|
factory User.fromMap(Map<String, dynamic> json) => User(
|
|
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.fromMap(json["userInfo"]),
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"accessToken": accessToken == null ? null : accessToken,
|
|
"refreshToken": refreshToken == null ? null : refreshToken,
|
|
"expiryDate": expiryDate == null ? null : expiryDate!.toIso8601String(),
|
|
"userInfo": userInfo == null ? null : userInfo!.toMap(),
|
|
};
|
|
}
|
|
|
|
class UserInfo {
|
|
UserInfo({
|
|
this.id,
|
|
this.userId,
|
|
this.firstName,
|
|
this.lastName,
|
|
this.mobileNo,
|
|
this.email,
|
|
this.userImageUrl,
|
|
this.roleId,
|
|
this.roleName,
|
|
this.isEmailVerified,
|
|
this.serviceProviderBranch,
|
|
this.isVerified,
|
|
this.userRoles,
|
|
this.isCustomer,
|
|
this.isProvider,
|
|
this.providerId,
|
|
this.customerId,
|
|
});
|
|
|
|
int? id;
|
|
String? userId;
|
|
String? firstName;
|
|
String? lastName;
|
|
String? mobileNo;
|
|
String? email;
|
|
dynamic? userImageUrl;
|
|
int? roleId;
|
|
String? roleName;
|
|
bool? isEmailVerified;
|
|
List<dynamic>? serviceProviderBranch;
|
|
bool? isVerified;
|
|
List<dynamic>? userRoles;
|
|
bool? isCustomer;
|
|
bool? isProvider;
|
|
dynamic? providerId;
|
|
int? customerId;
|
|
|
|
factory UserInfo.fromMap(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"],
|
|
isProvider: json["isProvider"] == null ? null : json["isProvider"],
|
|
providerId: json["providerID"],
|
|
customerId: json["customerID"] == null ? null : json["customerID"],
|
|
);
|
|
|
|
Map<String, dynamic> toMap() => {
|
|
"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,
|
|
"isProvider": isProvider == null ? null : isProvider,
|
|
"providerID": providerId,
|
|
"customerID": customerId == null ? null : customerId,
|
|
};
|
|
}
|