class KycModel {
  String? id;
  String? name;
  String? email;
  String? tradeName;
  String? address;
  String? state;
  String? city;
  String? district;
  String? pincode;
  String? mobileNumber;
  PrincipalDistributer? principalDistributer;
  String? panNumber;
  ImageModel? panImg;
  String? aadharNumber;
  ImageModel? aadharImg;
  String? gstNumber;
  ImageModel? gstImg;
  ImageModel? pesticideLicenseImg;
  ImageModel? selfieEntranceImg;
  String? status;
  AddedBy? addedBy;
  String? userType;
List<Notes>? notes;
  String? createdAt;
  String? updatedAt;
  int? v;

  KycModel({
    this.id,
    this.name,
    this.email,
    this.tradeName,
    this.address,
    this.state,
    this.city,
    this.district,
    this.pincode,
    this.mobileNumber,
    this.principalDistributer,
    this.panNumber,
    this.panImg,
    this.aadharNumber,
    this.aadharImg,
    this.gstNumber,
    this.gstImg,
    this.pesticideLicenseImg,
    this.selfieEntranceImg,
    this.status,
    this.addedBy,
    this.userType,
    this.notes,
    this.createdAt,
    this.updatedAt,
    this.v,
  });

  factory KycModel.fromJson(Map<String, dynamic> json) {
    return KycModel(
      id: json["_id"],
      name: json["name"],
      email: json["email"],
      tradeName: json["trade_name"],
      address: json["address"],
      state: json["state"],
      city: json["city"],
      district: json["district"],
      pincode: json["pincode"],
      mobileNumber: json["mobile_number"],
      principalDistributer: json["principal_distributer"] != null
          ? PrincipalDistributer.fromJson(json["principal_distributer"])
          : null,
      panNumber: json["pan_number"],
      panImg: json["pan_img"] != null ? ImageModel.fromJson(json["pan_img"]) : null,
      aadharNumber: json["aadhar_number"],
      aadharImg: json["aadhar_img"] != null
          ? ImageModel.fromJson(json["aadhar_img"])
          : null,
      gstNumber: json["gst_number"],
      gstImg: json["gst_img"] != null ? ImageModel.fromJson(json["gst_img"]) : null,
      pesticideLicenseImg: json["pesticide_license_img"] != null
          ? ImageModel.fromJson(json["pesticide_license_img"])
          : null,
      selfieEntranceImg: json["selfie_entrance_img"] != null
          ? ImageModel.fromJson(json["selfie_entrance_img"])
          : null,
      status: json["status"],
      addedBy: json["addedBy"] != null ? AddedBy.fromJson(json["addedBy"]) : null,
      userType: json["userType"],
      notes: json['notes'] != null
          ? (json['notes'] as List).map((i) => Notes.fromJson(i)).toList()
          : null,
      createdAt: json["createdAt"],
      updatedAt: json["updatedAt"],
      v: json["__v"],
    );
  }

  // Method for parsing list of JSON objects
  static List<KycModel> fromJsonList(List<dynamic> jsonList) {
    return jsonList.map((json) => KycModel.fromJson(json)).toList();
  }

  Map<String, dynamic> toJson() {
    return {
      "_id": id,
      "name": name,
      "email": email,
      "trade_name": tradeName,
      "address": address,
      "state": state,
      "city": city,
      "district": district,
      "pincode": pincode,
      "mobile_number": mobileNumber,
      "principal_distributer": principalDistributer?.toJson(),
      "pan_number": panNumber,
      "pan_img": panImg?.toJson(),
      "aadhar_number": aadharNumber,
      "aadhar_img": aadharImg?.toJson(),
      "gst_number": gstNumber,
      "gst_img": gstImg?.toJson(),
      "pesticide_license_img": pesticideLicenseImg?.toJson(),
      "selfie_entrance_img": selfieEntranceImg?.toJson(),
      "status": status,
      "addedBy": addedBy?.toJson(),
      "userType": userType,
      "notes": notes?.map((note) => note.toJson()).toList(),
      "createdAt": createdAt,
      "updatedAt": updatedAt,
      "__v": v,
    };
  }

  @override
  String toString() {
    return 'KycModel{id: $id, name: $name, email: $email, tradeName: $tradeName, address: $address, state: $state, city: $city, district: $district, pincode: $pincode, mobileNumber: $mobileNumber, principalDistributer: $principalDistributer, panNumber: $panNumber, panImg: $panImg, aadharNumber: $aadharNumber, aadharImg: $aadharImg, gstNumber: $gstNumber, gstImg: $gstImg, pesticideLicenseImg: $pesticideLicenseImg, selfieEntranceImg: $selfieEntranceImg, status: $status, addedBy: $addedBy, userType: $userType, notes: $notes, createdAt: $createdAt, updatedAt: $updatedAt, v: $v}';
  }
}

class PrincipalDistributer {
  String? id;
  String? name;

  PrincipalDistributer({this.id, this.name});

  factory PrincipalDistributer.fromJson(Map<String, dynamic> json) {
    return PrincipalDistributer(
      id: json["_id"],
      name: json["name"],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "_id": id,
      "name": name,
    };
  }

  @override
  String toString() {
    return 'PrincipalDistributer{id: $id, name: $name}';
  }
}


class Notes {
  String? message;
  String? replyDate;
  String? id;
  String? user;

  Notes({this.message, this.replyDate, this.id,this.user});

  factory Notes.fromJson(Map<String, dynamic> json) {
    return Notes(
      message: json["message"],
      replyDate: json["replyDate"],
      id: json["_id"],
      user: json['user']
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "message": message,
      "replyDate": replyDate,
      "_id": id,
      "user":user
    };
  }

  @override
  String toString() {
    return 'Notes{message: $message, replyDate: $replyDate, id: $id,user:$user}';
  }
}

class ImageModel {
  String? publicId;
  String? url;

  ImageModel({this.publicId, this.url});

  factory ImageModel.fromJson(Map<String, dynamic> json) {
    return ImageModel(
      publicId: json["public_id"],
      url: json["url"],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "public_id": publicId,
      "url": url,
    };
  }

  @override
  String toString() {
    return 'ImageModel{publicId: $publicId, url: $url}';
  }
}

class AddedBy {
  String? id;
  String? designation;
  String? name;
  String? mobileNumber;
  bool? isVerified;
  String? email;
  String? fcmToken;
  String? uniqueId;
  String? createdAt;
  String? updatedAt;
  int? v;

  AddedBy({
    this.id,
    this.designation,
    this.name,
    this.mobileNumber,
    this.isVerified,
    this.email,
    this.fcmToken,
    this.uniqueId,
    this.createdAt,
    this.updatedAt,
    this.v,
  });

  factory AddedBy.fromJson(Map<String, dynamic> json) {
    return AddedBy(
      id: json["_id"],
      designation: json["designation"],
      name: json["name"],
      mobileNumber: json["mobileNumber"],
      isVerified: json["isVerified"],
      email: json["email"],
      fcmToken: json["fcm_token"],
      uniqueId: json["uniqueId"],
      createdAt: json["createdAt"],
      updatedAt: json["updatedAt"],
      v: json["__v"],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "_id": id,
      "designation": designation,
      "name": name,
      "mobileNumber": mobileNumber,
      "isVerified": isVerified,
      "email": email,
      "fcm_token": fcmToken,
      "uniqueId": uniqueId,
      "createdAt": createdAt,
      "updatedAt": updatedAt,
      "__v": v,
    };
  }

  @override
  String toString() {
    return 'AddedBy{id: $id, designation: $designation, name: $name, mobileNumber: $mobileNumber, isVerified: $isVerified, email: $email, fcmToken: $fcmToken, uniqueId: $uniqueId, createdAt: $createdAt, updatedAt: $updatedAt, v: $v}';
  }
}



