class EnquiryModel {
  final String? id;
  final DateTime receivedDate;
  final String partner;
  final String assignedTo;
  final String broker;
  final String insurer;
  final String insuredName;
  final String vehicleNo;
  final String vehicleType;
  final String email;
  final String mobile;
  final String remarks;
  final String status;

  EnquiryModel({
    this.id,
    required this.receivedDate,
    required this.partner,
    required this.assignedTo,
    required this.broker,
    required this.insurer,
    required this.insuredName,
    required this.vehicleNo,
    required this.vehicleType,
    required this.email,
    required this.mobile,
    required this.remarks,
    required this.status,
  });

  factory EnquiryModel.fromJson(Map<String, dynamic> json) {
    return EnquiryModel(
      id: json['id']?.toString(),
      receivedDate: DateTime.parse(json['received_date']),
      partner: json['partner'] ?? '',
      assignedTo: json['assigned_to'] ?? '',
      broker: json['broker'] ?? '',
      insurer: json['insurer'] ?? '',
      insuredName: json['insured_name'] ?? '',
      vehicleNo: json['vehicle_no'] ?? '',
      vehicleType: json['vehicle_type'] ?? '',
      email: json['email'] ?? '',
      mobile: json['mobile'] ?? '',
      remarks: json['remarks'] ?? '',
      status: json['status'] ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'received_date': receivedDate.toIso8601String(),
      'partner': partner,
      'assigned_to': assignedTo,
      'broker': broker,
      'insurer': insurer,
      'insured_name': insuredName,
      'vehicle_no': vehicleNo,
      'vehicle_type': vehicleType,
      'email': email,
      'mobile': mobile,
      'remarks': remarks,
      'status': status,
    };
  }

  EnquiryModel copyWith({
    String? id,
    DateTime? receivedDate,
    String? partner,
    String? assignedTo,
    String? broker,
    String? insurer,
    String? insuredName,
    String? vehicleNo,
    String? vehicleType,
    String? email,
    String? mobile,
    String? remarks,
    String? status,
  }) {
    return EnquiryModel(
      id: id ?? this.id,
      receivedDate: receivedDate ?? this.receivedDate,
      partner: partner ?? this.partner,
      assignedTo: assignedTo ?? this.assignedTo,
      broker: broker ?? this.broker,
      insurer: insurer ?? this.insurer,
      insuredName: insuredName ?? this.insuredName,
      vehicleNo: vehicleNo ?? this.vehicleNo,
      vehicleType: vehicleType ?? this.vehicleType,
      email: email ?? this.email,
      mobile: mobile ?? this.mobile,
      remarks: remarks ?? this.remarks,
      status: status ?? this.status,
    );
  }
}
