import 'dart:developer';

import 'package:test_sa/models/lookup.dart';
import 'package:test_sa/modules/asset_delivery_module/models/cost_center_model.dart';

class TechnicalInspectionFormModel {
  Lookup? powerSupplyType;
  num? powerReading;
  num? maxCurrent;
  num? voltage;
  num? frequency;
  List<CostCenterModel>? costCenters;
  int? tableItemId;
  int? lineId;

  TechnicalInspectionFormModel({
    this.powerSupplyType,
    this.powerReading,
    this.maxCurrent,
    this.voltage,
    this.frequency,
    this.costCenters,
    this.lineId,
    this.tableItemId,
  });

  TechnicalInspectionFormModel.fromJson(Map<String, dynamic> json) {
    powerSupplyType = json["powerSupplyType"] == null ? null : Lookup.fromJson(json["powerSupplyType"]);
    powerReading = json['powerReading'];
    maxCurrent = json['maxCurrent'];
    voltage = json['voltage'];
    frequency = json['frequency'];
    if (json['costCenters'] != null) {
      costCenters = <CostCenterModel>[];
      json['costCenters'].forEach((v) {
        costCenters!.add(CostCenterModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = {};
    data['powerSupplyTypeId'] = powerSupplyType?.id;
    data['assetDeliveryExternalDeliveryId'] = tableItemId;
    data['assetDeliveryExternalDetailId'] = lineId;
    data['powerReading'] = powerReading;
    data['maxCurrent'] = maxCurrent;
    data['voltage'] = voltage;
    data['frequency'] = frequency;
    // data['costCenters'] = costCenters != null ? costCenters!.map((v) => v.toJson()).toList() : [];
    return data;
  }
}
