import 'package:test_sa/models/fault_description.dart';
import 'package:test_sa/models/helper_data_models/spare_part/activity_spare_part_model.dart';
import 'package:test_sa/models/helper_data_models/workorder/work_order_helper_models.dart';
import 'package:test_sa/models/lookup.dart';

class WorkOrderDetail {
  WorkOrderDetail({
    required this.data,
    required this.message,
    required this.title,
    required this.innerMessage,
    required this.responseCode,
    required this.isSuccess,
  });

  final WorkOrderData? data;
  final String? message;
  final dynamic title;
  final dynamic innerMessage;
  final int? responseCode;
  final bool? isSuccess;

  factory WorkOrderDetail.fromJson(Map<String, dynamic> json) {
    return WorkOrderDetail(
      data: json["data"] == null ? null : WorkOrderData.fromJson(json["data"]),
      message: json["message"],
      title: json["title"],
      innerMessage: json["innerMessage"],
      responseCode: json["responseCode"],
      isSuccess: json["isSuccess"],
    );
  }

  Map<String, dynamic> toJson() => {
        "data": data?.toJson(),
        "message": message,
        "title": title,
        "innerMessage": innerMessage,
        "responseCode": responseCode,
        "isSuccess": isSuccess,
      };
}

class WorkOrderData {
  WorkOrderData({
    this.requestId,
    required this.workOrderNo,
    required this.workOrderCreatedBy,
    required this.requestedDate,
    required this.asset,
    required this.assetGroup,
    required this.manufacturer,
    required this.model,
    required this.assetNdModel,
    required this.site,
    required this.building,
    required this.floor,
    required this.department,
    required this.room,
    required this.assetType,
    required this.assignedEmployee,
    required this.lastActivityStatus,
    required this.status,
    required this.setReminder,
    required this.nextStep,
    required this.assetVerificationType,
    required this.workOrderContactPerson,
    required this.equipmentStatus,
    required this.priority,
    required this.requestedThrough,
    required this.typeofRequest,
    required this.loanAvailablity,
    required this.assetLoan,
    required this.safety,
    required this.problemDescription,
    required this.faultDescription,
    required this.comments,
    required this.voiceNote,
    required this.workOrderAttachments,
    required this.returnToService,
    required this.serviceType,
    required this.failureReasone,
    required this.solution,
    required this.totalWorkingHours,
    this.needAVisitComment,
    this.needAVisitDateTime,
    this.iHaveArrivedDate,
    this.rejectReason,
    this.closedDate,
    this.since,
    this.cmFrame,
    this.rejectComment,
    this.callResponse,
    required this.workOrderHistory,
    required this.activities,
    required this.activityAssetToBeRetireds,
  });

  int? requestId;
  String? workOrderNo;
  WorkOrderAssignedEmployee? workOrderCreatedBy;
  DateTime? requestedDate;
  WorkOrderAsset? asset;
  Lookup? assetGroup;
  Lookup? manufacturer;
  Lookup? model;
  Lookup? assetNdModel;
  Site? site;
  Lookup? building;
  Lookup? floor;
  AssetGroup? department;
  int? room;
  Lookup? assetType;
  WorkOrderAssignedEmployee? assignedEmployee;
  Lookup? lastActivityStatus;
  Lookup? status;
  Lookup? setReminder;
  Lookup? nextStep;
  int? assetVerificationType;
  List<WorkOrderContactPerson> workOrderContactPerson;
  Lookup? equipmentStatus;
  Lookup? priority;
  Lookup? requestedThrough;
  Lookup? typeofRequest;
  Lookup? loanAvailablity;
  AssetLoan? assetLoan;
  Lookup? safety;
  Lookup? problemDescription;
  String? comments;
  String? voiceNote;
  List<WorkOrderAttachments> workOrderAttachments;
  String? returnToService;
  Lookup? serviceType;
  Lookup? failureReasone;
  FaultDescription? faultDescription;
  Lookup? solution;
  Lookup? cmFrame;

  //cmComments
  String? totalWorkingHours;
  DateTime? needAVisitDateTime;
  String? needAVisitComment;
  String? iHaveArrivedDate;
  String? closedDate;
  Lookup? rejectReason;
  String? rejectComment; // need to replace with reject comments.
  String? callResponse; // need to replace with reject comments.
  int? since;
  List<WorkOrderHistory> workOrderHistory;
  List<Activities> activities;
  List<dynamic> activityAssetToBeRetireds;

  factory WorkOrderData.fromJson(Map<String, dynamic> json) {
    return WorkOrderData(
      requestId: json["id"],
      workOrderNo: json["workOrderNo"],
      workOrderCreatedBy: json["workOrderCreatedBy"] == null ? null : WorkOrderAssignedEmployee.fromJson(json["workOrderCreatedBy"]),
      requestedDate: DateTime.tryParse(json["requestedDate"] ?? ""),
      asset: json["asset"] == null ? null : WorkOrderAsset.fromJson(json["asset"]),
      assetGroup: json["assetGroup"] == null ? null : Lookup.fromJson(json["assetGroup"]),
      manufacturer: json["manufacturer"] == null ? null : Lookup.fromJson(json["manufacturer"]),
      model: json["model"] == null ? null : Lookup.fromJson(json["model"]),
      assetNdModel: json["assetNDModel"] == null ? null : Lookup.fromJson(json["assetNDModel"]),
      site: json["site"] == null ? null : Site.fromJson(json["site"]),
      building: json["building"] == null ? null : Lookup.fromJson(json["building"]),
      floor: json["floor"] == null ? null : Lookup.fromJson(json["floor"]),
      department: json["department"] == null ? null : AssetGroup.fromJson(json["department"]),
      room: json["room"],
      rejectComment: json["rejectComment"],
      callResponse: json["callResponse"],
      iHaveArrivedDate: json["iHaveArrivedDate"],
      closedDate: json["closedDate"],
      cmFrame: json["cmFrame"] == null ? null : Lookup.fromJson(json["cmFrame"]),
      rejectReason: json["rejectReason"] == null ? null : Lookup.fromJson(json["rejectReason"]),
      since: json['since'],
      assetType: json["assetType"] == null ? null : Lookup.fromJson(json["assetType"]),
      assignedEmployee: json["assignedEmployee"] == null ? null : WorkOrderAssignedEmployee.fromJson(json["assignedEmployee"]),
      lastActivityStatus: json["lastActivityStatus"] != null ? Lookup.fromJson(json["lastActivityStatus"]) : null,
      status: json["status"] == null ? null : Lookup.fromJson(json["status"]),
      setReminder: json["setReminder"] == null ? null : Lookup.fromJson(json["setReminder"]),
      nextStep: json["nextStep"] == null ? null : Lookup.fromJson(json["nextStep"]),
      assetVerificationType: json["assetVerificationType"],
      workOrderContactPerson: json["workOrderContactPerson"] == null ? [] : List<WorkOrderContactPerson>.from(json["workOrderContactPerson"]!.map((x) => WorkOrderContactPerson.fromJson(x))),
      equipmentStatus: json["equipmentStatus"] == null ? null : Lookup.fromJson(json["equipmentStatus"]),
      priority: json["priority"] == null ? null : Lookup.fromJson(json["priority"]),
      requestedThrough: json["requestedThrough"] == null ? null : Lookup.fromJson(json["requestedThrough"]),
      typeofRequest: json["typeofRequest"] == null ? null : Lookup.fromJson(json["typeofRequest"]),
      loanAvailablity: json["loanAvailablity"] == null ? null : Lookup.fromJson(json["loanAvailablity"]),
      assetLoan: json["assetLoan"] == null ? null : AssetLoan.fromJson(json["assetLoan"]),
      safety: json["safety"] == null ? null : Lookup.fromJson(json["safety"]),
      problemDescription: json["problemDescription"] == null ? null : Lookup.fromJson(json["problemDescription"]),
      comments: json["comments"],
      voiceNote: json["voiceNote"],
      workOrderAttachments: json["workOrderAttachments"] == null ? [] : List.from(json['workOrderAttachments']).map((e) => WorkOrderAttachments.fromJson(e)).toList(),
      returnToService: json["returnToService"],
      serviceType: json["serviceType"] == null ? null : Lookup.fromJson(json["serviceType"]),
      failureReasone: json["failureReasone"] == null ? null : Lookup.fromJson(json["failureReasone"]),
      faultDescription: json["faultDescription"] == null ? null : FaultDescription.fromJson(json["faultDescription"]),
      solution: json["solution"] == null ? null : Lookup.fromJson(json["solution"]),
      totalWorkingHours: (json["totalWorkingHours"] ?? "").toString(),
      workOrderHistory: json["workOrderHistory"] == null ? [] : List<WorkOrderHistory>.from(json["workOrderHistory"]!.map((x) => WorkOrderHistory.fromJson(x))),
      activities: json["activities"] == null ? [] : List<Activities>.from(json["activities"]!.map((x) => Activities.fromJson(x))),
      needAVisitDateTime: DateTime.tryParse(json["needAVisitDateTime"] ?? ""),
      needAVisitComment: json["needAVisitComment"],
      activityAssetToBeRetireds: json["activityAssetToBeRetireds"] == null ? [] : List<dynamic>.from(json["activityAssetToBeRetireds"]!.map((x) => x)),
    );
  }

  Map<String, dynamic> toJson() => {
        "id": requestId,
        "workOrderNo": workOrderNo,
        "workOrderCreatedBy": workOrderCreatedBy?.toJson(),
        "requestedDate": requestedDate?.toIso8601String(),
        "needAVisitDateTime": needAVisitDateTime?.toIso8601String(),
        "asset": asset?.toJson(),
        "assetGroup": assetGroup?.toJson(),
        "manufacturer": manufacturer?.toJson(),
        "model": model?.toJson(),
        "assetNDModel": assetNdModel?.toJson(),
        "site": site?.toJson(),
        "building": building?.toJson(),
        "floor": floor?.toJson(),
        "department": department?.toJson(),
        "room": room,
        "assetType": assetType?.toJson(),
        "assignedEmployee": assignedEmployee?.toJson(),
        "lastActivityStatus": lastActivityStatus,
        "status": status?.toJson(),
        "setReminder": setReminder?.toJson(),
        "nextStep": nextStep?.toJson(),
        "assetVerificationType": assetVerificationType,
        "workOrderContactPerson": workOrderContactPerson.map((x) => x?.toJson()).toList(),
        "equipmentStatus": equipmentStatus?.toJson(),
        "priority": priority?.toJson(),
        "requestedThrough": requestedThrough?.toJson(),
        "typeofRequest": typeofRequest?.toJson(),
        "loanAvailablity": loanAvailablity?.toJson(),
        "assetLoan": assetLoan?.toJson(),
        "safety": safety?.toJson(),
        "problemDescription": problemDescription?.toJson(),
        "comments": comments,
        "voiceNote": voiceNote,
        "workOrderAttachments": workOrderAttachments.map((e) => e.toJson()).toList(),
        "returnToService": returnToService,
        "serviceType": serviceType?.toJson(),
        "failureReasone": failureReasone?.toJson(),
        "solution": solution?.toJson(),
        "totalWorkingHours": totalWorkingHours,
        "workOrderHistory": workOrderHistory.map((x) => x.toJson()).toList(),
        "activities": activities.map((x) => x.toJson()).toList(),
        "activityAssetToBeRetireds": activityAssetToBeRetireds.map((x) => x).toList(),
      };
}

class WorkOrderAsset {
  WorkOrderAsset({
    required this.id,
    required this.assetNumber,
  });

  int? id;
  String? assetNumber;

  factory WorkOrderAsset.fromJson(Map<String, dynamic> json) {
    return WorkOrderAsset(
      id: json["id"],
      assetNumber: json["assetNumber"],
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "assetNumber": assetNumber,
      };
}

class AssetGroup {
  AssetGroup({
    required this.id,
    required this.name,
  });

  int? id;
  String? name;

  factory AssetGroup.fromJson(Map<String, dynamic> json) {
    return AssetGroup(
      id: json["id"],
      name: json["name"],
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
      };
}

class WorkOrderAssignedEmployee {
  WorkOrderAssignedEmployee({
    required this.userId,
    required this.userName,
    required this.email,
    required this.languageId,
  });

  String userId;
  String? userName;
  String? email;
  int? languageId;

  factory WorkOrderAssignedEmployee.fromJson(Map<String, dynamic> json) {
    return WorkOrderAssignedEmployee(
      userId: json["userId"],
      userName: json["userName"],
      email: json["email"],
      languageId: json["languageId"],
    );
  }

  Map<String, dynamic> toJson() => {
        "userId": userId,
        "userName": userName,
        "email": email,
        "languageId": languageId,
      };
}

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

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

  factory AssetLoan.fromJson(Map<String, dynamic> json) {
    return AssetLoan(
      id: json["id"],
      tagCode: json["tagCode"],
      systemId: json["systemId"],
      assetSerialNo: json["assetSerialNo"],
      assetNumber: json["assetNumber"],
      assetName: json["assetName"],
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "assetName": assetName,
        "assetNumber": assetNumber,
        "assetSerialNo": assetSerialNo,
        "tagCode": tagCode,
        "systemId": systemId,
      };
}

class Activities {
  int? id;
  int? orderNo;
  Lookup? activityStatus;
  ActivityMaintenance? activityMaintenance;
  ActivitySparePart? activitySparePart;
  String? activityType;

  Activities({this.id, this.orderNo, this.activityStatus, this.activityMaintenance, this.activityType, this.activitySparePart});

  Activities.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    orderNo = json['orderNo'];
    activityStatus = json['activityStatus'] != null ? Lookup.fromJson(json['activityStatus']) : null;
    activityMaintenance = json['activityMaintenance'] != null ? ActivityMaintenance.fromJson(json['activityMaintenance']) : null;
    if (activityMaintenance != null) {
      activityType = 'CM Activity';
    }

    activitySparePart = json['activitySparePart'] != null ? ActivitySparePart.fromJson(json['activitySparePart']) : null;
    if (activitySparePart != null) {
      activityType = 'Spare Part Request';
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['orderNo'] = orderNo;
    if (activityStatus != null) {
      data['activityStatus'] = activityStatus!.toJson();
    }
    if (activitySparePart != null) {
      data['activitySparePart'] = activitySparePart!.toJson();
    }
    if (activityMaintenance != null) {
      data['activityMaintenance'] = activityMaintenance!.toJson();
    }
    return data;
  }
}

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

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

  ActivityStatus.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 ActivitySparePart {
  int? id;
  PartCatalogItem? partCatalogItem;
  double? quantity;
  String? comment;
  List<SparePartAttachments>? acitiySparePartAttachments;

  ActivitySparePart({this.id, this.partCatalogItem, this.quantity, this.comment, this.acitiySparePartAttachments});

  ActivitySparePart.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    partCatalogItem = json['partCatalogItem'] != null ? new PartCatalogItem.fromJson(json['partCatalogItem']) : null;
    quantity = json['quantity'];
    comment = json['comment'];
    if (json['acitiySparePartAttachments'] != null) {
      acitiySparePartAttachments = <SparePartAttachments>[];
      json['acitiySparePartAttachments'].forEach((v) {
        acitiySparePartAttachments!.add(SparePartAttachments.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    if (partCatalogItem != null) {
      data['partCatalogItem'] = partCatalogItem!.toJson();
    }
    data['quantity'] = quantity;
    data['comment'] = comment;
    if (acitiySparePartAttachments != null) {
      data['acitiySparePartAttachments'] = acitiySparePartAttachments!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class PartCatalogItem {
  int? id;
  String? partName;
  String? partNumber;
  String? oracleCode;

  PartCatalogItem({this.id, this.partName, this.partNumber, this.oracleCode});

  PartCatalogItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    partName = json['partName'];
    partNumber = json['partNumber'];
    oracleCode = json['oracleCode'];
  }

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

class Site {
  Site({
    required this.id,
    required this.siteName,
  });

  int? id;
  String? siteName;

  factory Site.fromJson(Map<String, dynamic> json) {
    return Site(
      id: json["id"],
      siteName: json["siteName"],
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "siteName": siteName,
      };
}

class WorkOrderContactPerson {
  WorkOrderContactPerson({
    required this.id,
    required this.name,
    required this.employeeId,
    required this.position,
    required this.extension,
    required this.email,
    required this.mobilePhone,
    required this.contactUser,
  });

  int? id;
  String? name;
  String? employeeId;
  String? position;
  String? extension;
  String? email;
  String ?mobilePhone;
  WorkOrderAssignedEmployee? contactUser;

  factory WorkOrderContactPerson.fromJson(Map<String, dynamic> json) {
    return WorkOrderContactPerson(
      id: json["id"],
      name: json["name"],
      employeeId: json["employeeId"],
      position: json["position"],
      extension: json["extension"],
      email: json["email"],
      mobilePhone: json["mobilePhone"],
      contactUser: json["contactUser"] == null ? null : WorkOrderAssignedEmployee.fromJson(json["contactUser"]),
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "employeeId": employeeId,
        "position": position,
        "extension": extension,
        "email": email,
        "mobilePhone": mobilePhone,
        "contactUser": contactUser?.toJson(),
      };
}

class WorkOrderHistory {
  WorkOrderHistory({
    required this.id,
    required this.workorderStatus,
    this.assetVerificationType,
    this.photoVerfication,
    required this.activityStatus,
    required this.date,
    required this.timeDifference,
    required this.user,
    required this.step,
    required this.fixRemotlyStartTime,
    required this.fixRemotlyEndTime,
    required this.fixRemotlyWorkingHours,
    required this.comments,
    required this.needAVisitDateTime,
  });

  int? id;
  Lookup? workorderStatus;
  Lookup? assetVerificationType;
  Lookup? activityStatus;
  DateTime? date;
  String timeDifference = '';
  String? photoVerfication;
  WorkOrderAssignedEmployee? user;
  Lookup? step;
  DateTime? fixRemotlyStartTime;
  DateTime? fixRemotlyEndTime;
  num? fixRemotlyWorkingHours;
  String? comments;
  DateTime? needAVisitDateTime;

  factory WorkOrderHistory.fromJson(Map<String, dynamic> json) {
    return WorkOrderHistory(
      id: json["id"],
      workorderStatus: json["workorderStatus"] == null ? null : Lookup.fromJson(json["workorderStatus"]),
      assetVerificationType: json["assetVerificationType"] == null ? null : Lookup.fromJson(json["assetVerificationType"]),
      activityStatus: json["activityStatus"] == null ? null : Lookup.fromJson(json["activityStatus"]),
      photoVerfication: json["photoVerfication"],
      date: DateTime.tryParse(json["date"] ?? ""),
      user: json["user"] == null ? null : WorkOrderAssignedEmployee.fromJson(json["user"]),
      step: json["step"] == null ? null : Lookup.fromJson(json["step"]),
      fixRemotlyStartTime: DateTime.tryParse(json["fixRemotlyStartTime"] ?? ""),
      fixRemotlyEndTime: DateTime.tryParse(json["fixRemotlyEndTime"] ?? ""),
      fixRemotlyWorkingHours: json["fixRemotlyWorkingHours"],
      timeDifference: '',
      comments: json["comments"],
      needAVisitDateTime: DateTime.tryParse(json["needAVisitDateTime"] ?? ""),
    );
  }

  Map<String, dynamic> toJson() => {
        "id": id,
        "workorderStatus": workorderStatus?.toJson(),
        "assetVerificationType": assetVerificationType?.toJson(),
        "photoVerfication": photoVerfication,
        "activityStatus": activityStatus?.toJson(),
        "date": date?.toIso8601String(),
        "user": user?.toJson(),
        "step": step?.toJson(),
        "fixRemotlyStartTime": fixRemotlyStartTime?.toIso8601String(),
        "fixRemotlyEndTime": fixRemotlyEndTime?.toIso8601String(),
        "fixRemotlyWorkingHours": fixRemotlyWorkingHours,
        "comments": comments,
        "needAVisitDateTime": needAVisitDateTime?.toIso8601String(),
      };
}

class ActivityMaintenance {
  int? id;
  ActivityStatus? activityStatus;
  String? startTime;
  Lookup? lastSituation;
  String? endTime;
  double? workingHours;
  double? travelHours;
  Lookup? repairLocation;
  AssignedEmployee? assignedEmployee;
  String? technicalComment;
  Lookup? supplier;
  Lookup? supplierEngineer;
  String? supplierStartTime;
  String? supplierEndTime;
  double? supplierWorkingHours;
  String? activityType;
  List<ActivityMaintenanceAssistantEmployees>? assistantEmployees;
  List<ActivityMaintenanceTimers>? activityMaintenanceTimers;

  ActivityMaintenance(
      {this.id,
      this.activityStatus,
      this.lastSituation,
      this.startTime,
      this.endTime,
      this.workingHours,
      this.travelHours,
      this.repairLocation,
      this.assignedEmployee,
      this.activityMaintenanceTimers,
      this.technicalComment,
      this.supplier,
      this.supplierEngineer,
      this.supplierStartTime,
      this.supplierEndTime,
        this.activityType,
      this.supplierWorkingHours,
      this.assistantEmployees});

  ActivityMaintenance.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    activityStatus = json['activityStatus'] != null ? ActivityStatus.fromJson(json['activityStatus']) : null;
    startTime = json['startTime'];
    endTime = json['endTime'];
    workingHours = json['workingHours'];
    activityType = json['activityType'];
    travelHours = json['travelHours'];
    lastSituation = json['lastSituation'] != null ? Lookup.fromJson(json['lastSituation']) : null;
    repairLocation = json['repairLocation'] != null ? Lookup.fromJson(json['repairLocation']) : null;
    assignedEmployee = json['assignedEmployee'] != null ? AssignedEmployee.fromJson(json['assignedEmployee']) : null;
    technicalComment = json['technicalComment'];
    //json["supplier"] == null ? null : Lookup.fromJson(json["supplier"]),
    supplier = json["supplier"] == null ? null : Lookup.fromJson(json["supplier"]);
    supplierEngineer = json["supplierEngineer"] == null ? null : Lookup.fromJson(json["supplierEngineer"]);
    // supplierEngineer = json['supplierEngineer'];
    supplierStartTime = json['supplierStartTime'];
    supplierEndTime = json['supplierEndTime'];
    supplierWorkingHours = json['supplierWorkingHours'];
    if (json['assistantEmployees'] != null) {
      assistantEmployees = <ActivityMaintenanceAssistantEmployees>[];
      json['assistantEmployees'].forEach((v) {
        assistantEmployees!.add(ActivityMaintenanceAssistantEmployees.fromJson(v));
      });
    }
    if (json['activityMaintenanceTimers'] != null) {
      activityMaintenanceTimers = <ActivityMaintenanceTimers>[];
      json['activityMaintenanceTimers'].forEach((v) {
        activityMaintenanceTimers!.add(ActivityMaintenanceTimers.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['activityStatus'] = activityStatus;
    data['startTime'] = startTime;
    data['endTime'] = endTime;
    data['workingHours'] = workingHours;
    data['travelHours'] = travelHours;
    if (repairLocation != null) {
      data['repairLocation'] = repairLocation!.toJson();
    }
    if (assignedEmployee != null) {
      data['assignedEmployee'] = assignedEmployee!.toJson();
    }
    data['technicalComment'] = technicalComment;
    data['supplier'] = supplier;
    data['supplierEngineer'] = supplierEngineer;
    data['supplierStartTime'] = supplierStartTime;
    data['supplierEndTime'] = supplierEndTime;
    data['supplierWorkingHours'] = supplierWorkingHours;
    if (assistantEmployees != null) {
      data['assistantEmployees'] = assistantEmployees!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

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

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

  RepairLocation.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 AssignedEmployee {
  String? userId;
  String? userName;
  String? email;
  int? languageId;

  AssignedEmployee({this.userId, this.userName, this.email, this.languageId});

  AssignedEmployee.fromJson(Map<String, dynamic> json) {
    userId = json['userId'];
    userName = json['userName'];
    email = json['email'];
    languageId = json['languageId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['userId'] = userId;
    data['userName'] = userName;
    data['email'] = email;
    data['languageId'] = languageId;
    return data;
  }
}

class ActivityMaintenanceAssistantEmployees {
  DateTime? startDate;
  DateTime? endDate;
  double? workingHours;
  String? technicalComment;
  AssignedEmployee? user;

  ActivityMaintenanceAssistantEmployees({this.startDate, this.endDate, this.workingHours, this.technicalComment, this.user});

  ActivityMaintenanceAssistantEmployees.fromJson(Map<String, dynamic> json) {
    startDate = json['startDate'] != null ? DateTime.parse(json['startDate']) : null;
    endDate = json['endDate'] != null ? DateTime.parse(json['endDate']) : null;
    workingHours = json['workingHours'];
    technicalComment = json['technicalComment'];
    user = json['user'] != null ? AssignedEmployee.fromJson(json['user']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['startDate'] = startDate?.toIso8601String();
    data['endDate'] = endDate?.toIso8601String();
    data['workingHours'] = workingHours;
    data['technicalComment'] = technicalComment;
    if (user != null) {
      data['userId'] = user?.userId;
    }
    return data;
  }
}

class ActivityMaintenanceTimers {
  int? id;
  String? startTime;
  String? endTime;
  dynamic workingHours;

  ActivityMaintenanceTimers({this.id, this.startTime, this.endTime, this.workingHours});

  ActivityMaintenanceTimers.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    startTime = json['startTime'];
    endTime = json['endTime'];
    workingHours = json['workingHours'];
  }

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