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

class CallRequestForWorkOrder {
  int id;
  String callNo;
  Asset asset;
  AssignedEmployee assignedEmployee;
  List<CallSiteContactPerson> callSiteContactPerson;
  Status status;
  Status callLastSituation;
  Status defectType;
  Status firstAction;
  int assetType;

  CallRequestForWorkOrder(
      {this.id, this.callNo, this.asset, this.assignedEmployee, this.callSiteContactPerson, this.status, this.callLastSituation, this.defectType, this.firstAction, this.assetType});

  CallRequestForWorkOrder.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    callNo = json['callNo'];
    asset = json['asset'] != null ? new Asset.fromJson(json['asset']) : null;
    assignedEmployee = json['assignedEmployee'] != null ? new AssignedEmployee.fromJson(json['assignedEmployee']) : null;
    if (json['callSiteContactPerson'] != null) {
      callSiteContactPerson = <CallSiteContactPerson>[];
      json['callSiteContactPerson'].forEach((v) {
        callSiteContactPerson.add(new CallSiteContactPerson.fromJson(v));
      });
    }
    status = json['status'] != null ? new Status.fromJson(json['status']) : null;
    callLastSituation = json['callLastSituation'] != null ? new Status.fromJson(json['callLastSituation']) : null;
    defectType = json['defectType'] != null ? new Status.fromJson(json['defectType']) : null;
    firstAction = json['firstAction'] != null ? new Status.fromJson(json['firstAction']) : null;
    assetType = json['assetType'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['callNo'] = this.callNo;
    if (this.asset != null) {
      data['asset'] = this.asset.toJson();
    }
    if (this.assignedEmployee != null) {
      data['assignedEmployee'] = this.assignedEmployee.toJson();
    }
    if (this.callSiteContactPerson != null) {
      data['callSiteContactPerson'] = this.callSiteContactPerson.map((v) => v.toJson()).toList();
    }
    if (this.status != null) {
      data['status'] = this.status.toJson();
    }
    if (this.callLastSituation != null) {
      data['callLastSituation'] = this.callLastSituation.toJson();
    }
    if (this.defectType != null) {
      data['defectType'] = this.defectType.toJson();
    }
    if (this.firstAction != null) {
      data['firstAction'] = this.firstAction.toJson();
    }
    data['assetType'] = this.assetType;
    return data;
  }
}

class Asset {
  int id;
  String assetSerialNo;
  String systemID;
  String assetNumber;
  ModelDefinition modelDefinition;
  String supplier;
  String ipAddress;
  String macAddress;
  String portNumber;
  Lookup assetReplace;
  String oldAsset;
  Lookup isParent;
  String parentAsset;
  Lookup assetType;
  Site site;
  Building building;
  String floor;
  Department department;
  String room;
  String testsDay;
  num purchasingPrice;
  String nbv;
  String currency;
  String poNo;
  String invoiceNumber;
  String invoiceDate;
  String replacementDate;
  Department originDepartment;
  Site originSite;
  String budgetYear;
  String lastPOPrice;
  String commissioningStatus;
  String productionDate;
  String edd;
  String technicalInspectionDate;
  String deliveryInspectionDate;
  String endUserAcceptanceDate;
  String receivingCommittee;
  String siteWarrantyMonths;
  String extendedWarrantyMonths;
  String remainderWarrantyMonths;
  String eomWarrantyMonthsNo;
  String warrantyValue;
  String warrantyEndDate;
  String warrantyContractConditions;
  List technicalGuidanceBooks;
  String comment;
  String tagCode;

  Asset(
      {this.id,
      this.assetSerialNo,
      this.systemID,
      this.assetNumber,
      this.modelDefinition,
      this.supplier,
      this.ipAddress,
      this.macAddress,
      this.portNumber,
      this.assetReplace,
      this.oldAsset,
      this.isParent,
      this.parentAsset,
      this.assetType,
      this.site,
      this.building,
      this.floor,
      this.department,
      this.room,
      this.testsDay,
      this.purchasingPrice,
      this.nbv,
      this.currency,
      this.poNo,
      this.invoiceNumber,
      this.invoiceDate,
      this.replacementDate,
      this.originDepartment,
      this.originSite,
      this.budgetYear,
      this.lastPOPrice,
      this.commissioningStatus,
      this.productionDate,
      this.edd,
      this.technicalInspectionDate,
      this.deliveryInspectionDate,
      this.endUserAcceptanceDate,
      this.receivingCommittee,
      this.siteWarrantyMonths,
      this.extendedWarrantyMonths,
      this.remainderWarrantyMonths,
      this.eomWarrantyMonthsNo,
      this.warrantyValue,
      this.warrantyEndDate,
      this.warrantyContractConditions,
      this.technicalGuidanceBooks,
      this.comment,
      this.tagCode});

  Asset.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    assetSerialNo = json['assetSerialNo'];
    systemID = json['systemID'];
    assetNumber = json['assetNumber'];
    modelDefinition = json['modelDefinition'] != null ? new ModelDefinition.fromJson(json['modelDefinition']) : null;
    supplier = json['supplier'];
    ipAddress = json['ipAddress'];
    macAddress = json['macAddress'];
    portNumber = json['portNumber'];
    assetReplace = json['assetReplace'] != null ? Lookup.fromJson(json['assetReplace']) : null;
    oldAsset = json['oldAsset'];
    isParent = json['isParent'] != null ? Lookup.fromJson(json['isParent']) : null;
    parentAsset = json['parentAsset'];
    assetType = json['assetType'] != null ? Lookup.fromJson(json['assetType']) : null;
    site = json['site'] != null ? new Site.fromJson(json['site']) : null;
    building = json['building'];
    floor = json['floor'];
    department = json['department'] != null ? new Department.fromJson(json['department']) : null;
    room = json['room'];
    testsDay = json['testsDay'];
    purchasingPrice = json['purchasingPrice'];
    nbv = json['nbv'];
    currency = json['currency'];
    poNo = json['poNo'];
    invoiceNumber = json['invoiceNumber'];
    invoiceDate = json['invoiceDate'];
    replacementDate = json['replacementDate'];
    originDepartment = json['originDepartment'] != null ? new Department.fromJson(json['originDepartment']) : null;
    originSite = json['originSite'] != null ? new Site.fromJson(json['originSite']) : null;
    budgetYear = json['budgetYear'];
    lastPOPrice = json['lastPOPrice'];
    commissioningStatus = json['commissioningStatus'];
    productionDate = json['productionDate'];
    edd = json['edd'];
    technicalInspectionDate = json['technicalInspectionDate'];
    deliveryInspectionDate = json['deliveryInspectionDate'];
    endUserAcceptanceDate = json['endUserAcceptanceDate'];
    receivingCommittee = json['receivingCommittee'];
    siteWarrantyMonths = json['siteWarrantyMonths'];
    extendedWarrantyMonths = json['extendedWarrantyMonths'];
    remainderWarrantyMonths = json['remainderWarrantyMonths'];
    eomWarrantyMonthsNo = json['eomWarrantyMonthsNo'];
    warrantyValue = json['warrantyValue'];
    warrantyEndDate = json['warrantyEndDate'];
    warrantyContractConditions = json['warrantyContractConditions'];
    if (json['technicalGuidanceBooks'] != null) {
      technicalGuidanceBooks = [];
      json['technicalGuidanceBooks'].forEach((v) {
        //technicalGuidanceBooks.add(new Null.fromJson(v));
      });
    }
    comment = json['comment'];
    tagCode = json['tagCode'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['assetSerialNo'] = this.assetSerialNo;
    data['systemID'] = this.systemID;
    data['assetNumber'] = this.assetNumber;
    if (this.modelDefinition != null) {
      data['modelDefinition'] = this.modelDefinition.toJson();
    }
    data['supplier'] = this.supplier;
    data['ipAddress'] = this.ipAddress;
    data['macAddress'] = this.macAddress;
    data['portNumber'] = this.portNumber;
    data['assetReplace'] = this.assetReplace;
    data['oldAsset'] = this.oldAsset;
    data['isParent'] = this.isParent;
    data['parentAsset'] = this.parentAsset;
    data['assetType'] = this.assetType;
    if (this.site != null) {
      data['site'] = this.site.toJson();
    }
    data['building'] = this.building;
    data['floor'] = this.floor;
    if (this.department != null) {
      data['department'] = this.department.toJson();
    }
    data['room'] = this.room;
    data['testsDay'] = this.testsDay;
    data['purchasingPrice'] = this.purchasingPrice;
    data['nbv'] = this.nbv;
    data['currency'] = this.currency;
    data['poNo'] = this.poNo;
    data['invoiceNumber'] = this.invoiceNumber;
    data['invoiceDate'] = this.invoiceDate;
    data['replacementDate'] = this.replacementDate;
    if (this.originDepartment != null) {
      data['originDepartment'] = this.originDepartment.toJson();
    }
    if (this.originSite != null) {
      data['originSite'] = this.originSite.toJson();
    }
    data['budgetYear'] = this.budgetYear;
    data['lastPOPrice'] = this.lastPOPrice;
    data['commissioningStatus'] = this.commissioningStatus;
    data['productionDate'] = this.productionDate;
    data['edd'] = this.edd;
    data['technicalInspectionDate'] = this.technicalInspectionDate;
    data['deliveryInspectionDate'] = this.deliveryInspectionDate;
    data['endUserAcceptanceDate'] = this.endUserAcceptanceDate;
    data['receivingCommittee'] = this.receivingCommittee;
    data['siteWarrantyMonths'] = this.siteWarrantyMonths;
    data['extendedWarrantyMonths'] = this.extendedWarrantyMonths;
    data['remainderWarrantyMonths'] = this.remainderWarrantyMonths;
    data['eomWarrantyMonthsNo'] = this.eomWarrantyMonthsNo;
    data['warrantyValue'] = this.warrantyValue;
    data['warrantyEndDate'] = this.warrantyEndDate;
    data['warrantyContractConditions'] = this.warrantyContractConditions;
    if (this.technicalGuidanceBooks != null) {
      data['technicalGuidanceBooks'] = this.technicalGuidanceBooks.map((v) => v.toJson()).toList();
    }
    data['comment'] = this.comment;
    data['tagCode'] = this.tagCode;
    return data;
  }
}

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

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

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

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

class ModelDefRelatedDefects {
  int id;
  String defectName;
  String workPerformed;
  String estimatedTime;

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

  ModelDefRelatedDefects.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    defectName = json['defectName'];
    workPerformed = json['workPerformed'];
    estimatedTime = json['estimatedTime'];
  }

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

class Site {
  int id;
  int customerCode;
  String custName;
  List 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 = [];
      json['buildings'].forEach((v) {
        // buildings!.add(new Null.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['customerCode'] = this.customerCode;
    data['custName'] = this.custName;
    if (this.buildings != null) {
      data['buildings'] = this.buildings.map((v) => v.toJson()).toList();
    }
    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 AssignedEmployee {
  String id;
  String name;

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

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

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

class CallSiteContactPerson {
  int id;
  String employeeCode;
  String name;
  String telephone;
  String job;
  String email;
  String land;
  String contactUserId;

  CallSiteContactPerson({this.id, this.employeeCode, this.name, this.telephone, this.job, this.email, this.land, this.contactUserId});

  CallSiteContactPerson.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    employeeCode = json['employeeCode'];
    name = json['name'];
    telephone = json['telephone'];
    job = json['job'];
    email = json['email'];
    land = json['land'];
    contactUserId = json['contactUserId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['employeeCode'] = this.employeeCode;
    data['name'] = this.name;
    data['telephone'] = this.telephone;
    data['job'] = this.job;
    data['email'] = this.email;
    data['land'] = this.land;
    data['contactUserId'] = this.contactUserId;
    return data;
  }
}

class Status {
  int id;
  String name;
  int value;

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

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

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

class Building {
  int id;
  String name;
  int value;
  var floor;

  Building({this.id, this.name, this.value, this.floor});

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

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