class LatestDataResponse {
  Data? data;
  int? statusCode;
  String? message;

  LatestDataResponse({this.data, this.statusCode, this.message});

  LatestDataResponse.fromJson(Map<String, dynamic> json) {
    data = json['data'] != null ? Data.fromJson(json['data']) : null;
    statusCode = json['statusCode'];
    message = json['message'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (this.data != null) {
      data['data'] = this.data!.toJson();
    }
    data['statusCode'] = statusCode;
    data['message'] = message;
    return data;
  }
}

class Data {
  List<Dht>? dht;
  List<Npk>? npk1;
  List<Npk>? npk2;

  Data({this.dht, this.npk1, this.npk2});

  Data.fromJson(Map<String, dynamic> json) {
    if (json['dht'] != null) {
      dht = <Dht>[];
      json['dht'].forEach((v) {
        dht!.add(Dht.fromJson(v));
      });
    }
    if (json['npk1'] != null) {
      npk1 = <Npk>[];
      json['npk1'].forEach((v) {
        npk1!.add(Npk.fromJson(v));
      });
    }
    if (json['npk2'] != null) {
      npk2 = <Npk>[];
      json['npk2'].forEach((v) {
        npk2!.add(Npk.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (dht != null) {
      data['dht'] = dht!.map((v) => v.toJson()).toList();
    }
    if (npk1 != null) {
      data['npk1'] = npk1!.map((v) => v.toJson()).toList();
    }
    if (npk2 != null) {
      data['npk2'] = npk2!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Dht {
  int? hour;
  num? vicitemperature;
  num? vicihumidity;
  num? viciluminosity;

  Dht(
      {this.hour,
      this.vicitemperature,
      this.vicihumidity,
      this.viciluminosity});

  Dht.fromJson(Map<String, dynamic> json) {
    hour = json['hour'];
    vicitemperature = json['vicitemperature'];
    vicihumidity = json['vicihumidity'];
    viciluminosity = json['viciluminosity'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['hour'] = hour;
    data['vicitemperature'] = vicitemperature;
    data['vicihumidity'] = vicihumidity;
    data['viciluminosity'] = viciluminosity;
    return data;
  }
}

class Npk {
  int? hour;
  num? soiltemperature;
  num? soilhumidity;
  num? soilconductivity;
  num? soilph;
  num? soilnitrogen;
  num? soilphosphorus;
  num? soilpotassium;

  Npk(
      {this.hour,
      this.soiltemperature,
      this.soilhumidity,
      this.soilconductivity,
      this.soilph,
      this.soilnitrogen,
      this.soilphosphorus,
      this.soilpotassium});

  Npk.fromJson(Map<String, dynamic> json) {
    hour = json['hour'];
    soiltemperature = json['soiltemperature'];
    soilhumidity = json['soilhumidity'];
    soilconductivity = json['soilconductivity'];
    soilph = json['soilph'];
    soilnitrogen = json['soilnitrogen'];
    soilphosphorus = json['soilphosphorus'];
    soilpotassium = json['soilpotassium'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['hour'] = hour;
    data['soiltemperature'] = soiltemperature;
    data['soilhumidity'] = soilhumidity;
    data['soilconductivity'] = soilconductivity;
    data['soilph'] = soilph;
    data['soilnitrogen'] = soilnitrogen;
    data['soilphosphorus'] = soilphosphorus;
    data['soilpotassium'] = soilpotassium;
    return data;
  }
}
