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

class TrafRequestModel {
  List<TrafRequestDataModel>? trafRequestDataModel;
  int? totalRows;
  int? count;
  String? message;
  String? title;
  String? innerMessage;
  int? responseCode;
  bool? isSuccess;

  TrafRequestModel({this.trafRequestDataModel, this.totalRows, this.count, this.message, this.title, this.innerMessage, this.responseCode, this.isSuccess});

  TrafRequestModel.fromJson(Map<String, dynamic> json) {
    if (json['TrafRequestDataModel'] != null) {
      trafRequestDataModel = <TrafRequestDataModel>[];
      json['TrafRequestDataModel'].forEach((v) {
        trafRequestDataModel!.add(new TrafRequestDataModel.fromJson(v));
      });
    }
    totalRows = json['totalRows'];
    count = json['count'];
    message = json['message'];
    title = json['title'];
    innerMessage = json['innerMessage'];
    responseCode = json['responseCode'];
    isSuccess = json['isSuccess'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.trafRequestDataModel != null) {
      data['TrafRequestDataModel'] = this.trafRequestDataModel!.map((v) => v.toJson()).toList();
    }
    data['totalRows'] = this.totalRows;
    data['count'] = this.count;
    data['message'] = this.message;
    data['title'] = this.title;
    data['innerMessage'] = this.innerMessage;
    data['responseCode'] = this.responseCode;
    data['isSuccess'] = this.isSuccess;
    return data;
  }
}

class TrafRequestDataModel {
  int? reqNo;
  String? reqCode;
  String? employeeId;
  String? employeeIdForDisplay;
  String? employeeName;
  String? employeeEmail;
  int? positionId;
  String? positionName;
  dynamic departmentId;
  String? departmentName;
  List<Departments>? departments;
  List<Departments>? trafDepartments;
  int? siteId;
  String? siteName;
  String? requesterExtensionNumber;
  String? requesterExtensionName;
  String? requesterContactNumber;
  int? requesterExtensionPositionId;
  String? requesterExtensionPositionName;
  int? requestTypeId;
  String? requestTypeName;
  int? assetNDId;
  int? modelId;
  String? modelName;
  int? manufacturerId;
  String? manufacturerName;
  int? assetId;
  String? assetSerialNo;
  String? assetNumber;
  String? assetName;
  int? assetAssetNDId;
  int? qty;
  String? purposeAnswer;
  String? currentPractise;
  String? censusQ1;
  String? censusQ2;
  String? censusQ3;
  String? censusQ4;
  List<TrafContacts>? trafContacts;
  int? usingSolelyOrSharedId;
  String? usingSolelyOrSharedName;
  int? isEffectedId;
  String? isEffectedName;
  String? effectedServices;
  int? isCombinationId;
  int?requestTypeValue;
  String? isCombinationName;
  String? usedWithCombination;
  String? comment;
  List<GenericAttachmentModel>? attachments;
  bool? isFromMobile;
  int? isBudgetId;
  String? isBudgetName;
  String? firstLineManagerId;
  String? firstLineManagerName;
  int? firstLineManagerApprovalId;
  String? firstLineManagerApprovalName;
  int? tlapiId;
  String? tlapiName;
  String? assessorEmployeeId;
  String? assessorEmployeeName;
  String? secondLineManagerId;
  String? secondLineManagerName;
  int? secondLineManagerApprovalId;
  String? secondLineManagerApprovalName;
  String? hospitalManagementId;
  String? hospitalManagementName;
  int? hospitalManagementApprovalId;
  String? hospitalManagementApprovalName;
  List<OracleCodes>? oracleCodes;
  String? assessorTeamLeaderId;
  String? assessorTeamLeaderName;
  int? assessorTeamLeaderApprovalId;
  String? assessorTeamLeaderApprovalName;
  int? statusOfDRId;
  String? statusOfDRName;
  int? statusOfRequesterId;
  String? statusOfRequesterName;
  bool? approved;
  String? approvalUserId;
  String? approvalUserName;
  String? approvalDate;
  String? docDate;
  String? approvalDocDate;
  String? isAssigned;
  String? poNumber;
  String? apiDirectorId;
  String? apiDirectorName;
  int? apiDirectorApprovalId;
  String? apiDirectorApprovalName;
  List<int>? trafAssessIds;
  List<int>? trafPRIds;
  List<int>? trafOfferIds;
  int? id;
  String? createdBy;
  String? createdDate;
  String? modifiedBy;
  String? modifiedDate;

  TrafRequestDataModel(
      {this.reqNo,
      this.reqCode,
      this.employeeId,
      this.employeeIdForDisplay,
      this.employeeName,
      this.employeeEmail,
      this.positionId,
      this.positionName,
      this.departmentId,
      this.departmentName,
      this.departments,
      this.trafDepartments,
      this.siteId,
      this.siteName,
      this.requesterExtensionNumber,
      this.requesterExtensionName,
      this.requesterContactNumber,
      this.requesterExtensionPositionId,
      this.requesterExtensionPositionName,
      this.requestTypeId,
      this.requestTypeName,
      this.assetNDId,
      this.modelId,
      this.modelName,
      this.manufacturerId,
      this.manufacturerName,
      this.assetId,
      this.assetSerialNo,
      this.assetNumber,
      this.assetName,
      this.assetAssetNDId,
      this.qty,
      this.purposeAnswer,
      this.currentPractise,
      this.censusQ1,
      this.censusQ2,
      this.censusQ3,
      this.censusQ4,
      this.trafContacts,
      this.usingSolelyOrSharedId,
      this.usingSolelyOrSharedName,
      this.isEffectedId,
      this.isEffectedName,
      this.effectedServices,
      this.isCombinationId,
        this.requestTypeValue,
      this.isCombinationName,
      this.usedWithCombination,
      this.comment,
      this.isFromMobile = true,
      this.attachments,
      this.isBudgetId,
      this.isBudgetName,
      this.firstLineManagerId,
      this.firstLineManagerName,
      this.firstLineManagerApprovalId,
      this.firstLineManagerApprovalName,
      this.tlapiId,
      this.tlapiName,
      this.assessorEmployeeId,
      this.assessorEmployeeName,
      this.secondLineManagerId,
      this.secondLineManagerName,
      this.secondLineManagerApprovalId,
      this.secondLineManagerApprovalName,
      this.hospitalManagementId,
      this.hospitalManagementName,
      this.hospitalManagementApprovalId,
      this.hospitalManagementApprovalName,
      this.oracleCodes,
      this.assessorTeamLeaderId,
      this.assessorTeamLeaderName,
      this.assessorTeamLeaderApprovalId,
      this.assessorTeamLeaderApprovalName,
      this.statusOfDRId,
      this.statusOfDRName,
      this.statusOfRequesterId,
      this.statusOfRequesterName,
      this.approved,
      this.approvalUserId,
      this.approvalUserName,
      this.approvalDate,
      this.docDate,
      this.approvalDocDate,
      this.isAssigned,
      this.poNumber,
      this.apiDirectorId,
      this.apiDirectorName,
      this.apiDirectorApprovalId,
      this.apiDirectorApprovalName,
      this.trafAssessIds,
      this.trafPRIds,
      this.trafOfferIds,
      this.id,
      this.createdBy,
      this.createdDate,
      this.modifiedBy,
      this.modifiedDate});

  TrafRequestDataModel.fromJson(Map<String, dynamic> json) {
    reqNo = json['reqNo'];
    reqCode = json['reqCode'];
    employeeId = json['employeeId'];
    employeeIdForDisplay = json['employeeIdForDisplay'];
    employeeName = json['employeeName'];
    employeeEmail = json['employeeEmail'];
    positionId = json['positionId'];
    positionName = json['positionName'];
    departmentId = json['departmentId'];
    departmentName = json['departmentName'];
    if (json['departments'] != null) {
      departments = <Departments>[];
      json['departments'].forEach((v) {
        departments!.add(new Departments.fromJson(v));
      });
    }
    if (json['trafDepartments'] != null) {
      trafDepartments = <Departments>[];
      json['trafDepartments'].forEach((v) {
        trafDepartments!.add(new Departments.fromJson(v));
      });
    }
    siteId = json['siteId'];
    siteName = json['siteName'];
    requesterExtensionNumber = json['requesterExtensionNumber'];
    requesterExtensionName = json['requesterExtensionName'];
    requesterContactNumber = json['requesterContactNumber'];
    requesterExtensionPositionId = json['requesterExtensionPositionId'];
    requesterExtensionPositionName = json['requesterExtensionPositionName'];
    requestTypeId = json['requestTypeId'];
    requestTypeName = json['requestTypeName'];
    assetNDId = json['assetNDId'];
    modelId = json['modelId'];
    modelName = json['modelName'];
    manufacturerId = json['manufacturerId'];
    manufacturerName = json['manufacturerName'];
    assetId = json['assetId'];
    assetSerialNo = json['assetSerialNo'];
    assetNumber = json['assetNumber'];
    assetName = json['assetName'];
    assetAssetNDId = json['assetAssetNDId'];
    qty = json['qty'];
    purposeAnswer = json['purposeAnswer'];
    currentPractise = json['currentPractise'];
    censusQ1 = json['censusQ1'];
    censusQ2 = json['censusQ2'];
    censusQ3 = json['censusQ3'];
    censusQ4 = json['censusQ4'];
    if (json['trafContacts'] != null) {
      trafContacts = <TrafContacts>[];
      json['trafContacts'].forEach((v) {
        trafContacts!.add(new TrafContacts.fromJson(v));
      });
    }
    usingSolelyOrSharedId = json['usingSolelyOrSharedId'];
    usingSolelyOrSharedName = json['usingSolelyOrSharedName'];
    isEffectedId = json['isEffectedId'];
    isEffectedName = json['isEffectedName'];
    effectedServices = json['effectedServices'];
    isCombinationId = json['isCombinationId'];
    requestTypeValue = json['requestTypeValue'];
    isCombinationName = json['isCombinationName'];
    usedWithCombination = json['usedWithCombination'];
    comment = json['comment'];
    isFromMobile = json['isFromMobile'];
    if (json['attachments'] != null) {
      attachments = <GenericAttachmentModel>[];
      json['attachments'].forEach((v) {
        attachments!.add(GenericAttachmentModel.fromTrafJson(v));
      });
    }
    isBudgetId = json['isBudgetId'];
    isBudgetName = json['isBudgetName'];
    firstLineManagerId = json['firstLineManagerId'];
    firstLineManagerName = json['firstLineManagerName'];
    firstLineManagerApprovalId = json['firstLineManagerApprovalId'];
    firstLineManagerApprovalName = json['firstLineManagerApprovalName'];
    tlapiId = json['tlapiId'];
    tlapiName = json['tlapiName'];
    assessorEmployeeId = json['assessorEmployeeId'];
    assessorEmployeeName = json['assessorEmployeeName'];
    secondLineManagerId = json['secondLineManagerId'];
    secondLineManagerName = json['secondLineManagerName'];
    secondLineManagerApprovalId = json['secondLineManagerApprovalId'];
    secondLineManagerApprovalName = json['secondLineManagerApprovalName'];
    hospitalManagementId = json['hospitalManagementId'];
    hospitalManagementName = json['hospitalManagementName'];
    hospitalManagementApprovalId = json['hospitalManagementApprovalId'];
    hospitalManagementApprovalName = json['hospitalManagementApprovalName'];
    if (json['oracleCodes'] != null) {
      oracleCodes = <OracleCodes>[];
      json['oracleCodes'].forEach((v) {
        oracleCodes!.add(new OracleCodes.fromJson(v));
      });
    }
    assessorTeamLeaderId = json['assessorTeamLeaderId'];
    assessorTeamLeaderName = json['assessorTeamLeaderName'];
    assessorTeamLeaderApprovalId = json['assessorTeamLeaderApprovalId'];
    assessorTeamLeaderApprovalName = json['assessorTeamLeaderApprovalName'];
    statusOfDRId = json['statusOfDRId'];
    statusOfDRName = json['statusOfDRName'];
    statusOfRequesterId = json['statusOfRequesterId'];
    statusOfRequesterName = json['statusOfRequesterName'];
    approved = json['approved'];
    approvalUserId = json['approvalUserId'];
    approvalUserName = json['approvalUserName'];
    approvalDate = json['approvalDate'];
    docDate = json['docDate'];
    approvalDocDate = json['approvalDocDate'];
    isAssigned = json['isAssigned'];
    poNumber = json['poNumber'];
    apiDirectorId = json['apiDirectorId'];
    apiDirectorName = json['apiDirectorName'];
    apiDirectorApprovalId = json['apiDirectorApprovalId'];
    apiDirectorApprovalName = json['apiDirectorApprovalName'];
    trafAssessIds = json['trafAssessIds'].cast<int>();
    trafPRIds = json['trafPRIds'].cast<int>();
    trafOfferIds = json['trafOfferIds'].cast<int>();
    id = json['id'];
    createdBy = json['createdBy'];
    createdDate = json['createdDate'];
    modifiedBy = json['modifiedBy'];
    modifiedDate = json['modifiedDate'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['reqNo'] = this.reqNo;
    data['reqCode'] = this.reqCode;
    data['employeeId'] = this.employeeId;
    data['employeeIdForDisplay'] = this.employeeIdForDisplay;
    data['employeeName'] = this.employeeName;
    data['employeeEmail'] = this.employeeEmail;
    data['positionId'] = this.positionId;
    data['positionName'] = this.positionName;
    data['departmentId'] = this.departmentId;
    data['departmentName'] = this.departmentName;
    if (this.departments != null) {
      data['departments'] = this.departments!.map((v) => v.toJson()).toList();
    }
    if (this.trafDepartments != null) {
      data['trafDepartments'] = this.trafDepartments!.map((v) => v.toJson()).toList();
    }
    data['siteId'] = this.siteId;
    data['siteName'] = this.siteName;
    data['requesterExtensionNumber'] = this.requesterExtensionNumber;
    data['requesterExtensionName'] = this.requesterExtensionName;
    data['requesterContactNumber'] = this.requesterContactNumber;
    data['requesterExtensionPositionId'] = this.requesterExtensionPositionId;
    data['requesterExtensionPositionName'] = this.requesterExtensionPositionName;
    data['requestTypeId'] = this.requestTypeId;
    data['requestTypeName'] = this.requestTypeName;
    data['assetNDId'] = this.assetNDId;
    data['modelId'] = this.modelId;
    data['modelName'] = this.modelName;
    data['manufacturerId'] = this.manufacturerId;
    data['manufacturerName'] = this.manufacturerName;
    data['assetId'] = this.assetId;
    data['assetSerialNo'] = this.assetSerialNo;
    data['assetNumber'] = this.assetNumber;
    data['assetName'] = this.assetName;
    data['assetAssetNDId'] = this.assetAssetNDId;
    data['qty'] = this.qty;
    data['purposeAnswer'] = this.purposeAnswer;
    data['currentPractise'] = this.currentPractise;
    data['censusQ1'] = this.censusQ1;
    data['censusQ2'] = this.censusQ2;
    data['censusQ3'] = this.censusQ3;
    data['censusQ4'] = this.censusQ4;
    if (this.trafContacts != null) {
      data['trafContacts'] = this.trafContacts!.map((v) => v.toJson()).toList();
    }
    data['usingSolelyOrSharedId'] = this.usingSolelyOrSharedId;
    data['usingSolelyOrSharedName'] = this.usingSolelyOrSharedName;
    data['isEffectedId'] = this.isEffectedId;
    data['isEffectedName'] = this.isEffectedName;
    data['effectedServices'] = this.effectedServices;
    data['isCombinationId'] = this.isCombinationId;
    data['requestTypeValue'] = this.requestTypeValue;
    data['isCombinationName'] = this.isCombinationName;
    data['usedWithCombination'] = this.usedWithCombination;
    data['comment'] = this.comment;
    data['isFromMobile'] = this.isFromMobile;
    if (attachments != null) {
      data['attachments'] = attachments!.map((v) => v.toTrafJson()).toList();
    } else {
      data['attachments'] = [];
    }
    data['isBudgetId'] = this.isBudgetId;
    data['isBudgetName'] = this.isBudgetName;
    data['firstLineManagerId'] = this.firstLineManagerId;
    data['firstLineManagerName'] = this.firstLineManagerName;
    data['firstLineManagerApprovalId'] = this.firstLineManagerApprovalId;
    data['firstLineManagerApprovalName'] = this.firstLineManagerApprovalName;
    data['tlapiId'] = this.tlapiId;
    data['tlapiName'] = this.tlapiName;
    data['assessorEmployeeId'] = this.assessorEmployeeId;
    data['assessorEmployeeName'] = this.assessorEmployeeName;
    data['secondLineManagerId'] = this.secondLineManagerId;
    data['secondLineManagerName'] = this.secondLineManagerName;
    data['secondLineManagerApprovalId'] = this.secondLineManagerApprovalId;
    data['secondLineManagerApprovalName'] = this.secondLineManagerApprovalName;
    data['hospitalManagementId'] = this.hospitalManagementId;
    data['hospitalManagementName'] = this.hospitalManagementName;
    data['hospitalManagementApprovalId'] = this.hospitalManagementApprovalId;
    data['hospitalManagementApprovalName'] = this.hospitalManagementApprovalName;
    if (this.oracleCodes != null) {
      data['oracleCodes'] = this.oracleCodes!.map((v) => v.toJson()).toList();
    }
    data['assessorTeamLeaderId'] = this.assessorTeamLeaderId;
    data['assessorTeamLeaderName'] = this.assessorTeamLeaderName;
    data['assessorTeamLeaderApprovalId'] = this.assessorTeamLeaderApprovalId;
    data['assessorTeamLeaderApprovalName'] = this.assessorTeamLeaderApprovalName;
    data['statusOfDRId'] = this.statusOfDRId;
    data['statusOfDRName'] = this.statusOfDRName;
    data['statusOfRequesterId'] = this.statusOfRequesterId;
    data['statusOfRequesterName'] = this.statusOfRequesterName;
    data['approved'] = this.approved;
    data['approvalUserId'] = this.approvalUserId;
    data['approvalUserName'] = this.approvalUserName;
    data['approvalDate'] = this.approvalDate;
    data['docDate'] = this.docDate;
    data['approvalDocDate'] = this.approvalDocDate;
    data['isAssigned'] = this.isAssigned;
    data['poNumber'] = this.poNumber;
    data['apiDirectorId'] = this.apiDirectorId;
    data['apiDirectorName'] = this.apiDirectorName;
    data['apiDirectorApprovalId'] = this.apiDirectorApprovalId;
    data['apiDirectorApprovalName'] = this.apiDirectorApprovalName;
    data['trafAssessIds'] = this.trafAssessIds;
    data['trafPRIds'] = this.trafPRIds;
    data['trafOfferIds'] = this.trafOfferIds;
    data['id'] = this.id;
    data['createdBy'] = this.createdBy;
    data['createdDate'] = this.createdDate;
    data['modifiedBy'] = this.modifiedBy;
    data['modifiedDate'] = this.modifiedDate;
    return data;
  }
  Map<String, dynamic> toJsonNew() {
    final Map<String, dynamic> data = <String, dynamic>{};

    data['id'] = id;
    data['reqNo'] = reqNo;
    data['reqCode'] = reqCode;
    data['employeeId'] = employeeId;
    data['positionId'] = positionId;

    data['departments'] =
        departments?.map((v) => v.toJson()).toList() ?? [];
    if (this.trafDepartments != null) {
      data['trafDepartments'] = this.trafDepartments!.map((v) => v.toJson()).toList();
    }

    data['siteId'] = siteId;
    data['departmentId'] = departmentId;
    data['siteName'] = siteName;
    data['requesterExtensionNumber'] = requesterExtensionNumber;
    data['requesterExtensionName'] = requesterExtensionName;
    data['requesterExtensionPositionId'] = requesterExtensionPositionId;

    data['requestTypeId'] = requestTypeId;

    data['assetNDId'] = assetNDId;
    data['assetId'] = assetId;
    data['qty'] = qty;

    data['purposeAnswer'] = purposeAnswer;
    data['currentPractise'] = currentPractise;

    data['censusQ1'] = censusQ1;
    data['censusQ2'] = censusQ2;
    data['censusQ3'] = censusQ3;
    data['censusQ4'] = censusQ4;

    data['isFromMobile'] = isFromMobile;

    data['trafContacts'] =
        trafContacts?.map((v) => v.toJson()).toList() ?? [];

    data['usingSolelyOrSharedId'] = usingSolelyOrSharedId;

    data['isEffectedId'] = isEffectedId;
    data['effectedServices'] = effectedServices;

    data['isCombinationId'] = isCombinationId;
    data['usedWithCombination'] = usedWithCombination;

    data['comment'] = comment;

    data['isBudgetId'] = isBudgetId;

    data['attachments'] =
        attachments?.map((v) => v.toTrafJson() ?? {}).toList() ?? [];

    return data;
  }




}

class TrafContacts {
  int? id;
  int? trafId;
  String? userId;
  String? name;
  String? telephone;
  String? notes;

  TrafContacts({this.id, this.trafId, this.userId, this.name, this.telephone, this.notes});

  TrafContacts.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    trafId = json['trafId'];
    userId = json['userId'];
    name = json['name'];
    telephone = json['telephone'];
    notes = json['notes'];
  }

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

class OracleCodes {
  int? id;
  int? assetNDId;
  int? codeTypeId;
  String? codeTypeName;
  int? codeTypeValue;
  String? codeValue;

  OracleCodes({this.id, this.assetNDId, this.codeTypeId, this.codeTypeName, this.codeTypeValue, this.codeValue});

  OracleCodes.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    assetNDId = json['assetNDId'];
    codeTypeId = json['codeTypeId'];
    codeTypeName = json['codeTypeName'];
    codeTypeValue = json['codeTypeValue'];
    codeValue = json['codeValue'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['assetNDId'] = this.assetNDId;
    data['codeTypeId'] = this.codeTypeId;
    data['codeTypeName'] = this.codeTypeName;
    data['codeTypeValue'] = this.codeTypeValue;
    data['codeValue'] = this.codeValue;
    return data;
  }
}

class Departments {
  int? id;
  int? trafId;
  int? departmentId;
  String? departmentName;

  Departments({this.id, this.trafId, this.departmentId, this.departmentName});

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

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['trafId'] = this.trafId;
    data['departmentId'] = this.departmentId;
    data['departmentName'] = this.departmentName;
    return data;
  }
}
//TODO need to remove this
// class Attachments {
//   int? id;
//   int? trafId;
//   String? attachmentName;
//   Lookup ? documentType;
//
//   Attachments({this.id, this.trafId, this.attachmentName,this.documentType});
//
//   Attachments.fromJson(Map<String, dynamic> json) {
//     id = json['id'];
//     trafId = json['trafId'];
//     attachmentName = json['attachmentName'];
//     documentType = json['documentType'];
//   }
//
//   Map<String, dynamic> toJson() {
//     final Map<String, dynamic> data = new Map<String, dynamic>();
//     data['id'] = this.id;
//     data['trafId'] = this.trafId;
//     data['attachmentName'] = this.attachmentName;
//     data['documentTypeId'] = this.documentType?.id;
//     return data;
//   }
// }
