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

repairDetailResponseEntityFromJson(RepairDetailResponseEntity 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 = RepairDetailResponseData().fromJson(json['data']);
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	return data;
}

Map<String, dynamic> repairDetailResponseEntityToJson(RepairDetailResponseEntity 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;
}

repairDetailResponseDataFromJson(RepairDetailResponseData data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['repNum'] != null) {
		data.repNum = json['repNum'].toString();
	}
	if (json['theme'] != null) {
		data.theme = json['theme'].toString();
	}
	if (json['urg'] != null) {
		data.urg = json['urg'] is String
				? int.tryParse(json['urg'])
				: json['urg'].toInt();
	}
	if (json['deviceName'] != null) {
		data.deviceName = json['deviceName'];
	}
	if (json['deviceKey'] != null) {
		data.deviceKey = json['deviceKey'];
	}
	if (json['treatment'] != null) {
		data.treatment = json['treatment'] is String
				? int.tryParse(json['treatment'])
				: json['treatment'].toInt();
	}
	if (json['customerName'] != null) {
		data.customerName = json['customerName'];
	}
	if (json['channelName'] != null) {
		data.channelName = json['channelName'];
	}
	if (json['submitter'] != null) {
		data.submitter = json['submitter'];
	}
	if (json['receiver'] != null) {
		data.receiver = json['receiver'].toString();
	}
	if (json['maintainer'] != null) {
		data.maintainer = json['maintainer'].toString();
	}
	if (json['orderRecTime'] != null) {
		data.orderRecTime = json['orderRecTime'].toString();
	}
	if (json['applicant'] != null) {
		data.applicant = json['applicant'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['deviceId'] != null) {
		data.deviceId = json['deviceId'] is String
				? int.tryParse(json['deviceId'])
				: json['deviceId'].toInt();
	}
	if (json['instructions'] != null) {
		data.instructions = json['instructions'].toString();
	}
	if (json['repResRemarks'] != null) {
		data.repResRemarks = json['repResRemarks'].toString();
	}
	if (json['applicationTime'] != null) {
		data.applicationTime = json['applicationTime'].toString();
	}
	if (json['completeTime'] != null) {
		data.completeTime = json['completeTime'].toString();
	}
	if (json['repairImgUrls'] != null) {
		data.repairImgUrls = (json['repairImgUrls'] as List).map((v) => v).toList().cast<String>();
	}else{
		data.repairImgUrls =[];
	}
	if (json['repairResUrls'] != null) {
		data.repairResUrls = (json['repairResUrls'] as List).map((v) => v).toList().cast<String>();
	}else{
		data.repairResUrls =[];
	}
	if (json['logs'] != null) {
		data.logs = (json['logs'] as List).map((v) => RepairDetailResponseDataLogs().fromJson(v)).toList();
	}
	if (json['device'] != null) {
		data.device = RepairDetailResponseDataDevice().fromJson(json['device']);
	}
	return data;
}

Map<String, dynamic> repairDetailResponseDataToJson(RepairDetailResponseData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['repNum'] = entity.repNum;
	data['theme'] = entity.theme;
	data['urg'] = entity.urg;
	data['deviceName'] = entity.deviceName;
	data['deviceKey'] = entity.deviceKey;
	data['treatment'] = entity.treatment;
	data['customerName'] = entity.customerName;
	data['channelName'] = entity.channelName;
	data['submitter'] = entity.submitter;
	data['receiver'] = entity.receiver;
	data['maintainer'] = entity.maintainer;
	data['orderRecTime'] = entity.orderRecTime;
	data['applicant'] = entity.applicant;
	data['status'] = entity.status;
	data['deviceId'] = entity.deviceId;
	data['instructions'] = entity.instructions;
	data['applicationTime'] = entity.applicationTime;
	data['completeTime'] = entity.completeTime;
	data['repairImgUrls'] = entity.repairImgUrls;
	data['repResRemarks'] = entity.repResRemarks;
	data['repairResUrls'] = entity.repairResUrls;
	data['logs'] =  entity.logs.map((v) => v.toJson()).toList();
	data['device'] = entity.device!.toJson();
	return data;
}

repairDetailResponseDataLogsFromJson(RepairDetailResponseDataLogs data, Map<String, dynamic> json) {
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['updateTime'] != null) {
		data.updateTime = json['updateTime'].toString();
	}
	if (json['creator'] != null) {
		data.creator = json['creator'] is String
				? int.tryParse(json['creator'])
				: json['creator'].toInt();
	}
	if (json['updater'] != null) {
		data.updater = json['updater'] is String
				? int.tryParse(json['updater'])
				: json['updater'].toInt();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['userName'] != null) {
		data.userName = json['userName'].toString();
	}
	if (json['description'] != null) {
		data.description = json['description'].toString();
	}
	if (json['repairBillId'] != null) {
		data.repairBillId = json['repairBillId'] is String
				? int.tryParse(json['repairBillId'])
				: json['repairBillId'].toInt();
	}
	return data;
}

Map<String, dynamic> repairDetailResponseDataLogsToJson(RepairDetailResponseDataLogs entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['createTime'] = entity.createTime;
	data['updateTime'] = entity.updateTime;
	data['creator'] = entity.creator;
	data['updater'] = entity.updater;
	data['id'] = entity.id;
	data['userName'] = entity.userName;
	data['description'] = entity.description;
	data['repairBillId'] = entity.repairBillId;
	return data;
}

repairDetailResponseDataDeviceFromJson(RepairDetailResponseDataDevice data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['showName'] != null) {
		data.showName = json['showName'].toString();
	}
	if (json['deviceName'] != null) {
		data.deviceName = json['deviceName'].toString();
	}
	if (json['deviceKey'] != null) {
		data.deviceKey = json['deviceKey'].toString();
	}
	if (json['repairBillId'] != null) {
		data.repairBillId = json['repairBillId'];
	}
	if (json['prodName'] != null) {
		data.prodName = json['prodName'].toString();
	}
	if (json['isRepaired'] != null) {
		data.isRepaired = json['isRepaired'] is String
				? int.tryParse(json['isRepaired'])
				: json['isRepaired'].toInt();
	}
	if (json['completeTime'] != null) {
		data.completeTime = json['completeTime'].toString();
	}
	return data;
}

Map<String, dynamic> repairDetailResponseDataDeviceToJson(RepairDetailResponseDataDevice entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['showName'] = entity.showName;
	data['deviceName'] = entity.deviceName;
	data['deviceKey'] = entity.deviceKey;
	data['repairBillId'] = entity.repairBillId;
	data['prodName'] = entity.prodName;
	data['isRepaired'] = entity.isRepaired;
	data['completeTime'] = entity.completeTime;
	return data;
}