import 'package:test_sa/models/service_request/supp_engineer_work_orders.dart';
import 'package:test_sa/models/service_request/supplier_details.dart';

import '../lookup.dart';

class WoParent {
  WoParent({
    this.callLastSituation,
    this.supplier,
    this.assetType,
    this.vendorTicketNumber,
    this.callId,
    this.id,
    this.stepsWorkOrder,
    this.suppEngineerWorkOrders,
    this.equipmentStatus,
    this.currentSituation,
  });

  WoParent.fromJson(dynamic json) {
    callLastSituation = json['callLastSituation'] != null ? Lookup.fromJson(json['callLastSituation']) : null;
    supplier = json['supplier'] != null ? SupplierDetails.fromJson(json['supplier']) : null;
    assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
    vendorTicketNumber = json['vendorTicketNumber'];
    callId = json['callId'];
    id = json['id'];
    stepsWorkOrder = json['stepsWorkOrderDto'] != null ? StepsWorkOrder.fromJson(json['stepsWorkOrderDto']) : null;
    if (json['suppEngineerWorkOrders'] != null) {
      suppEngineerWorkOrders = [];
      json['suppEngineerWorkOrders'].forEach((v) {
        suppEngineerWorkOrders!.add(SuppEngineerWorkOrders.fromJson(v));
      });
    }
    equipmentStatus = json['equipmentStatus'] != null ? Lookup.fromJson(json['equipmentStatus']) : null;
    currentSituation = json['currentSituation'] != null ? Lookup.fromJson(json['currentSituation']) : null;
  }

  Lookup? callLastSituation;
  SupplierDetails? supplier;
  Lookup? assetType;
  String? vendorTicketNumber;
  num? callId;
  num? id;
  StepsWorkOrder? stepsWorkOrder;
  List<SuppEngineerWorkOrders>? suppEngineerWorkOrders;
  Lookup? equipmentStatus;
  Lookup? currentSituation;

  WoParent copyWith({
    Lookup? callLastSituation,
    SupplierDetails? supplier,
    Lookup? assetType,
    String? vendorTicketNumber,
    num? callId,
    num? id,
    StepsWorkOrder? stepsWorkOrder,
    List<SuppEngineerWorkOrders>? suppEngineerWorkOrders,
    Lookup? equipmentStatus,
    Lookup? currentSituation,
  }) =>
      WoParent(
        callLastSituation: callLastSituation ?? this.callLastSituation,
        supplier: supplier ?? this.supplier,
        assetType: assetType ?? this.assetType,
        vendorTicketNumber: vendorTicketNumber ?? this.vendorTicketNumber,
        callId: callId ?? this.callId,
        id: id ?? this.id,
        stepsWorkOrder: stepsWorkOrder ?? this.stepsWorkOrder,
        suppEngineerWorkOrders: suppEngineerWorkOrders ?? this.suppEngineerWorkOrders,
        equipmentStatus: equipmentStatus ?? this.equipmentStatus,
        currentSituation: currentSituation ?? this.currentSituation,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (callLastSituation != null) {
      map['callLastSituation'] = callLastSituation!.toJson();
    }
    if (supplier != null) {
      map['supplier'] = supplier!.toJson();
    }
    if (assetType != null) {
      map['assetType'] = assetType!.toJson();
    }
    map['vendorTicketNumber'] = vendorTicketNumber;
    map['callId'] = callId;
    map['id'] = id;
    if (stepsWorkOrder != null) {
      map['stepsWorkOrderDto'] = stepsWorkOrder!.toJson();
    }
    if (suppEngineerWorkOrders != null) {
      map['suppEngineerWorkOrders'] = suppEngineerWorkOrders!.map((v) => v.toJson()).toList();
    }
    if (equipmentStatus != null) {
      map['equipmentStatus'] = equipmentStatus!.toJson();
    }
    if (currentSituation != null) {
      map['currentSituation'] = currentSituation!.toJson();
    }
    return map;
  }
}

class StepsWorkOrder {
  StepsWorkOrder({this.sequence, this.id, this.name, this.statusValue, this.typeTransaction, this.processed, this.parentWOId, this.callId});

  StepsWorkOrder.fromJson(dynamic json) {
    sequence = json['sequence'];
    id = json['id'];
    name = json['name'];
    statusValue = json['statusValue'];
    typeTransaction = json['typeTransaction'];
    processed = json['processed'];
    parentWOId = json['parentWOId'];
    callId = json['callId'];
  }

  num? sequence;
  num? id;
  String? name;
  num? statusValue;
  String? typeTransaction;
  bool? processed;
  num? parentWOId;
  num? callId;

  StepsWorkOrder copyWith({
    num? sequence,
    num? id,
    String? name,
    num? statusValue,
    String? typeTransaction,
    bool? processed,
    num? parentWOId,
    num? callId,
  }) =>
      StepsWorkOrder(
        sequence: sequence ?? this.sequence,
        id: id ?? this.id,
        name: name ?? this.name,
        statusValue: statusValue ?? this.statusValue,
        typeTransaction: typeTransaction ?? this.typeTransaction,
        processed: processed ?? this.processed,
        parentWOId: parentWOId ?? this.parentWOId,
        callId: callId ?? this.callId,
      );

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['sequence'] = sequence;
    map['id'] = id;
    map['name'] = name;
    map['statusValue'] = statusValue;
    map['typeTransaction'] = typeTransaction;
    map['processed'] = processed;
    map['parentWOId'] = parentWOId;
    map['callId'] = callId;
    return map;
  }
}
