import 'package:locations/model/user/user_info.dart';
|
|
class LocationUserModel {
|
LocationUserModel(
|
{String? id,
|
int? targetUid,
|
String? targetName,
|
String? targetPhone,
|
LocationInviteStatus? status,
|
LocationUserType? userType,
|
UserInfo? userInfo}) {
|
_id = id;
|
_targetUid = targetUid;
|
_targetName = targetName;
|
_targetPhone = targetPhone;
|
_status = status;
|
_userType = userType;
|
_userInfo = userInfo;
|
}
|
|
LocationUserModel.fromJson(dynamic json) {
|
_id = json['id'];
|
_targetUid = json['targetUid'];
|
_targetName = json['targetName'];
|
_targetPhone = json['targetPhone'];
|
switch (json['status']) {
|
case "sentInvite":
|
_status = LocationInviteStatus.sentInvite;
|
break;
|
case "agree":
|
_status = LocationInviteStatus.agree;
|
break;
|
case "reject":
|
_status = LocationInviteStatus.reject;
|
break;
|
}
|
|
switch (json['userType']) {
|
case "son":
|
_userType = LocationUserType.son;
|
break;
|
case "daughter":
|
_userType = LocationUserType.daughter;
|
break;
|
case "husband":
|
_userType = LocationUserType.husband;
|
break;
|
case "wife":
|
_userType = LocationUserType.wife;
|
break;
|
case "father":
|
_userType = LocationUserType.father;
|
break;
|
case "mother":
|
_userType = LocationUserType.mother;
|
break;
|
case "other":
|
_userType = LocationUserType.other;
|
break;
|
}
|
if (json['userInfo'] != null) {
|
_userInfo = UserInfo.fromJson(json['userInfo']);
|
}
|
}
|
|
String? _id;
|
int? _targetUid;
|
String? _targetName;
|
String? _targetPhone;
|
LocationInviteStatus? _status;
|
LocationUserType? _userType;
|
UserInfo? _userInfo;
|
|
String? get id => _id;
|
|
int? get targetUid => _targetUid;
|
|
String? get targetName => _targetName;
|
|
String? get targetPhone => _targetPhone;
|
|
UserInfo? get userInfo => _userInfo;
|
|
LocationInviteStatus? get status => _status;
|
|
LocationUserType? get userType => _userType;
|
|
Map<String?, dynamic> toJson() {
|
final map = <String?, dynamic>{};
|
map['id'] = _id;
|
map['targetUid'] = _targetUid;
|
map['targetName'] = _targetName;
|
map['targetPhone'] = _targetPhone;
|
map['status'] = _status;
|
map['userType'] = _userType;
|
map['userInfo'] = _userInfo;
|
return map;
|
}
|
}
|
|
enum LocationUserType { father, mother, husband, wife, daughter, son, other }
|
|
enum LocationInviteStatus { sentInvite, agree, reject }
|