import 'package:test_sa/models/device/technical_guidance_book.dart';
import 'package:test_sa/models/lookup.dart';

class AssetByIdModel {
  List<MultiAssets>? multiAssets;
  int? id;
  ModelDefinition? modelDefinition;
  Suppliers? supplier;
  String? ipAddress;
  String? macAddress;
  String? portNumber;
  AssetReplace? assetReplace;
  AssetInfo? oldAsset;
  AssetReplace? isParent;
  AssetInfo? parentAsset;
  AssetReplace? assetType;
  String? demoRequest;
  String? missionCritical;
  Site? site;
  AssetReplace? building;
  AssetReplace? floor;
  Department? department;
  Lookup? room;
  int? testsDay;
  num? purchasingPrice;
  String? nbv;
  Lookup? currency;
  String? poDate;
  String? poNo;
  String? invoiceNumber;
  String? invoiceDate;
  String? replacementDate;
  num? budgetYear;
  num? lastPOPrice;
  Lookup? commissioningStatus;
  Department? originDepartment;
  Site? originSite;
  String? productionDate;
  String? edd;
  String? technicalInspectionDate;
  String? deliveryInspectionDate;
  String? endUserAcceptanceDate;
  String? technicalAcceptanceDate;
  String? finalAcceptanceDate;
  String? installationDate;
  int? siteWarrantyMonthNo;
  num? extendedWarrantyMonthNo;
  num? remainderWarrantyMonthNo;
  num? eomWarrantyMonthsNo;
  num? warrantyValue;
  String? warrantyEndDate;
  String? warrantyContractConditions;
  List<TechnicalGuidanceBook>? technicalGuidanceBooks;
  String? comment;
  bool? isEnabled;
  String? tagCode;
  List<String>? assetAttachments;
  String? retirementTypeName;
  String? retirementStatusName;
  String? retirementDate;
  AssetGroup? assetGroup;
  String? assetPhoto;
  String? nextPMDate;
  String? lastPMDate;

  AssetByIdModel(
      {this.multiAssets,
      this.id,
      this.modelDefinition,
      this.supplier,
      this.ipAddress,
      this.macAddress,
      this.portNumber,
      this.assetReplace,
      this.oldAsset,
      this.isParent,
      this.parentAsset,
      this.assetType,
      this.demoRequest,
      this.missionCritical,
      this.site,
      this.building,
      this.floor,
      this.department,
      this.room,
      this.testsDay,
      this.purchasingPrice,
      this.nbv,
      this.currency,
      this.poDate,
      this.poNo,
      this.invoiceNumber,
      this.invoiceDate,
      this.replacementDate,
      this.budgetYear,
      this.lastPOPrice,
      this.commissioningStatus,
      this.originDepartment,
      this.originSite,
      this.productionDate,
      this.edd,
      this.technicalInspectionDate,
      this.deliveryInspectionDate,
      this.endUserAcceptanceDate,
      this.technicalAcceptanceDate,
      this.finalAcceptanceDate,
      this.installationDate,
      this.siteWarrantyMonthNo,
      this.extendedWarrantyMonthNo,
      this.remainderWarrantyMonthNo,
      this.eomWarrantyMonthsNo,
      this.warrantyValue,
      this.warrantyEndDate,
      this.warrantyContractConditions,
      this.technicalGuidanceBooks,
      this.comment,
      this.isEnabled,
      this.tagCode,
      this.assetAttachments,
      this.retirementTypeName,
      this.retirementStatusName,
      this.retirementDate,
      this.assetGroup,
      this.assetPhoto,
      this.nextPMDate,
      this.lastPMDate});

  AssetByIdModel.fromJson(Map<String, dynamic> json) {
    if (json['multiAssets'] != null) {
      multiAssets = <MultiAssets>[];
      json['multiAssets'].forEach((v) {
        multiAssets!.add(MultiAssets.fromJson(v));
      });
    }
    id = json['id'];
    modelDefinition = json['modelDefinition'] != null ? ModelDefinition.fromJson(json['modelDefinition']) : null;
    supplier = json['supplier'] != null ? Suppliers.fromJson(json['supplier']) : null;
    ipAddress = json['ipAddress'];
    macAddress = json['macAddress'];
    portNumber = json['portNumber'];
    assetReplace = json['assetReplace'] != null ? AssetReplace.fromJson(json['assetReplace']) : null;
    oldAsset = json['oldAsset'] != null ? AssetInfo.fromJson(json['oldAsset']) : null;
    isParent = json['isParent'] != null ? AssetReplace.fromJson(json['isParent']) : null;
    parentAsset = json['parentAsset'] != null ? AssetInfo.fromJson(json['parentAsset']) : null;
    assetType = json['assetType'] != null ? AssetReplace.fromJson(json['assetType']) : null;
    demoRequest = json['demoRequest'];
    missionCritical = json['missionCritical'];
    site = json['site'] != null ? Site.fromJson(json['site']) : null;
    building = json['building'] != null ? AssetReplace.fromJson(json['building']) : null;
    floor = json['floor'] != null ? AssetReplace.fromJson(json['floor']) : null;
    department = json['department'] != null ? Department.fromJson(json['department']) : null;
    room = json['room'] != null ? Lookup.fromJson(json['room']) : null;
    testsDay = json['testsDay'];
    purchasingPrice = json['purchasingPrice'];
    nbv = json['nbv'];
    currency = json['currency'] != null ? Lookup.fromJson(json['currency']) : null;
    poDate = json['poDate'];
    poNo = json['poNo'];
    invoiceNumber = json['invoiceNumber'];
    invoiceDate = json['invoiceDate'];
    replacementDate = json['replacementDate'];
    budgetYear = json['budgetYear'];
    lastPOPrice = json['lastPOPrice'];
    commissioningStatus = json['commissioningStatus'] != null ? Lookup.fromJson(json['commissioningStatus']) : null;
    originDepartment = json['originDepartment'] != null ? Department.fromJson(json['originDepartment']) : null;
    originSite = json['originSite'] != null ? Site.fromJson(json['originSite']) : null;
    productionDate = json['productionDate'];
    edd = json['edd'];
    technicalInspectionDate = json['technicalInspectionDate'];
    deliveryInspectionDate = json['deliveryInspectionDate'];
    endUserAcceptanceDate = json['endUserAcceptanceDate'];
    technicalAcceptanceDate = json['technicalAcceptanceDate'];
    finalAcceptanceDate = json['finalAcceptanceDate'];
    installationDate = json['installationDate'];
    siteWarrantyMonthNo = json['siteWarrantyMonthNo'];
    extendedWarrantyMonthNo = json['extendedWarrantyMonthNo'];
    remainderWarrantyMonthNo = json['remainderWarrantyMonthNo'];
    eomWarrantyMonthsNo = json['eomWarrantyMonthsNo'];
    warrantyValue = json['warrantyValue'];
    warrantyEndDate = json['warrantyEndDate'];
    warrantyContractConditions = json['warrantyContractConditions'];
    if (json['technicalGuidanceBooks'] != null) {
      technicalGuidanceBooks = [];
      json['technicalGuidanceBooks'].forEach((v) {
        technicalGuidanceBooks!.add(TechnicalGuidanceBook.fromJson(v));
      });
    }
    comment = json['comment'];
    isEnabled = json['isEnabled'];
    tagCode = json['tagCode'];
    if (json['assetAttachments'] != null) {
      assetAttachments = <String>[];
      json['assetAttachments'].forEach((v) {
        assetAttachments!.add(v);
      });
    }
    retirementTypeName = json['retirementTypeName'];
    retirementStatusName = json['retirementStatusName'];
    retirementDate = json['retirementDate'];
    assetGroup = json['assetGroup'] != null ? AssetGroup.fromJson(json['assetGroup']) : null;
    assetPhoto = json['assetPhoto'];
    nextPMDate = json['nextPMDate'];
    lastPMDate = json['lastPMDate'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (multiAssets != null) {
      data['multiAssets'] = multiAssets!.map((v) => v.toJson()).toList();
    }
    data['id'] = id;
    if (modelDefinition != null) {
      data['modelDefinition'] = modelDefinition?.toJson();
    }
    if (supplier != null) {
      data['supplier'] = supplier?.toJson();
    }
    data['ipAddress'] = ipAddress;
    data['macAddress'] = macAddress;
    data['portNumber'] = portNumber;
    if (assetReplace != null) {
      data['assetReplace'] = assetReplace?.toJson();
    }
    data['oldAsset'] = oldAsset?.toJson();
    if (isParent != null) {
      data['isParent'] = isParent?.toJson();
    }
    data['parentAsset'] = parentAsset?.toJson();
    if (assetType != null) {
      data['assetType'] = assetType?.toJson();
    }
    data['demoRequest'] = demoRequest;
    data['missionCritical'] = missionCritical;
    if (site != null) {
      data['site'] = site?.toJson();
    }
    if (building != null) {
      data['building'] = building?.toJson();
    }
    if (floor != null) {
      data['floor'] = floor?.toJson();
    }
    if (department != null) {
      data['department'] = department?.toJson();
    }
    data['room'] = room?.toJson();
    data['testsDay'] = testsDay;
    data['purchasingPrice'] = purchasingPrice;
    data['nbv'] = nbv;
    if (currency != null) {
      data['currency'] = currency?.toJson();
    }
    data['poDate'] = poDate;
    data['poNo'] = poNo;
    data['invoiceNumber'] = invoiceNumber;
    data['invoiceDate'] = invoiceDate;
    data['replacementDate'] = replacementDate;
    data['budgetYear'] = budgetYear;
    data['lastPOPrice'] = lastPOPrice;
    data['commissioningStatus'] = commissioningStatus?.toJson();
    if (originDepartment != null) {
      data['originDepartment'] = originDepartment?.toJson();
    }
    if (originSite != null) {
      data['originSite'] = originSite?.toJson();
    }
    data['productionDate'] = productionDate;
    data['edd'] = edd;
    data['technicalInspectionDate'] = technicalInspectionDate;
    data['deliveryInspectionDate'] = deliveryInspectionDate;
    data['endUserAcceptanceDate'] = endUserAcceptanceDate;
    data['technicalAcceptanceDate'] = technicalAcceptanceDate;
    data['finalAcceptanceDate'] = finalAcceptanceDate;
    data['installationDate'] = installationDate;
    data['siteWarrantyMonthNo'] = siteWarrantyMonthNo;
    data['extendedWarrantyMonthNo'] = extendedWarrantyMonthNo;
    data['remainderWarrantyMonthNo'] = remainderWarrantyMonthNo;
    data['eomWarrantyMonthsNo'] = eomWarrantyMonthsNo;
    data['warrantyValue'] = warrantyValue;
    data['warrantyEndDate'] = warrantyEndDate;
    data['warrantyContractConditions'] = warrantyContractConditions;
    if (technicalGuidanceBooks != null) {
      data['technicalGuidanceBooks'] = technicalGuidanceBooks!.map((v) => v).toList();
    }
    data['comment'] = comment;
    data['isEnabled'] = isEnabled;
    data['tagCode'] = tagCode;
    if (assetAttachments != null) {
      data['assetAttachments'] = assetAttachments!.map((v) => v).toList();
    }
    data['retirementTypeName'] = retirementTypeName;
    data['retirementStatusName'] = retirementStatusName;
    data['retirementDate'] = retirementDate;
    if (assetGroup != null) {
      data['assetGroup'] = assetGroup?.toJson();
    }
    data['assetPhoto'] = assetPhoto;
    data['nextPMDate'] = nextPMDate;
    data['lastPMDate'] = lastPMDate;
    return data;
  }
}

class MultiAssets {
  String? assetSerialNo;
  String? systemID;
  String? assetNumber;

  MultiAssets({this.assetSerialNo, this.systemID, this.assetNumber});

  MultiAssets.fromJson(Map<String, dynamic> json) {
    assetSerialNo = json['assetSerialNo'];
    systemID = json['systemID'];
    assetNumber = json['assetNumber'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['assetSerialNo'] = assetSerialNo;
    data['systemID'] = systemID;
    data['assetNumber'] = assetNumber;
    return data;
  }
}

class ModelDefinition {
  int? id;
  String? assetName;
  String? assetDescription;
  String? modelDefCode;
  String? modelName;
  int? manufacturerId;
  String? manufacturerName;
  String? supplierName;
  String? replacementDate;
  String? essentialEquipement;
  String? businessCritical;
  int? lifeSpan;
  List<ModelDefRelatedDefects>? modelDefRelatedDefects;
  List<Suppliers>? suppliers;

  ModelDefinition(
      {this.id,
      this.assetName,
      this.assetDescription,
      this.modelDefCode,
      this.modelName,
      this.manufacturerId,
      this.manufacturerName,
      this.supplierName,
      this.replacementDate,
      this.essentialEquipement,
      this.businessCritical,
      this.lifeSpan,
      this.modelDefRelatedDefects,
      this.suppliers});

  ModelDefinition.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    assetName = json['assetName'];
    assetDescription = json['assetDescription'];
    modelDefCode = json['modelDefCode'];
    modelName = json['modelName'];
    manufacturerId = json['manufacturerId'];
    manufacturerName = json['manufacturerName'];
    supplierName = json['supplierName'];
    replacementDate = json['replacementDate'];
    essentialEquipement = json['essentialEquipement'];
    businessCritical = json['businessCritical'];
    lifeSpan = json['lifeSpan'];
    if (json['modelDefRelatedDefects'] != null) {
      modelDefRelatedDefects = [];
      json['modelDefRelatedDefects'].forEach((v) {
        modelDefRelatedDefects!.add(ModelDefRelatedDefects.fromJson(v));
      });
    }
    if (json['suppliers'] != null) {
      suppliers = <Suppliers>[];
      json['suppliers'].forEach((v) {
        suppliers!.add(Suppliers.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['assetName'] = assetName;
    data['assetDescription'] = assetDescription;
    data['modelDefCode'] = modelDefCode;
    data['modelName'] = modelName;
    data['manufacturerId'] = manufacturerId;
    data['manufacturerName'] = manufacturerName;
    data['supplierName'] = supplierName;
    data['replacementDate'] = replacementDate;
    data['essentialEquipement'] = essentialEquipement;
    data['businessCritical'] = businessCritical;
    data['lifeSpan'] = lifeSpan;
    if (modelDefRelatedDefects != null) {
      data['modelDefRelatedDefects'] = modelDefRelatedDefects!.map((v) => v.toJson()).toList();
    }
    if (suppliers != null) {
      data['suppliers'] = suppliers!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Suppliers {
  int? id;
  String? suppliername;

  Suppliers({this.id, this.suppliername});

  Suppliers.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    suppliername = json['suppliername'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['suppliername'] = suppliername;
    return data;
  }
}

class AssetReplace {
  int? id;
  String? name;
  int? value;

  AssetReplace({this.id, this.name, this.value});

  AssetReplace.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    data['value'] = value;
    return data;
  }
}

class Site {
  int? id;
  int? customerCode;
  String? custName;
  List<Buildings>? buildings;

  Site({this.id, this.customerCode, this.custName, this.buildings});

  Site.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    customerCode = json['customerCode'];
    custName = json['custName'];
    if (json['buildings'] != null) {
      buildings = <Buildings>[];
      json['buildings'].forEach((v) {
        buildings!.add(Buildings.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['customerCode'] = customerCode;
    data['custName'] = custName;
    if (buildings != null) {
      data['buildings'] = buildings!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Buildings {
  int? id;
  String? name;
  int? value;
  List<Floors>? floors;

  Buildings({this.id, this.name, this.value, this.floors});

  Buildings.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
    if (json['floors'] != null) {
      floors = <Floors>[];
      json['floors'].forEach((v) {
        floors!.add(Floors.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    data['value'] = value;
    if (floors != null) {
      data['floors'] = floors!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Floors {
  int? id;
  String? name;
  int? value;
  List<Departments>? departments;

  Floors({this.id, this.name, this.value, this.departments});

  Floors.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    value = json['value'];
    if (json['departments'] != null) {
      departments = <Departments>[];
      json['departments'].forEach((v) {
        departments!.add(Departments.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    data['value'] = value;
    if (departments != null) {
      data['departments'] = departments!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Departments {
  int? id;
  String? name;

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

  Departments.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    return data;
  }
}

class Department {
  int? id;
  String? departmentName;
  String? departmentCode;
  String? ntCode;

  Department({this.id, this.departmentName, this.departmentCode, this.ntCode});

  Department.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    departmentName = json['departmentName'];
    departmentCode = json['departmentCode'];
    ntCode = json['ntCode'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['departmentName'] = departmentName;
    data['departmentCode'] = departmentCode;
    data['ntCode'] = ntCode;
    return data;
  }
}

class AssetGroup {
  int? id;
  String? name;
  String? code;

  AssetGroup({this.id, this.name, this.code});

  AssetGroup.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    code = json['code'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    data['code'] = code;
    return data;
  }
}

class ModelDefRelatedDefects {
  ModelDefRelatedDefects({
    this.id,
    this.defectName,
    this.workPerformed,
    this.estimatedTime,
  });

  ModelDefRelatedDefects.fromJson(dynamic json) {
    id = json['id'];
    defectName = json['defectName'];
    workPerformed = json['workPerformed'];
    estimatedTime = json['estimatedTime'];
  }

  num? id;
  String? defectName;
  String? workPerformed;
  String? estimatedTime;

  ModelDefRelatedDefects copyWith({
    num? id,
    String? defectName,
    String? workPerformed,
    String? estimatedTime,
  }) =>
      ModelDefRelatedDefects(
        id: id ?? this.id ?? 0,
        defectName: defectName ?? this.defectName,
        workPerformed: workPerformed ?? this.workPerformed,
        estimatedTime: estimatedTime ?? this.estimatedTime,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['defectName'] = defectName;
    map['workPerformed'] = workPerformed;
    map['estimatedTime'] = estimatedTime;
    return map;
  }
}

class AssetInfo {
  AssetInfo({
    this.id,
    this.assetSerialNo,
    this.assetNumber,
    this.tagCode,
    this.systemId,
    this.assetName,
  });

  AssetInfo.fromJson(dynamic json) {
    id = json['id'];
    assetSerialNo = json['assetSerialNo'];
    assetNumber = json['assetNumber'];
    tagCode = json['tagCode'];
    systemId = json['systemId'];
    assetName = json['assetName'];
  }

  num? id;
  String? assetSerialNo;
  String? assetNumber;
  String? tagCode;
  String? systemId;
  String? assetName;

  AssetInfo copyWith({
    num? id,
    String? assetSerialNo,
    String? assetNumber,
    String? tagCode,
    String? systemId,
    String? assetName,
  }) =>
      AssetInfo(
        id: id ?? this.id,
        assetSerialNo: assetSerialNo ?? this.assetSerialNo,
        assetNumber: assetNumber ?? this.assetNumber,
        tagCode: tagCode ?? this.tagCode,
        systemId: systemId ?? this.systemId,
        assetName: assetName ?? this.assetName,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = id;
    map['assetSerialNo'] = assetSerialNo;
    map['assetNumber'] = assetNumber;
    map['tagCode'] = tagCode;
    map['systemId'] = systemId;
    map['assetName'] = assetName;
    return map;
  }
}
