import 'package:deus_app/model/login_response_entity.dart';

loginResponseEntityFromJson(LoginResponseEntity data, Map<String, dynamic> json) {
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = LoginResponseData().fromJson(json['data']);
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	return data;
}

Map<String, dynamic> loginResponseEntityToJson(LoginResponseEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['code'] = entity.code;
	data['data'] = entity.data.toJson();
	data['msg'] = entity.msg;
	return data;
}

loginResponseDataFromJson(LoginResponseData data, Map<String, dynamic> json) {
	if (json['user'] != null) {
		data.user = LoginResponseDataUser().fromJson(json['user']);
	}
	if (json['token'] != null) {
		data.token = json['token'].toString();
	}
	return data;
}

Map<String, dynamic> loginResponseDataToJson(LoginResponseData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['user'] = entity.user.toJson();
	data['token'] = entity.token;
	return data;
}

loginResponseDataUserFromJson(LoginResponseDataUser data, Map<String, dynamic> json) {
	if (json['key'] != null) {
		data.key = json['key'].toString();
	}
	if (json['token'] != null) {
		data.token = json['token'].toString();
	}
	if (json['ip'] != null) {
		data.ip = json['ip'].toString();
	}
	if (json['address'] != null) {
		data.address = json['address'].toString();
	}
	if (json['browser'] != null) {
		data.browser = json['browser'].toString();
	}
	if (json['loginTime'] != null) {
		data.loginTime = json['loginTime'].toString();
	}
	if (json['userId'] != null) {
		data.userId = json['userId'] is String
				? int.tryParse(json['userId'])
				: json['userId'].toInt();
	}
	if (json['username'] != null) {
		data.username = json['username'].toString();
	}
	if (json['nickName'] != null) {
		data.nickName = json['nickName'];
	}
	if (json['enabled'] != null) {
		data.enabled = json['enabled'];
	}
	if (json['dataScopes'] != null) {
		data.dataScopes = json['dataScopes'];
	}
	if (json['authorities'] != null) {
		data.authorities = (json['authorities'] as List).map((v) => v).toList().cast<dynamic>();
	}
	return data;
}

Map<String, dynamic> loginResponseDataUserToJson(LoginResponseDataUser entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['key'] = entity.key;
	data['token'] = entity.token;
	data['ip'] = entity.ip;
	data['address'] = entity.address;
	data['browser'] = entity.browser;
	data['loginTime'] = entity.loginTime;
	data['userId'] = entity.userId;
	data['username'] = entity.username;
	data['nickName'] = entity.nickName;
	data['enabled'] = entity.enabled;
	data['dataScopes'] = entity.dataScopes;
	data['authorities'] = entity.authorities;
	return data;
}