import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:generp/Models/ViewVisitDetailsResponseNew.dart';
import 'package:generp/Models/commonModels/DistrictsResponse.dart';
import 'package:generp/Models/commonModels/SubLocationsResponse.dart';
import 'package:generp/Models/commonModels/commonAccessiblePagesResponse.dart';
import 'package:generp/Models/commonModels/commonAddAccountsViewResponse.dart';
import 'package:generp/Models/crmModels/AccessiblePagesResponse.dart';
import 'package:generp/Models/crmModels/GetDistrictOnStateResponse.dart';
import 'package:generp/Models/crmModels/GetSegmentOnTeamResponse.dart';
import 'package:generp/Models/crmModels/GetSourceOnReferenceResponse.dart';
import 'package:generp/Models/crmModels/GetSubLocOnDistrictResponse.dart';
import 'package:generp/Models/crmModels/LeadListContactPopUpResponse.dart';
import 'package:generp/Models/crmModels/LeadListViewResponse.dart';
import 'package:generp/Models/crmModels/ProspectListViewResponse.dart';
import 'package:generp/Models/crmModels/SubmitLeadListFilterResponse.dart';
import 'package:generp/Models/crmModels/crmDashboardQuotationResponse.dart';
import 'package:generp/Models/crmModels/crmDownloadGenQuoteResponse.dart';
import 'package:generp/Models/crmModels/crmLeadDetailsGenerateQuotationSubmitResponse.dart';
import 'package:generp/Models/crmModels/crmNewLeadsProspectsSubmitResponse.dart';
import 'package:generp/Models/crmModels/crmNewLeadsProspectsViewResponse.dart';
import 'package:generp/Models/crmModels/crmProspectDetailsAddFollowUpAppointmentResponse.dart';
import 'package:generp/Models/crmModels/crmProspectDetailsAddLeadsResponse.dart';
import 'package:generp/Models/crmModels/crmProspectDetailsResponse.dart';
import 'package:generp/Models/financeModels/addDirectPaymentResponse.dart';
import 'package:generp/Models/financeModels/paymentRequisitionPaymentsListResponse.dart';
import 'package:generp/Models/hrmModels/attendanceRequestListResponse.dart';
import 'package:generp/Models/hrmModels/leaveApplicationDetailsResponse.dart';
import 'package:generp/Models/hrmModels/leaveApplicationLIstResponse.dart';
import 'package:generp/Models/hrmModels/rewardListResponse.dart';
import 'package:generp/Models/hrmModels/tourExpensesAddViewResponse.dart';
import 'package:generp/Models/hrmModels/tourExpensesDetailsResponse.dart';
import 'package:generp/Models/hrmModels/tourExpensesListResponse.dart';
import 'package:generp/Models/ordersModels/PendingTPCAgentListResponse.dart';
import 'package:generp/Models/ordersModels/TPCAgentDetailsResponse.dart';
import 'package:generp/Models/ordersModels/TPCListResponse.dart';
import 'package:generp/Models/ordersModels/orderDashboardResponse.dart';
import 'package:generp/services/api_names.dart';
import 'package:generp/services/api_post_request.dart';
import 'package:http/http.dart' as http;
import 'package:path_provider/path_provider.dart';

import '../Models/AccountSuggestionResponse.dart';
import '../Models/AddContactResponse.dart';
import '../Models/AttendanceListResponse.dart';
import '../Models/CheckInResponse.dart';
import '../Models/CheckOutResponse.dart';
import '../Models/ComplaintsSelectionResponse.dart';
import '../Models/DashboardResponse.dart';
import '../Models/DayWiseAttendance.dart';
import '../Models/FollowUpResponse.dart';
import '../Models/Inventory_Part_details_response.dart';
import '../Models/LoginQRResponse.dart';
import '../Models/LogoutResponse.dart';
import '../Models/NearbyGeneratorsResponse.dart';
import '../Models/PaymentCollectionResponse.dart';
import '../Models/PaymentCollectionValidateOTPResponse.dart';
import '../Models/PaymentCollectionWalletResponse.dart';
import '../Models/ProfileResponse.dart';
import '../Models/SessionResponse.dart';
import '../Models/StatusResponse.dart';
import '../Models/SubmitComplaintResponse.dart';
import '../Models/TagGeneratorResponse.dart';
import '../Models/TagLocationResponse.dart';
import '../Models/TechnicianAddPaymentCollectionResponse.dart';
import '../Models/TechnicianDashboardResponse.dart';
import '../Models/TechnicianLoadNumbersResponse.dart';
import '../Models/TechniciansPendingComplaintsResponse.dart';
import '../Models/TodayVisitResponse.dart';
import '../Models/UpdateComplaintResponse.dart';
import '../Models/UpdatePasswordResponse.dart';
import '../Models/VersionsResponse.dart';
import '../Models/ViewVisitDetailsResponse.dart';
import '../Models/commonModels/commonAddAccountsSubmitResponse.dart';
import '../Models/crmModels/appointmentCalendarResponse.dart';
import '../Models/crmModels/crmAddFollowUpResponse.dart';
import '../Models/crmModels/crmDashboardFollowUpResponse.dart';
import '../Models/crmModels/crmDashboardResponse.dart';
import '../Models/crmModels/crmPendingTasksResponse.dart';
import '../Models/crmModels/crmSelectedProductDetailsResponse.dart';
import '../Models/crmModels/crmUniversalSearchResponse.dart';
import '../Models/financeModels/paymentRequestionBankDetailsResponse.dart';
import '../Models/commonModels/commonAccountLedgerFilterResponse.dart';
import '../Models/commonModels/commonAccountLedgerResponse.dart';
import '../Models/commonModels/commonAccountdetailsResponse.dart';
import '../Models/commonModels/commonAccountlistResponse.dart';
import '../Models/crmModels/LeadDetailsResponse.dart';
import '../Models/crmModels/NearbyOpenLeadsResponse.dart';
import '../Models/crmModels/SubmitProspectListFilterResponse.dart';
import '../Models/crmModels/crmLeadDetailsEditAccountViewResponse.dart';
import '../Models/crmModels/crmLeadDetailsEditProductsViewResponse.dart';
import '../Models/crmModels/crmLeadDetailsGenerateQuotationViewResponse.dart';
import '../Models/crmModels/crmProspectDetailsEditAccountViewResponse.dart';
import '../Models/financeModels/addPaymentRequestionResponse.dart';
import '../Models/financeModels/addReceiptPaymentResponse.dart';
import '../Models/financeModels/paymentRequesitionListsResponse.dart';
import '../Models/financeModels/paymentRequisitionDetailsResponse.dart';
import '../Models/financeModels/paymentRequisitionPaymentsDetailsResponse.dart';
import '../Models/financeModels/paymentRequisitionPaymentsReceiptsDetailsResponse.dart';
import '../Models/financeModels/paymentRequisitionPaymentsReceiptsListResponse.dart';
import '../Models/generatorComplaintResponse.dart';
import '../Models/hrmModels/attendanceRequestDetailsResponse.dart';
import '../Models/hrmModels/hrmAccessiblePagesResponse.dart';
import '../Models/hrmmodels/ogresponse.dart';
import '../Models/loadGeneratorDetailsResponse.dart';
import '../Models/financeModels/financeDashboardPagesResponse.dart';
import '../Models/ordersModels/AddOrderPaymentSelectAccountResponse.dart';
import '../Models/ordersModels/AddOrderPaymentSelectOrderResponse.dart';
import '../Models/ordersModels/AddOrderViewResponse.dart';
import '../Models/ordersModels/EditPaymentDetailsAdjustedOrdersViewResponse.dart';
import '../Models/ordersModels/addOrderAccontDetailsResponse.dart';
import '../Models/ordersModels/addOrderPaymentViewResponse.dart';
import '../Models/ordersModels/addOrderTpcAgentListResponse.dart';
import '../Models/ordersModels/commonResponse.dart';
import '../Models/ordersModels/orderPendingTasksListResponse.dart';
import '../Models/ordersModels/ordersAccessiblePagesResponse.dart';
import '../Models/ordersModels/ordersDetailsByModeResponse.dart';
import '../Models/ordersModels/ordersDetailsDispatchOrderViewResponse.dart';
import '../Models/ordersModels/ordersDetailsEditOrderViewResponse.dart';
import '../Models/ordersModels/ordersListByModeFilterResponse.dart';
import '../Models/ordersModels/ordersListByModeResponse.dart';
import '../Models/ordersModels/ordersPdiIdByEngNumberResponse.dart';
import '../Models/ordersModels/paymentDetailsByModeFilterResponse.dart';
import '../Models/ordersModels/paymentListByModeFilterResponse.dart';
import '../Models/ordersModels/paymentListByModeResponse.dart';
import '../Models/ordersModels/technicianAddPaymentResendOTPResponse.dart';
import '../Notifiers/financeProvider/approveRejectPaymentRequestResponse.dart';
import '../Utils/commonServices.dart';
import 'package:http_parser/http_parser.dart';

class ApiCalling {
  static Future download_files(empId, session, url, cntxt) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, url, {});
      if (res != null) {
        final bytes = res.bodyBytes;
        var directory = "";
        if (Platform.isAndroid) {
          directory = "/storage/emulated/0/Download";
          var _directory = Directory(directory);
          if (!_directory.existsSync()) {
            // If the directory does not exist, create it
            _directory.createSync(recursive: true);
            debugPrint('Directory created: $_directory');
          } else {
            debugPrint('Directory already exists: $_directory');
          }
          // final androiddirectory = await getDownloadsDirectory();
          // directory = androiddirectory!.path;
        } else if (Platform.isIOS) {
          final iosDirectory = await getApplicationSupportDirectory();
          directory = iosDirectory!.path;
        }

        final contentDisposition = res.headers['content-disposition'];
        debugPrint(
          "contentDisposition ${contentDisposition?.split('filename=')[1]}",
        );

        // final filename = contentDisposition != null
        //     ? contentDisposition.split('filename=')[1]
        //     : 'file';
        var filename = (contentDisposition?.split('filename=')[1])?.replaceAll(
          '"',
          "",
        );
        // ignore: unnecessary_brace_in_string_interps
        final file = File('${directory}/${filename}');
        await file.writeAsBytes(bytes);
        toast(
          cntxt,
          "File saved to your downloads as ${filename} to ${directory}, Successfully",
        );
        debugPrint('File saved successfully');
        return jsonDecode(res.body);
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<VersionsResponse?> checkAppVersionApi() async {
    try {
      final response = await post({}, getAppVersionUrl, {});
      if (response != null) {
        print("${response.body}");
        return VersionsResponse.fromJson(jsonDecode(response.body));
      } else {
        return null;
      }
    } catch (e, s) {
      return null;
    }
  }

  static Future<SessionResponse?> CheckSessionExistsApi(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      // print(data);
      final res = await post(data, getEmployeeSessionDetailsUrl, {});
      if (res != null) {
        // print("check_session: ${res.body}");
        return SessionResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<StatusResponse?> LoginFunctionApi(
    email,
    password,
    token,
    deviceID,
    deviceInfo,
  ) async {
    try {
      Map<String, String> data = {
        'email_id': (email).toString(),
        'password': (password).toString(),
        'token_id': (token).toString(),
        'device_id': (deviceID).toString(),
        'device_details': (deviceInfo).toString(),
      };
      final res = await post(data, loginUrl, {});
      if (res != null) {
        // debugPrint("Login: ${res.body}");
        // print(data);
        return StatusResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<UpdatePasswordResponse?> UpdatePasswordApi(
    empId,
    session,
    password,
    conf_password,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'password': (password).toString(),
        'confirm_password': (conf_password).toString(),
      };
      final res = await post(data, updatePasswordUrl, {});
      if (res != null) {
        debugPrint("update password ${res.body}");
        debugPrint("update password ${data}");
        return UpdatePasswordResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<DashboardResponse?> DashboardFunctionApi(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, employeeDashboardUrl, {});
      if (res != null) {
        // debugPrint("Dashboard: ${res.body}");
        return DashboardResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ProfileResponse?> ProfileFunctionApi(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, employeeProfileUrl, {});
      if (res != null) {
        // debugPrint("profile-details: ${res.body}");

        return ProfileResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<LoginQRResponse?> QRLoginRequestAPI(
    empId,
    session,
    type,
    token,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': (type).toString(),
        'token': (token).toString(),
      };
      final res = await post(data, qrCodeLoginUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return LoginQRResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<LogoutResponse?> LogoutFunctionApi(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, logoutAppUrl, {});
      if (res != null) {
        // debugPrint(res.body);

        return LogoutResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CheckInResponse?> CheckInApi(
    empId,
    sessioId,
    location,
    latlngs,
    check_in_pic,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (sessioId).toString(),
        'posit': (latlngs).toString(),
        'location': (location).toString(),
      };
      var res;
      // if (check_in_pic != null) {
      res = await postImage(data, employeeChekInUrl, {}, check_in_pic);
      res = jsonDecode(res);
      // } else {
      //   // res = await post(data, employeeChekInUrl, {});
      //   // res = jsonDecode(res.body);
      // }
      if (res != null) {
        return CheckInResponse.fromJson(res);
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CheckOutResponse?> CheckOutApi(
    empId,
    sessioId,
    location,
    latlngs,
    check_out_pic,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (sessioId).toString(),
        'location': (location).toString(),
        'posit': (latlngs).toString(),
      };
      var res;
      // if (image != null) {
      //   res = await postImage2(data, {}, employeeCheckOutUrl, image);
      //   res = jsonDecode(res);
      // } else {
      //   res = await post(data, employeeCheckOutUrl, {});
      //   res = jsonDecode(res);
      // }
      // if (res != null) {
      //   return CheckOutResponse.fromJson(res);
      // } else {
      //   debugPrint("Null Response");
      //   return null;
      // }
      // if (check_out_pic != null) {
      res = await postImageNew(
        data,
        {},
        employeeCheckOutUrl,
        check_out_pic,
        'check_out_pic',
      );
      if (res != null) {
        res = jsonDecode(res);
      }

      // } else {
      //   res = await post(data, employeeCheckOutUrl, {});
      //   res = jsonDecode(res.body);
      // }
      return CheckOutResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AttendanceDashboard?> AttendanceListApi(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, employeeAttendanceDashboardUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return AttendanceDashboard.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static LoadAttendanceDetails(empId, session, month, year) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'year': (year).toString(),
        'month': month.toString(),
      };
      final res = await post(data, employeeMonthwiseAttendanceUrl, {});
      if (res != null) {
        // debugPrint("montly attendance: ${res.body}");
        // return AttendanceHistory.fromJson(jsonDecode(res.body));
        return res.body;
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AttendanceDaywiseResponse?> DateWiseAttendanceApi(
    empId,
    session,
    date,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'date': (date).toString(),
      };
      final res = await post(data, employeeDayAttendanceDetailsUrl, {});
      if (res != null) {
        // debugPrint("Attendacnce API /; ${res.body}");
        return AttendanceDaywiseResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///gen tracker

  static Future<loadGeneratorDetailsResponse?> LoadGeneratorDetailsAPI(
    empId,
    session,
    gen_hash_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_hash_id': (gen_hash_id).toString(),
      };
      final res = await post(data, genTrackerGeneratorDetailsUrl, {});
      if (res != null) {
        debugPrint("gen details222: ${jsonDecode(res.body)['complaint_list']}");
        return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<generatorComplaintResponse?> LoadGeneratorComplaintListAPI(
    empId,
    session,
    gen_id,
    open_status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_id': (gen_id).toString(),
        'open_status': (open_status).toString(),
      };
      final res = await post(data, genTrackerGeneratorComplaintsUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return generatorComplaintResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TagLocationResponse?> TagLocationAPI(
    empId,
    session,
    gen_hash_id,
    location,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_hash_id': (gen_hash_id).toString(),
        'location': (location).toString(),
      };
      print("Tag Loation: ${data}");
      var res;
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          genTrackerTagLocationUrl,
          attachment,
          "attachment",
        );
        res = jsonDecode(res);
        return TagLocationResponse.fromJson(res);
      } else {
        res = await post(data, genTrackerTagLocationUrl, {});
        if (res != null) {
          // debugPrint(res.body);
          return TagLocationResponse.fromJson(jsonDecode(res.body));
        } else {
          debugPrint("Null Response");
          return null;
        }
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TagGeneratorResponse?> TagGeneratorAPI(
    empId,
    session,
    gen_hash_id,
    engine_no,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_hash_id': (gen_hash_id).toString(),
        'engine_no': (engine_no).toString(),
      };
      final res = await post(data, genTrackerTagGeneratorUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return TagGeneratorResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TagGeneratorResponse?> TagGeneratorCheckAPI(
    empId,
    session,
    gen_hash_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_hash_id': (gen_hash_id).toString(),
      };
      final res = await post(data, genTrackerCheckTagGeneratorUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return TagGeneratorResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<SubmitComplaintResponse?> SubmitGeneratorComplaintAPI(
    empId,
    session,
    complaint_type_id,
    complaint_category_id,
    complaint_desc_id,
    running_hrs,
    gen_id,
    complaint_note,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'complaint_type_id': (complaint_type_id).toString(),
        'complaint_category_id': (complaint_category_id).toString(),
        'complaint_desc_id': (complaint_desc_id).toString(),
        'running_hrs': (running_hrs).toString(),
        'gen_id': (gen_id).toString(),
        'complaint_note': (complaint_note).toString(),
      };
      final res = await post(data, genTrackerRegisterComplaint, {});
      if (res != null) {
        // debugPrint(res.body);
        return SubmitComplaintResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ComplaintsSelectionResponse?> ComplaintSelectionAPI(
    empId,
    session,
    gen_hash_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_hash_id': (gen_hash_id).toString(),
      };
      final res = await post(data, complaintsSelectionUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return ComplaintsSelectionResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///Inventory Module API's

  static Future<Inventory_Part_details_response?> LoadPartDetailsAPI(
    empId,
    session,
    part_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'part_id': (part_id).toString(),
      };
      final res = await post(data, inventoryPartDetailsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return Inventory_Part_details_response.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<loadGeneratorDetailsResponse?> InventoryUpdateStockAPI(
    empId,
    session,
    qty,
    descr,
    part_id,
    tran_type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'qty': (qty).toString(),
        'descr': (descr).toString(),
        'product_id': (part_id).toString(),
        'tran_type': (tran_type).toString(),
      };
      final res = await post(data, inventoryStockUpdateUrl, {});
      if (res != null) {
        print("Issue Receive $data");
        debugPrint(res.body);
        return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///technician
  static Future<loadGeneratorDetailsResponse?>
  LoadTechnicianGeneratorDetailsAPI(empId, session, gen_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_id': (gen_id).toString(),
      };
      final res = await post(data, technicianGeneratorDetailsUrl, {});

      if (res != null) {
        print("genderrails:${jsonDecode(res!.body)}");
        return loadGeneratorDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TechnicianResponse?> loadTechnicianDashboardApi(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianDashboardUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return TechnicianResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TodayVisitResponse?> getTodayVisitsListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianTodayVisitsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return TodayVisitResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TodayVisitResponse?> getMonthVisitsListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianMonthlyVisitsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return TodayVisitResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<NearbyGeneratorsResponse?> loadNearbyGeneratorsAPI(
    empId,
    session,
    tech_loc,
    radius,
    status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'tech_loc': (tech_loc).toString(),
        'radius': (radius).toString(),
        'status': (status).toString(),
      };
      final res = await post(data, technicianNearbyGeneratorsUrl, {});
      if (res != null) {
        // print(data);
        // debugPrint(res.body);
        return NearbyGeneratorsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AccountSuggestionResonse?> AccountSuggestionAPI(
    empId,
    session,
    search_string,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'search_string': (search_string).toString(),
      };
      final res = await post(data, technicianAccountSearchUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return AccountSuggestionResonse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TechnicianPendingComplaintsResponse?>
  LoadTechnicianComplaintsAPI(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianPendingComplaintUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return TechnicianPendingComplaintsResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TechnicianLoadNumbersResponse?> LoadContactsTechnicianAPI(
    empId,
    session,
    type,
    gen_id,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': (type).toString(),
        'gen_id': (gen_id).toString(),
        'account_id': (account_id).toString(),
      };
      print(data);
      final res = await post(data, technicianAddPaymentUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return TechnicianLoadNumbersResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TechnicianAddPaymentCollectionResponse?>
  TechnicianUpdatepaymentAPI(
    empId,
    session,
    ref_type,
    ref_id,
    payment_mode_id,
    payment_ref_no,
    amount,
    otp_validated_name,
    otp_validated_mobile_number,
    payment_proof,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'ref_type': (ref_type).toString(),
        'ref_id': (ref_id).toString(),
        'payment_mode_id': (payment_mode_id).toString(),
        'payment_ref_no': (payment_ref_no).toString(),
        'amount': (amount).toString(),
        'otp_validated_name': (otp_validated_name).toString(),
        'otp_validated_mobile_number': (otp_validated_mobile_number).toString(),
      };
      var res;
      // if (payment_proof != null) {
      //   res = await postImage3(
      //     data,
      //     {},
      //     technicianAddPaymentCollectionUrl,
      //     payment_proof,
      //   );
      //   res = jsonDecode(res);
      // } else {
      //   res = await post(data, technicianAddPaymentCollectionUrl, {});
      //   res = jsonDecode(res);
      // }
      // if (res != null) {
      //   return TechnicianAddPaymentCollectionResponse.fromJson(res);
      // } else {
      //   debugPrint("Null Response");
      //   return null;
      // }
      print("send otp:${data}");
      if (payment_proof != null) {
        res = await postImageNew(
          data,
          {},
          technicianAddPaymentCollectionUrl,
          payment_proof,
          'payment_proof',
        );

        print("Add Payment $res");
        res = jsonDecode(res);
      } else {
        print("Add Payment $res");
        res = await post(data, technicianAddPaymentCollectionUrl, {});
        res = jsonDecode(res.body);
        // return TechnicianAddPaymentCollectionResponse.fromJson(res);
      }
      return TechnicianAddPaymentCollectionResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<PaymentCollectionValidateOTPResponse?>
  TechnicianPaymentOTPValidateAPI(
    empId,
    session,
    payment_collection_id,
    otp,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_collection_id': (payment_collection_id).toString(),
        'otp': (otp).toString(),
      };
      final res = await post(data, technicianPaymentCollectionOtpUrl, {});
      if (res != null) {
        debugPrint("OTP${res.body}");
        return PaymentCollectionValidateOTPResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<Technicianaddpaymentresendotpresponse?>
  TechnicianPaymentOTPResendAPI(empId, session, payment_collection_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_collection_id': (payment_collection_id).toString(),
      };
      final res = await post(data, technicianAddPaymentResendOTPUrl, {});
      if (res != null) {
        debugPrint("OTP${res.body}");
        return Technicianaddpaymentresendotpresponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<PaymentCollectionResponse?> paymentCollectionListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianPaymentCollectionUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return PaymentCollectionResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<PaymentCollectionWalletResponse?> loadTransactionsListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, technicianWalletCollectionUrl, {});
      if (res != null) {
        // debugPrint(res.body);
        return PaymentCollectionWalletResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ViewVisitDetailsResponseNew?> loadVisitDetailsAPI(
    empId,
    session,
    comp_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'comp_id': (comp_id).toString(),
      };
      final res = await post(data, technicianComplaintDetailsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return ViewVisitDetailsResponseNew.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<FollowupListResponse?> loadFollowupListAPI(
    empId,
    session,
    comp_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'comp_id': (comp_id).toString(),
      };
      final res = await post(data, technicianComplaintFollowUpUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return FollowupListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AddContactResponse?> AddContactAPI(
    empId,
    session,
    gen_id,
    name,
    designation,
    mob1,
    mob2,
    tel,
    mail,
    type,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'gen_id': (gen_id).toString(),
        'name': (name).toString(),
        'designation': (designation).toString(),
        'mob1': (mob1).toString(),
        'mob2': (mob2).toString(),
        'tel': (tel).toString(),
        'mail': (mail).toString(),
        'type': (type).toString(),
        'account_id': (account_id).toString(),
      };
      print("add: $data");
      final res = await post(data, technicianAddContactUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return AddContactResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<UpdateComplaintResponse?> UpdateComplaintAPI(
    empId,
    session,
    complaint_id,
    in_time,
    feedback,
    fsr_no,
    running_hrs,
    complaint_status,
    fsr_file,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'complaint_id': (complaint_id).toString(),
        'in_time': (in_time).toString(),
        'feedback': (feedback).toString(),
        'fsr_no': (fsr_no).toString(),
        'running_hrs': (running_hrs).toString(),
        'complaint_status': (complaint_status).toString(),
      };
      // print(data);
      // print(fsr_file);
      var res;
      if (fsr_file != null) {
        res = await postImageNew(
          data,
          {},
          technicianUpdateVisitUrl,
          fsr_file,
          'fsr_file',
        );
        res = jsonDecode(res);
        return UpdateComplaintResponse.fromJson(res);
      } else {
        res = await post(data, technicianUpdateVisitUrl, {});
        res = jsonDecode(res.body);
        return UpdateComplaintResponse.fromJson(res);
      }

      // debugPrint(res);
      if (res != null) {
        // debugPrint(res);
        return UpdateComplaintResponse.fromJson(res);
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///finance Module
  static Future<financeDashboardPagesResponse?> financeDashboardPagesAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, financeDashboardPagesUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return financeDashboardPagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<financeDashboardPagesResponse?>
  addFormfinanceFormAccessPagesAPI(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, financeAddFormPagesAccessUrl, {});
      if (res != null) {
        debugPrint("adjf:${res.body}");
        return financeDashboardPagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addPaymentRequestionResponse?> addPaymentRequestionViewAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, addPaymentRequestionViewUrl, {});
      if (res != null) {
        // print("add view:${data}");
        // debugPrint(res.body);
        return addPaymentRequestionResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addDirectPaymentResponse?> addDirectPaymentRequestionViewAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, addDirectPaymentRequestionViewUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return addDirectPaymentResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addReceiptPaymentResponse?> addReceiptPaymentRequestionViewAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, addPaymentReceiptViewUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return addReceiptPaymentResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> addPaymentRequestionSubmitAPI(
    emp_id,
    session_id,
    type,
    account_id,
    requesting_purpose,
    description,
    amount,
    payment_mode_id,
    bank_name,
    bank_branch_name,
    bank_acc_number,
    bank_ifsc_code,
    acc_holder_name,
    bank_upi_id,
    approval_assignee_emp_id,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': emp_id.toString(),
        'session_id': session_id.toString(),
        'type': type.toString(),
        'account_id': account_id.toString(),
        'requesting_purpose': requesting_purpose.toString(),
        'description': description.toString(),
        'amount': amount.toString(),
        'payment_mode_id': payment_mode_id.toString(),
        'bank_name': bank_name.toString(),
        'bank_branch_name': bank_branch_name.toString(),
        'bank_acc_number': bank_acc_number.toString(),
        'bank_ifsc_code': bank_ifsc_code.toString(),
        'acc_holder_name': acc_holder_name.toString(),
        'bank_upi_id': bank_upi_id.toString(),
        'approval_assignee_emp_id': approval_assignee_emp_id.toString(),
      };

      var res;
      print(data);
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          addPaymentRequestionSubmitUrl,
          attachment,
          "attachment",
        );
        res = jsonDecode(res);
        return CommonResponse.fromJson(res);
      } else {
        res = await post(data, addPaymentRequestionSubmitUrl, {});
        res = jsonDecode(res.body);
        return CommonResponse.fromJson(res);
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addDirectPaymentResponse?> addDirectPaymentRequestionSubmitAPI(
    emp_id,
    session_id,
    from_account_id,
    to_account_id,
    description,
    payment_mode_id,
    amount,
    payment_date,
    payment_reference_number,
    bank_name,
    bank_branch_name,
    bank_acc_number,
    bank_ifsc_code,
    acc_holder_name,
    bank_upi_id,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': emp_id.toString(),
        'session_id': session_id.toString(),
        'from_account_id': from_account_id.toString(),
        'to_account_id': to_account_id.toString(),
        'description': description.toString(),
        'payment_mode_id': payment_mode_id.toString(),
        'amount': amount.toString(),
        'payment_date': payment_date.toString(),
        'payment_reference_number': payment_reference_number.toString(),
        'bank_name': bank_name.toString(),
        'bank_branch_name': bank_branch_name.toString(),
        'bank_acc_number': bank_acc_number.toString(),
        'bank_ifsc_code': bank_ifsc_code.toString(),
        'acc_holder_name': acc_holder_name.toString(),
        'bank_upi_id': bank_upi_id.toString(),
      };
      print(data);
      print(attachment);
      var res;
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          addDirectPaymentRequestionSubmitUrl,
          attachment,
          "attachment",
        );
        res = jsonDecode(res);
        return addDirectPaymentResponse.fromJson(res);
      } else {
        res = await post(data, addDirectPaymentRequestionSubmitUrl, {});
        res = jsonDecode(res.body);
        print(res);
        return addDirectPaymentResponse.fromJson(res);
      }
      if (res != null) {
        return res;
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addReceiptPaymentResponse?>
  addReceiptPaymentRequestionSubmitAPI(
    emp_id,
    session_id,
    from_account_id,
    to_account_id,
    description,
    payment_mode_id,
    amount,
    receipt_date,
    payment_reference_number,
    bank_name,
    bank_branch_name,
    bank_acc_number,
    bank_ifsc_code,
    acc_holder_name,
    bank_upi_id,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': emp_id.toString(),
        'session_id': session_id.toString(),
        'from_account_id': from_account_id.toString(),
        'to_account_id': to_account_id.toString(),
        'description': description.toString(),
        'payment_mode_id': payment_mode_id.toString(),
        'amount': amount.toString(),
        'receipt_date': receipt_date.toString(),
        'payment_reference_number': payment_reference_number.toString(),
        'bank_name': bank_name.toString(),
        'bank_branch_name': bank_branch_name.toString(),
        'bank_acc_number': bank_acc_number.toString(),
        'bank_ifsc_code': bank_ifsc_code.toString(),
        'acc_holder_name': acc_holder_name.toString(),
        'bank_upi_id': bank_upi_id.toString(),
      };

      var res;
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          addPaymentReceiptSubmitUrl,
          attachment,
          "attachment",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, addPaymentReceiptSubmitUrl, {});
        res = jsonDecode(res.body);
        // return addReceiptPaymentResponse.fromJson(res);
      }
      return addReceiptPaymentResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequesitionListsResponse?> paymentRequestionListsAPI(
    empId,
    session,
    mode,
    from_date,
    to_date,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'from': from_date.toString(),
        'to': to_date.toString(),
      };
      print(data);
      final res = await post(data, paymentRequestionListUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return paymentRequesitionListsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequisitionDetailsResponse?> paymentRequestionDetailsAPI(
    empId,
    session,
    payment_request_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_request_id': (payment_request_id).toString(),
      };
      final res = await post(data, paymentRequestionDetailsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return paymentRequisitionDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequestionBankDetailsResponse?>
  paymentRequestionBankDetailsAPI(empId, session, account_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
      };
      final res = await post(data, paymentRequestBankDetailsUrl, {});
      if (res != null) {
        print("Bank Detaols ${data}");
        debugPrint(res.body);
        return paymentRequestionBankDetailsResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<approveRejectPaymentRequestResponse?>
  approveRejectPaymentRequestAPI(empId, session, payment_request_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_request_id': (payment_request_id).toString(),
      };
      final res = await post(data, approveRejectPaymentRequestUrl, {});
      if (res != null) {
        print("add payment:${data}");
        debugPrint(res.body);
        return approveRejectPaymentRequestResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<approveRejectPaymentRequestResponse?>
  RejectPaymentRequestSubmitAPI(
    empId,
    session,
    mode,
    payment_request_id,
    approve_remarks,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': 'reject',
        'mode': mode.toString(),
        'payment_request_id': (payment_request_id).toString(),
        'approve_remarks': approve_remarks,
      };
      final res = await post(data, approveRejectPaymentRequestSubmitUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return approveRejectPaymentRequestResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<approveRejectPaymentRequestResponse?>
  ApprovePaymentRequestSubmitAPI(
    empId,
    session,
    mode,
    payment_request_id,
    approved_amount,
    approve_remarks,
    proposed_payment_account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': 'approve',
        'mode': mode.toString(),
        'payment_request_id': (payment_request_id).toString(),
        'approve_remarks': approve_remarks,
        'approved_amount': approved_amount,
        'proposed_payment_account_id': proposed_payment_account_id,
      };
      // print(data);
      final res = await post(data, approveRejectPaymentRequestSubmitUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return approveRejectPaymentRequestResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> processApproveRejectPaymentRequestSubmitAPI(
    empId,
    session,
    mode,
    payment_reference_number,
    payment_amount,
    payment_request_id,
    payment_account_id,
    processing_remarks,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': 'approve'.toString(),
        'mode': mode.toString(),
        'payment_reference_number': payment_reference_number.toString(),
        'payment_amount': payment_amount.toString(),
        'payment_request_id': (payment_request_id).toString(),
        'payment_account_id': payment_account_id.toString(),
        'processing_remarks': processing_remarks.toString(),
      };
      var res;
      print("Process:${data}");
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          approveRejectPaymentRequestSubmitUrl,
          attachment,
          "attachment",
        );
        print("Process:${data}");
        res = jsonDecode(res);
        print(data);
        return CommonResponse.fromJson(res);
      } else {
        res = await post(data, approveRejectPaymentRequestSubmitUrl, {});
        res = jsonDecode(res.body);
        return CommonResponse.fromJson(res);
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequisitionPaymentsListResponse?>
  paymentRequisitionPaymentListAPI(empId, session, from, to) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'from': (from).toString(),
        'to': (to).toString(),
      };
      final res = await post(data, paymentRequesitionPaymentsListUrl, {});
      if (res != null) {
        print(data);

        print("payment req:${res.body}");
        return paymentRequisitionPaymentsListResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequisitionPaymentsReceiptsListResponse?>
  paymentRequisitionPaymentReceiptListAPI(empId, session, from, to) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'from': (from).toString(),
        'to': (to).toString(),
      };
      final res = await post(
        data,
        paymentRequesitionPaymentsReceiptsListUrl,
        {},
      );
      if (res != null) {
        debugPrint(res.body);
        return paymentRequisitionPaymentsReceiptsListResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequisitionPaymentsDetailsResponse?>
  paymentRequisitionPaymentDetailsAPI(empId, session, payment_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': (payment_id).toString(),
      };
      final res = await post(data, paymentRequesitionPaymentsDetailsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return paymentRequisitionPaymentsDetailsResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentRequisitionPaymentsReceiptsDetailsResponse?>
  paymentRequisitionPaymentReceiptDetailsAPI(empId, session, payment_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_receipt_id': (payment_id).toString(),
      };
      final res = await post(
        data,
        paymentRequesitionPaymentsReceiptsDetailsUrl,
        {},
      );
      if (res != null) {
        debugPrint(res.body);
        return paymentRequisitionPaymentsReceiptsDetailsResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }
  static Future<CommonResponse?> editProcessedRequestAmountAPI(
      empId,
      session,
      process_payment_id,
      approval_amount,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'process_payment_id': process_payment_id.toString(),
        'approval_amount': approval_amount.toString(),
      };
      print("Process EDIT:${data}");
      var res = await post(data, paymentRequesitionEditProcessedPaymentUrl, {});
      if (res != null) {


        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///common Module
  static Future<commonAccessiblePagesResponse?> commonDashboardPagesAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, commonAccessiblePagesUrl, {});
      if (res != null) {
        debugPrint("CA:${res.body}");
        return commonAccessiblePagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAddAccountsViewResponse?> commonAddAccountViewAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, commonAddAccountViewUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<DistrictsResponse?> commonAddAccountViewDistrictAPI(
    empId,
    session,
    state_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'state_id': state_id.toString(),
      };
      final res = await post(data, commonAddAccountViewgetDistrictUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return DistrictsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<SubLocationsResponse?> commonAddAccountViewSubLocationAPI(
    empId,
    session,
    district_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'district_id': district_id.toString(),
      };
      final res = await post(data, commonAddAccountViewgetSubLocationUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return SubLocationsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAddAccountsViewResponse?> commonAddAccountCheckInputsAPI(
    empId,
    session,
    type,
    type_value,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': (type).toString(),
        'type_value': (type_value).toString(),
      };
      final res = await post(data, commonAddAccountCheckInputsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return commonAddAccountsViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAddAccountsSubmitResponse?> commonAddAccountSubmitAPI(
    empId,
    session,
    type,
    name,
    mob1,
    mob2,
    tel,
    email,
    designation,
    address,
    state,
    district,
    sub_locality,
    bank_name,
    bank_branch_name,
    bank_ifsc_code,
    bank_account_holder_name,
    bank_account_number,
    bank_upi_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': type.toString(),
        'name': name.toString(),
        'mob1': mob1.toString(),
        'mob2': mob2.toString(),
        'tel': tel.toString(),
        'email': email.toString(),
        'designation': designation.toString(),
        'address': address.toString(),
        'state': state.toString(),
        'district': district.toString(),
        'sub_locality': sub_locality.toString(),
        'bank_name': bank_name.toString(),
        'bank_branch_name': bank_branch_name.toString(),
        'bank_ifsc_code': bank_ifsc_code.toString(),
        'bank_account_holder_name': bank_account_holder_name.toString(),
        'bank_account_number': bank_account_number.toString(),
        'bank_upi_id': bank_upi_id.toString(),
      };
      final res = await post(data, commonAddAccountSubmit, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return commonAddAccountsSubmitResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAccountlistResponse?> commonAccountListAPI(
    empId,
    session,
    page_number,
    company_name,
    mobile_number,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'page_number': page_number.toString(),
        'company_name': company_name.toString(),
        'mobile_number': mobile_number.toString(),
      };
      final res = await post(data, commonAccountListUrl, {});
      if (res != null) {
        debugPrint("adad:${res.body}");
        return commonAccountlistResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAccountdetailsResponse?> commonAccountDetailsAPI(
    empId,
    session,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': account_id.toString(),
      };
      final res = await post(data, commonAccountLedgerAccountDetails, {});
      if (res != null) {
        debugPrint(res.body);
        return commonAccountdetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAccountLedgerFilterResponse?>
  commonAccountLedgerDropDownAPI(empId, session) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, commonAccountLedgerDropDownUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return commonAccountLedgerFilterResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<commonAccountLedgerResponse?> commonAccountLedgerListAPI(
    empId,
    session,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': account_id.toString(),
      };
      print(data);
      final res = await post(data, commonAccountLedgerListWithFilterUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return commonAccountLedgerResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///Orders Module
  static Future<ordersAccessiblePagesResponse?> ordersAccesiblePagesAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ordersAccessiblePagesUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return ordersAccessiblePagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }


  static Future<ordersAccessiblePagesResponse?> ordersAccesibleAddPagesAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ordersAccessibleAddPagesUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return ordersAccessiblePagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<orderPendingTasksListResponse?> orderPendingTasksListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ordersPendingTasksListUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return orderPendingTasksListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<orderDashboardResponse?> ordersDashboardAPI(
    empId,
    session,
    mode,
    from,
    to,
    teamemployee,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'from': (from).toString(),
        'to': (to).toString(),
        'teamemployee': (teamemployee).toString(),
      };
      final res = await post(data, ordersDashboardUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return orderDashboardResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AddOrderViewResponse?> addOrderViewAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, ordersAddOrderViewUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return AddOrderViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addOrderAccontDetailsResponse?> addOrderAccountDetailsAPI(
    empId,
    session,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
      };
      final res = await post(data, ordersAddOrderAccountDetailsUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return addOrderAccontDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addOrderTpcAgentListResponse?> addOrderTPCAgentListAPI(
    empId,
    session,
    mode,
    text,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': mode.toString(),
        'text': (text).toString(),
      };
      final res = await post(data, ordersAddOrderTpcAgentListUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return addOrderTpcAgentListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> addOrderSubmitAPI(
    empId,
    session,
    mode,
    sales_person_emp_id,
    selected_acc_id,
    dispatch_state_id,
    dispatch_district_id,
    dispatch_sub_location_id,
    dispatch_pincode,
    dispatch_address,
    basic_amount,
    cgst_amount,
    sgst_amount,
    igst_amount,
    total_amount,
    order_received_date,
    note,
    unloading,
    freight,
    erection,
    tpc_applicable,
    billing_name,
    billing_gst_no,
    billing_pincode,
    billing_address,
    billing_state,
    billing_district,
    billing_sub_locality,
    order_products,
    lead_id,
    feedback,
    in_time,
    loc,
    requested_tpc_amount,
    tpc_agent_id,
    po,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': empId.toString(),
        'session_id': session.toString(),
        'mode': mode.toString(),
        'sales_person_emp_id': sales_person_emp_id.toString(),
        'selected_acc_id': selected_acc_id.toString(),
        'dispatch_state_id': dispatch_state_id.toString(),
        'dispatch_district_id': dispatch_district_id.toString(),
        'dispatch_sub_location_id': dispatch_sub_location_id.toString(),
        'dispatch_pincode': dispatch_pincode.toString(),
        'dispatch_address': dispatch_address.toString(),
        'basic_amount': basic_amount.toString(),
        'cgst_amount': cgst_amount.toString(),
        'sgst_amount': sgst_amount.toString(),
        'igst_amount': igst_amount.toString(),
        'total_amount': total_amount.toString(),
        'order_received_date': order_received_date.toString(),
        'note': note.toString(),
        'unloading': unloading.toString(),
        'freight': freight.toString(),
        'erection': erection.toString(),
        'tpc_applicable': tpc_applicable.toString(),
        'billing_name': billing_name.toString(),
        'billing_gst_no': billing_gst_no.toString(),
        'billing_pincode': billing_pincode.toString(),
        'billing_address': billing_address.toString(),
        'billing_state': billing_state.toString(),
        'billing_district': billing_district.toString(),
        'billing_sub_locality': billing_sub_locality.toString(),
        'order_products': (order_products).toString(),
        'lead_id': lead_id.toString(),
        'feedback': feedback.toString(),
        'in_time': in_time.toString(),
        'loc': loc.toString(),
        'requested_tpc_amount': requested_tpc_amount.toString(),
        'tpc_agent_id': tpc_agent_id.toString(),
      };
      var res;
      print("add order:${data}");
      if (po != null) {
        res = await postImageNew(data, {}, ordersAddOrderSubmitUrl, po, "po");
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersAddOrderSubmitUrl, {});
        res = jsonDecode(res.body);
      }
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersListByModeFilterResponse?> ordersListByModeFilterAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, ordersOrderListByModeUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return ordersListByModeFilterResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersListByModeResponse?> ordersListByModeAPI(
    empId,
    session,
    mode,
    teamemployee,
    status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'teamemployee': (teamemployee).toString(),
        'status': (status).toString(),
      };
      final res = await post(data, ordersOrderListFilterUrl, {});
      if (res != null) {
        print("mode: $data");
        debugPrint(res.body);
        return ordersListByModeResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersDetailsByModeResponse?> ordersDetailsByModeAPI(
    empId,
    session,
    order_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'order_id': (order_id).toString(),
      };
      final res = await post(data, ordersOrderDetailsUrl, {});
      if (res != null) {
        print("Order Details ${data}");
        print("Order Details ${res.body}");
        return ordersDetailsByModeResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersDetailsFeedbackSubmissionAPI(
    empId,
    session,
    order_id,
    feedback,
    status,
    attachment_file,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'order_id': order_id.toString(),
        'feedback': (feedback).toString(),
        'status': status,
      };
      var res;
      if (attachment_file != null) {
        res = await postImageNew(
          data,
          {},
          ordersOrderDetailsFeedbackSubmitUrl,
          attachment_file,
          "attachment_file",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersOrderDetailsFeedbackSubmitUrl, {});
        res = jsonDecode(res.body);
      }
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersDetailsEditOrderViewResponse?>
  ordersDetailsEditOrderViewAPI(empId, session, order_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'order_id': order_id.toString(),
      };

      var res = await post(data, ordersOrderDetailsEditOrderUrl, {});
      if (res != null) {
        return ordersDetailsEditOrderViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersDetailsEditOrderSubmitAPI(
    empId,
    session,
    order_id,
    attachment_file,
    dispatch_state_id,
    district,
    sub_locality,
    dispatch_pincode,
    dispatch_address,
    unloading,
    freight,
    erection,
    note,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': empId.toString(),
        'session_id': session.toString(),
        'order_id': order_id.toString(),
        'dispatch_state_id': dispatch_state_id.toString(),
        'district': district.toString(),
        'sub_locality': sub_locality.toString(),
        'dispatch_pincode': dispatch_pincode.toString(),
        'dispatch_address': dispatch_address.toString(),
        'unloading': unloading.toString(),
        'freight': freight.toString(),
        'erection': erection.toString(),
        'note': note.toString(),
      };
      var res;
      print("Edit Order:$data");
      if (attachment_file != null) {
        res = await postImageNew(
          data,
          {},
          ordersOrderDetailsEditOrderSubmitUrl,
          attachment_file,
          "attachment_file",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersOrderDetailsEditOrderSubmitUrl, {});
        res = jsonDecode(res.body);
      }
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersDetailsDispatchOrderViewResponse?>
  ordersDetailsDispatchOrderViewAPI(empId, session, order_id) async {
    try {
      Map<String, String> data = {
        'emp_id': empId.toString(),
        'session_id': session.toString(),
        'order_id': order_id.toString(),
      };

      final res = await post(data, ordersOrderDetailsDispatchProductsUrl, {});
      if (res != null) {
        return ordersDetailsDispatchOrderViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ordersPdiIdByEngNumberResponse?> ordersPdiIdByEngNumberUrlAPI(
    empId,
    session,
    engine_number,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': empId.toString(),
        'session_id': session.toString(),
        'engine_number': engine_number.toString(),
      };

      final res = await post(data, ordersPdiIdByEngNumberUrl, {});
      if (res != null) {
        return ordersPdiIdByEngNumberResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersDetailsApproveRejectAPI(
    empId,
    session,
    status,
    type,
    order_id,
    feedback,
    tpc_applicable,
    tpc_approved_amount,
    sale_order_number,
    edit_company_name,
    invoice_number,
    vehicle_number,
    driver_name,
    driver_mobile_no,
    crm_order_p_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "status": status.toString(),
        "type": type.toString(),
        "order_id": order_id.toString(),
        "feedback": feedback.toString(),
        "tpc_applicable": tpc_applicable.toString(),
        "tpc_approved_amount": tpc_approved_amount.toString(),
        "sale_order_number": sale_order_number.toString(),
        "edit_company_name": edit_company_name.toString(),
        "invoice_number": invoice_number.toString(),
        "vehicle_number": vehicle_number.toString(),
        "driver_name": driver_name.toString(),
        "driver_mobile_no": driver_mobile_no.toString(),
        "crm_order_p_id": crm_order_p_id.toString(),
      };
      final res = await post(data, ordersOrderApproveRejectUrl, {});
      if (res != null) {
        print("DATATATATA:: $data");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersDetailsDeleteAPI(
    empId,
    session,
    order_id,
    feedback,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "order_id": order_id.toString(),
        "feedback": feedback.toString(),
      };
      final res = await post(data, ordersOrderLDeleteUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<addOrderPaymentViewResponse?> addOrderpaymentListViewAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ordersAddPaymentViewUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return addOrderPaymentViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> addOrderpaymentListSubmitAPI(
    empId,
    session,
    account_id,
    description,
    selected_orders,
    payment_amount,
    payment_date,
    payment_type,
    ref_no,
    attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': account_id.toString(),
        'description': description.toString(),
        'selected_orders': jsonEncode(selected_orders).toString(),
        'payment_amount': payment_amount.toString(),
        'payment_date': payment_date.toString(),
        'payment_type': payment_type.toString(),
        'ref_no': ref_no.toString(),
      };
      var res;
      print("Add Payment: ${data}");
      if (attachment != null) {
        res = await postImageNew(
          data,
          {},
          ordersAddPaymentSubmitUrl,
          attachment,
          "attachment",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersAddPaymentSubmitUrl, {});
        res = jsonDecode(res.body);
        // return CommonResponse.fromJson(res);
      }
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersEditPaymentDetailsAPI(
    empId,
    session,
    payment_id,
    description,
    payment_type,
    ref_no,
    payment_date,
    amount,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': payment_id.toString(),
        'description': description.toString(),
        'payment_type': payment_type.toString(),
        'payment_date': payment_date.toString(),
        'ref_no': ref_no.toString(),
        'amount': amount.toString(),
      };

      var res = await post(data, ordersEditPaymentDetailsUrl, {});
      if (res != null) {
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<EditPaymentDetailsAdjustedOrdersViewResponse?>
  ordersEditPaymentDetailsAdjustedOrdersViewAPI(
    empId,
    session,
    payment_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': payment_id.toString(),
      };

      var res = await post(
        data,
        ordersEditPaymentDetailsAdjustedOrdersViewUrl,
        {},
      );
      if (res != null) {
        print("edit adjusted : ${res.body}");
        return EditPaymentDetailsAdjustedOrdersViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<EditPaymentDetailsAdjustedOrdersViewResponse?>
  ordersEditPaymentDetailsAdjustedOrdersUpdateAPI(
    empId,
    session,
    payment_id,
    update_amounts,
    insert_amounts,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': payment_id.toString(),
        'update_amounts': jsonEncode(update_amounts).toString(),
        'insert_amounts': jsonEncode(insert_amounts).toString(),
      };

      var res = await post(data, ordersEditPaymentDetailsAdjustedOrdersUrl, {});
      if (res != null) {
        return EditPaymentDetailsAdjustedOrdersViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AddOrderPaymentSelectAccountResponse?>
  AddOrderPaymentSelectAccountAPI(empId, session, mode, search_term) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': mode.toString(),
        'search_term': search_term.toString(),
      };
      final res = await post(
        data,
        ordersAddPaymentSelectAccountForOrderUrl,
        {},
      );
      if (res != null) {
        print(data);
        print("PaymentSeralectAccount${res.body}");
        return AddOrderPaymentSelectAccountResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<AddOrderPaymentSelectOrderResponse?>
  AddOrderPaymentSelectOrderAPI(empId, session, account_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': account_id.toString(),
      };
      final res = await post(data, ordersAddPaymentSelectOrderUrl, {});
      if (res != null) {
        print(data);
        debugPrint("add order payment selected order: ${res.body}");
        return AddOrderPaymentSelectOrderResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentListByModeFilterResponse?> paymentListByModeFilterAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, ordersPaymentListFilterUrl, {});
      if (res != null) {
        debugPrint(res.body);
        return paymentListByModeFilterResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentListByModeResponse?> paymentListsByModeAPI(
    empId,
    session,
    mode,
    teamemployee,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'teamemployee': (teamemployee).toString(),
      };
      final res = await post(data, ordersPaymentListByModeUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return paymentListByModeResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> paymentOrderApproveRejectAPI(
    empId,
    session,
    payment_id,
    type,
    remarks,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "payment_id": payment_id.toString(),
        "type": type.toString(),
        "remarks": remarks.toString(),
      };
      final res = await post(data, ordersPaymentListApproveRejectUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }


  static Future<CommonResponse?> verifyOrderAPI(
    empId,
    session,
      order_id,
      otp,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "order_id": order_id.toString(),
        "otp": otp.toString(),
      };
      final res = await post(data, ordersVerifyOtpUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> resendOTPOrderAPI(
    empId,
    session,
      order_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "order_id": order_id.toString(),
      };
      final res = await post(data, ordersResendOtpUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> paymentOrderDeleteAPI(
    empId,
    session,
    payment_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        "payment_id": payment_id.toString(),
      };
      final res = await post(data, ordersPaymentListDeleteUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<paymentDetailsByModeFilterResponse?> paymentsDetailsByModeAPI(
    empId,
    session,
    payment_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': (payment_id).toString(),
      };
      final res = await post(data, ordersPaymentDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return paymentDetailsByModeFilterResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> paymentsDetailsAddAdjustedOrderAPI(
    empId,
    session,
    payment_id,
      selected_order_id,
      amount,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'payment_id': (payment_id).toString(),
        'selected_order_id': (selected_order_id).toString(),
        'amount': (amount).toString(),

      };
      final res = await post(data, ordersPaymentDetailsAddOrderUrl, {});
      if (res != null) {
        print("paymentsDetailsAddAdjusted: $data");
        debugPrint(res.body);
        return CommonResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> paymentsDetailsEditAdjustedOrderAPI(
    empId,
    session,
      selected_order_id,
      amount,
      order_payment_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'selected_order_id': (selected_order_id).toString(),
        'amount': (amount).toString(),
        'order_payment_id': (order_payment_id).toString(),
      };
      final res = await post(data, ordersPaymentDetailsEditOrderUrl, {});
      if (res != null) {
        print("paymentsDetailsEditAdjusted $data");
        debugPrint(res.body);
        return CommonResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> ordersAddTPCAgentAPI(
    empId,
    session,
    agent_name,
    mobile_number,
    bank_name,
    bank_account_no,
    bank_ifsc_code,
    bank_beneficiary_name,
    note,
    id_proof,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'agent_name': agent_name.toString(),
        'mobile_number': mobile_number.toString(),
        'bank_name': bank_name.toString(),
        'bank_account_no': bank_account_no.toString(),
        'bank_ifsc_code': bank_ifsc_code.toString(),
        'bank_beneficiary_name': bank_beneficiary_name.toString(),
        'note': note.toString(),
      };
      var res;
      print("add TPC: $data");
      if (id_proof != null) {
        res = await postImageNew(
          data,
          {},
          ordersAddTPCAgentUrl,
          id_proof,
          "id_proof",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersAddTPCAgentUrl, {});
        res = jsonDecode(res.body);
        // return CommonResponse.fromJson(res);
      }
      print("Add TPC: ${res}");
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TPCListResponse?> TPCAgentListAPI(empId, session, mode) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, ordersTPCAgentListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return TPCListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<TPCAgentDetailsResponse?> TPCAgentDetailsAPI(
    empId,
    session,
    tpc_agent_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'tpc_agent_id': (tpc_agent_id).toString(),
      };
      final res = await post(data, ordersTPCAgentDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return TPCAgentDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<PendingTPCAgentListResponse?> pendingTPCAgentIssueListAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ordersPendingTPCIssueListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return PendingTPCAgentListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> TpcIssueListApprovalAPI(
    empId,
    session,
    tpc_payment_mode,
    tpc_payment_reference_no,
    order_id,
    order_tpc_feedback,
    tpc_paym_attachment,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'tpc_payment_mode': tpc_payment_mode.toString(),
        'tpc_payment_reference_no': tpc_payment_reference_no.toString(),
        'order_id': order_id.toString(),
        'order_tpc_feedback': order_tpc_feedback.toString(),
      };
      var res;
      if (tpc_paym_attachment != null) {
        res = await postImageNew(
          data,
          {},
          ordersApprovePendingTPCIssueListUrl,
          tpc_paym_attachment,
          "tpc_paym_attachment",
        );
        res = jsonDecode(res);
      } else {
        res = await post(data, ordersApprovePendingTPCIssueListUrl, {});
        res = jsonDecode(res.body);
        // return CommonResponse.fromJson(res);
      }
      return CommonResponse.fromJson(res);
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  ///CRM Module
  static Future<AccessiblePagesResponse?> crmAccessiblePagesAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, crmAccessiblePagesUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Accessibl pages: ${res.body}");
        return AccessiblePagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmNewLeadsProspectsViewResponse?> crmNewLeadsProspectsViewAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, crmNewProspectLeadViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint("New Leads prospecrs ${res.body}");
        return crmNewLeadsProspectsViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmNewLeadsProspectsSubmitResponse?> crmNewLeadsProspectsSubmitAPI(
    session_id,
    emp_id,
    mode,
    acc_manager_id,
    salutation_name,
    name,
    contact_name,
    district,
    state,
    address,
    segment,
    source,
    reference,
    team,
    sub_locality,
    mob1,
    mob2,
    tel,
    email,
    designation,
    lead_status,
    products,
  ) async {
    try {
      Map<String, String> data = {
        'session_id': session_id.toString(),
        'emp_id': emp_id.toString(),
        'mode': mode.toString(),
        'acc_manager_id': acc_manager_id.toString(),
        'salutation_name': salutation_name.toString(),
        'name': name.toString(),
        'contact_name': contact_name.toString(),
        'district': district.toString(),
        'state': state.toString(),
        'address': address.toString(),
        'segment': segment.toString(),
        'source': source.toString(),
        'reference': reference.toString(),
        'team': team.toString(),
        'sub_locality': sub_locality.toString(),
        'mob1': mob1.toString(),
        'mob2': mob2.toString(),
        'tel': tel.toString(),
        'email': email.toString(),
        'designation': designation.toString(),
        'lead_status': lead_status.toString(),
        'products': products.toString(),
      };
      final res = await post(data, crmNewProspectLeadSubmitUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Submit New Leads ${res.body}");
        return crmNewLeadsProspectsSubmitResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmDashboardResponse?> crmDashboardAPI(
    empId,
    session,
    emp_loc,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'emp_loc': emp_loc.toString(),
      };
      final res = await post(data, crmDashboardUrl, {});
      if (res != null) {
        print(data);
        print("CRM Dash ${jsonDecode(res.body)}");
        return crmDashboardResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmPendingTasksResponse?> crmPendingTasksAPI(
    empId,
    session,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, crmPendingTasksListUrl, {});
      if (res != null) {
        print(data);
        debugPrint("PEnding Tasks ${res.body}");
        return crmPendingTasksResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmUniversalSearchResponse?> crmUniversalSearchAPI(
    empId,
    session,
    q,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'q': (q).toString(),
      };
      final res = await post(data, crmUnivesalSearchUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Universal Search ${res.body}");
        return crmUniversalSearchResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<LeadListViewResponse?> crmLeadListViewAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, crmLeadListViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Lead ListView2: ${res.body}");
        return LeadListViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<SubmitLeadListFilterResponse?> crmLeadListFilterSubmitAPI(
    empId,
    session,
    mode,
    status,
    open_status,
    mob,
    com,
    source,
    reference,
    team,
    segment,
    alphabet,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'status': status.toString(),
        'open_status': open_status.toString(),
        'mob': mob.toString(),
        'com': com.toString(),
        'source': source.toString(),
        'reference': reference.toString(),
        'team': team.toString(),
        'segment': segment.toString(),
        'alphabet': alphabet.toString(),
      };
      final res = await post(data, crmLeadListFilterSubmitUrl, {});
      if (res != null) {
        print("Lead Filter:${data}");
        debugPrint(res.body);
        return SubmitLeadListFilterResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<GetSourceOnReferenceResponse?> crmLeadListSourceOnReferenceAPI(
    empId,
    session,
    source_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'source_id': (source_id).toString(),
      };
      final res = await post(data, crmLeadListSourceOnReferenceUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Source on Ref ${res.body}");
        return GetSourceOnReferenceResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<GetSegmentOnTeamResponse?> crmLeadListSegmentOnTeamAPI(
    empId,
    session,
    team_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'team_id': (team_id).toString(),
      };
      final res = await post(data, crmLeadListSegmentOnTeamUrl, {});
      if (res != null) {
        print(data);
        print("Segemnt on team ${res.body}");
        return GetSegmentOnTeamResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<GetDistrictOnStateResponse?> crmDistrictsOnStateAPI(
    empId,
    session,
    state_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'state_id': (state_id).toString(),
      };
      final res = await post(data, crmLeadListDistrictOnStateUrl, {});
      if (res != null) {
        print(data);
        debugPrint("districts on State ${res.body}");
        return GetDistrictOnStateResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<GetSubLocOnDistrictResponse?> crmSubLocOnDistrictAPI(
    empId,
    session,
    district_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'district_id': (district_id).toString(),
      };
      final res = await post(data, crmLeadListSubLocOnDistrictUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Sub loc on Dist ${res.body}");
        return GetSubLocOnDistrictResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<LeadListContactPopUpResponse?> crmLeadListContactPopUpAPI(
    empId,
    session,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
      };
      final res = await post(data, crmLeadListContactPopUpUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Lead list contact ${res.body}");
        return LeadListContactPopUpResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<LeadDetailsResponse?> crmLeadDetailsAPI(
    empId,
    session,
    lead_id,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, crmLeadDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint("Lead Deatails ${res.body}");
        return LeadDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsAddEditProductsAPI(
    empId,
    session,
    lead_id,
    type,
    lead_product_id,
    product_id,
    qty,
    amount,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
        'type': (type).toString(),
        'lead_product_id': (lead_product_id).toString(),
        'product_id': (product_id).toString(),
        'qty': (qty).toString(),
        'amount': (amount).toString(),
      };
      final res = await post(data, crmLeadDetailsAddEditProductsUrl, {});
      if (res != null) {
        print("AddEditProducts $data");
        debugPrint("AddEditProducts: ${res.body}");
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmAddFollowUpResponse?> crmLeadDetailsAddFollowUpAPI(
    session_id,
    emp_id,
    nextapp,
    orderstatus,
    lead_id,
    followup_feedback,
    followup_type,
    followupintime,
    loc,
    competitor,
    reason,
    followup_status,
    next_appointment_date,
    appointment_type,
    sms,
    app_note,
  ) async {
    try {
      Map<String, String> data = {
        'session_id': session_id.toString(),
        'emp_id': emp_id.toString(),
        'nextapp': nextapp.toString(),
        'orderstatus': orderstatus.toString(),
        'lead_id': lead_id.toString(),
        'followup_feedback': followup_feedback.toString(),
        'followup_type': followup_type.toString(),
        'followupintime': followupintime.toString(),
        'loc': loc.toString(),
        'competitor': competitor.toString(),
        'reason': reason.toString(),
        'followup_status': followup_status.toString(),
        'next_appointment_date': next_appointment_date.toString(),
        'appointment_type': appointment_type.toString(),
        'sms': sms.toString(),
        'app_note': app_note.toString(),
      };

      final res = await post(data, crmLeadDetailsAddFollowUpUrl, {});
      if (res != null) {
        print("crmAddFollowUp: $data");
        debugPrint("crmAddFollowUp: ${res.body}");
        return crmAddFollowUpResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmLeadDetailsEditAccountViewResponse?>
  crmLeadDetailsEditAccountViewAPI(empId, session, lead_id, mode) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, crmLeadDetailsEditAccountViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint("crmLeadDetailsEditAccountViewAPI: ${res.body}");
        return crmLeadDetailsEditAccountViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsEditAccountSubmitAPI(
    empId,
    session,
    account_id,
    segment_id,
    team_id,
    account_name,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
        'segment_id': (segment_id).toString(),
        'team_id': (team_id).toString(),
        'account_name': (account_name).toString(),
      };
      final res = await post(data, crmLeadDetailsEditAccountUrl, {});
      if (res != null) {
        print(data);
        debugPrint("crmLeadDetailsEditAccountSubmitAPI ${res.body}");
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmLeadDetailsEditProductsViewResponse?>
  crmLeadDetailsEditProductsViewAPI(empId, session, lead_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
      };
      final res = await post(data, crmLeadDetailsEditProductsViewUrl, {});
      if (res != null) {
        print(data);
        print("crmLeadDetailsEditProductsViewAPI: ${jsonDecode(res.body)['lead_products']}");
        debugPrint(res.body);
        return crmLeadDetailsEditProductsViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsEditProductsSubmitAPI(
    empId,
    session,
    products,
    lead_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'products': jsonEncode(products).toString(),
        'lead_id': (lead_id).toString(),
      };
      final res = await post(data, crmLeadDetailsEditProductsUrl, {});
      if (res != null) {
        print(data);
        print("crmLeadDetailsEditProductsSubmitAPI: ${jsonDecode(res.body)}");
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsAddContactAPI(
    empId,
    session,
    acc_id,
    name,
    mob1,
    designation,
    mob2,
    tel,
    email,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'acc_id': (acc_id).toString(),
        'name': (name).toString(),
        'mob1': (mob1).toString(),
        'designation': (designation).toString(),
        'mob2': (mob2).toString(),
        'tel': (tel).toString(),
        'email': (email).toString(),
      };
      final res = await post(data, crmLeadDetailsAddContactUrl, {});
      if (res != null) {
        print(data);
        debugPrint("crmLeadDetailsAddContactAPI${res.body}");
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsEditContactAPI(
    empId,
    session,
    contact_id,
    name,
    mob1,
    designation,
    mob2,
    tel,
    email,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'contact_id': (contact_id).toString(),
        'name': (name).toString(),
        'mob1': (mob1).toString(),
        'designation': (designation).toString(),
        'mob2': (mob2).toString(),
        'tel': (tel).toString(),
        'email': (email).toString(),
      };
      final res = await post(data, crmLeadDetailsEditContactUrl, {});
      if (res != null) {
        print(data);
        debugPrint("crmLeadDetailsEditContactAPI ${res.body}");
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmLeadDetailsAddAppointmentAPI(
    empId,
    session,
    lead_id,
    appointment_date,
    type,
    note,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
        'appointment_date': (appointment_date).toString(),
        'type': (type).toString(),
        'note': (note).toString(),
      };
      final res = await post(data, crmLeadDetailsAddAppointmentUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmLeadDetailsGenerateQuotationViewResponse?>
  crmLeadDetailsGenerateQuotationViewAPI(empId, session, lead_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'lead_id': (lead_id).toString(),
      };
      final res = await post(data, crmLeadDetailsGenerateQuotationViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint("ListView1: ${res.body}");
        return crmLeadDetailsGenerateQuotationViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmLeadDetailsGenerateQuotationSubmitResponse?>
  crmLeadDetailsGenerateQuotationSubmitAPI(
    emp_id,
    session_id,
    lead_id,
    quotemno,
    quotesubject,
    taxes,
    quotenote,
    quotefor,
    quotep_terms,
    quotemail,
    quote_products,
    quotation_type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': emp_id.toString(),
        'session_id': session_id.toString(),
        'lead_id': lead_id.toString(),
        'quotemno': quotemno.toString(),
        'quotesubject': quotesubject.toString(),
        'taxes': taxes.toString(),
        'quotenote': quotenote.toString(),
        'quotefor': quotefor.toString(),
        'quotep_terms': quotep_terms.toString(),
        'quotemail': quotemail.toString(),
        'quote_products': jsonEncode(quote_products).toString(),
        'quotation_type': quotation_type.toString(),
      };
      final res = await post(
        data,
        crmLeadDetailsGenerateQuotationSubmitUrl,
        {},
      );
      if (res != null) {
        print("Filter: ${data}");
        debugPrint(res.body);
        return crmLeadDetailsGenerateQuotationSubmitResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }


  static Future<crmDownloadGenQuoteResponse?>
  crmDownloadGenQuoteAPI(
    emp_id,
    session_id,
    lead_id,
      quote_id,
      quotation_type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': emp_id.toString(),
        'session_id': session_id.toString(),
        'lead_id': lead_id.toString(),
        'quote_id': quote_id.toString(),
        'quotation_type': quotation_type.toString(),

      };
      final res = await post(
        data,
        crmDownloadGeneratedQuotationUrl,
        {},
      );
      if (res != null) {
        print("Filter: ${data}");
        debugPrint(res.body);
        return crmDownloadGenQuoteResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<ProspectListViewResponse?> crmProspectListViewAPI(
    empId,
    session,
    mode,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, crmProspectListViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint("ListView3: ${res.body}");
        return ProspectListViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<SubmitProspectListFilterResponse?>
  crmProspectListFilterSubmitAPI(
    empId,
    session,
    mode,
    teamemployee,
    mob,
    company_name,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'teamemployee': teamemployee.toString(),
        'mob': mob.toString(),
        'company_name': company_name.toString(),
      };
      final res = await post(data, crmProspectListFilterSubmitUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return SubmitProspectListFilterResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmProspectDetailsResponse?> crmProspectDetailsAPI(
    empId,
    session,
    account_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
      };
      final res = await post(data, crmProspectDetailsUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return crmProspectDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsTransferAccountAPI(
    empId,
    session,
    account_id,
    tranemp_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
        'tranemp_id': (tranemp_id).toString(),
      };
      final res = await post(data, crmProspectDetailsTransferAccountUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmProspectDetailsEditAccountViewResponse?>
  crmProspectDetailsEditAccountViewAPI(empId, session, account_id) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
      };
      final res = await post(data, crmProspectDetailsEditAccountViewUrl, {});
      if (res != null) {
        print("Filter:${data}");
        print("Stetets:${jsonDecode(res.body)['states']}");
        return crmProspectDetailsEditAccountViewResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsEditAccountSubmitAPI(
    empId,
    session,
    account_id,
    edit_company_name,
    edit_salutation_name,
    state_id,
    district,
    sub_locality,
    pincode,
    address,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': (account_id).toString(),
        'edit_company_name': edit_company_name.toString(),
        'edit_salutation_name': edit_salutation_name.toString(),
        'state_id': state_id.toString(),
        'district': district.toString(),
        'sub_locality': sub_locality.toString(),
        'pincode': pincode.toString(),
        'address': address.toString(),
      };
      final res = await post(data, crmProspectDetailsEditAccountSubmitUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmProspectDetailsAddLeadsResponse?>
  crmProspectDetailsAddLeadViewAPI(empId, session, mode) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
      };
      final res = await post(data, crmProspectDetailsAddLeadViewUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return crmProspectDetailsAddLeadsResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsAddLeadSubmitAPI(
    empId,
    session,
    mode,
    account_id,
    acc_manager_id,
    products,
    lead_status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'mode': (mode).toString(),
        'account_id': account_id.toString(),
        'acc_manager_id': acc_manager_id.toString(),
        'products': jsonEncode(products).toString(),
        'lead_status': lead_status.toString(),
      };
      final res = await post(data, crmProspectDetailsAddLeadSubmitUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsAddLeadAPI(
    empId,
    session,
    account_id,
    product_id,
    quantity,
    amount,
    lead_status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'account_id': account_id.toString(),
        'product_id': product_id.toString(),
        'quantity': quantity.toString(),
        'amount': amount.toString(),
        'lead_status': lead_status.toString(),
      };
      final res = await post(data, crmProspectDetailsAddLeadUrl, {});
      if (res != null) {
        print("crmProspectDetailsAddLead:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsAddAccountAPI(
    empId,
    session,
    name,
    acc_id,
    mob1,
    designation,
    email,
    tel,
    mob2,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'name': name.toString(),
        'acc_id': acc_id.toString(),
        'mob1': mob1.toString(),
        'designation': designation.toString(),
        'email': email.toString(),
        'tel': tel.toString(),
        'mob2': mob2.toString(),
      };
      final res = await post(data, crmProspectDetailsAddAccountUrl, {});
      if (res != null) {
        print("crmProspectDetailsAddAccountAPI:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> crmProspectDetailsEditContactAPI(
    empId,
    session,
    contact_id,
    name,
    acc_id,
    mob1,
    mob2,
    tel,
    designation,
    email,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'contact_id': (contact_id).toString(),
        'name': name.toString(),
        'acc_id': acc_id.toString(),
        'mob1': mob1.toString(),
        'mob2': mob2.toString(),
        'tel': tel.toString(),
        'designation': designation.toString(),
        'email': email.toString(),
      };
      final res = await post(data, crmProspectDetailsEditContactUrl, {});
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmProspectDetailsAddFollowUpAppointmentResponse?>
  crmProspectDetailsFollowupNextAppointmentAPI(
    empId,
    session,
    nextapp,
    orderstatus,
    lead_id,
    followup_feedback,
    followup_type,
    followupintime,
    loc,
    followup_status,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'nextapp': nextapp.toString(),
        'orderstatus': orderstatus.toString(),
        'lead_id': lead_id.toString(),
        'followup_feedback': followup_feedback.toString(),
        'followup_type': followup_type.toString(),
        'followupintime': followupintime.toString(),
        'loc': loc.toString(),
        'followup_status': followup_status.toString(),
      };
      final res = await post(
        data,
        crmProspectDetailsFollowupNextAppointmentUrl,
        {},
      );
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return crmProspectDetailsAddFollowUpAppointmentResponse.fromJson(
          jsonDecode(res.body),
        );
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<appointmentCalendarResponse?> crmAppointmentCalendarAPI(
    empId,
    session,
    appointment_date,
    type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'appointment_date': (appointment_date).toString(),
        'type': (type).toString(),
      };
      final res = await post(data, crmAppointmentCalendarUrl, {});
      if (res != null) {
        print("appointmentCalendar: ${data}");
        debugPrint(res.body);
        return appointmentCalendarResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmSelectedProductDetailsResponse?> crmSelectedProductDetailsApi(
    empId,
    session,
      product_id,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'product_id': (product_id).toString(),
      };
      final res = await post(data, crmSelectedProductDetailsUrl, {});
      if (res != null) {
        print("crmSelectedProductDetailsApi: ${data}");
        debugPrint(res.body);
        return crmSelectedProductDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }



  static Future<CommonResponse?> crmCheckAccountFieldsApi(
    empId,
    session,
      type_value,
      type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type_value': (type_value).toString(),
        'type': (type).toString(),
      };
      final res = await post(data, crmCheckAccountFieldsUrl, {});
      if (res != null) {
        print("crmCheckAccountFieldsApi: ${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?>
  crmProspectDetailsFollowupNextAppointmentOtherCaseAPI(
    empId,
    session,
    nextapp,
    orderstatus,
    lead_id,
    followup_feedback,
    followup_type,
    followupintime,
    loc,
    followup_status,
    appointmentset,
    app_date,
    sms,
    app_note,
    in_t,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'nextapp': nextapp.toString(),
        'orderstatus': orderstatus.toString(),
        'lead_id': lead_id.toString(),
        'followup_feedback': followup_feedback.toString(),
        'followup_type': followup_type.toString(),
        'followupintime': followupintime.toString(),
        'loc': loc.toString(),
        'followup_status': followup_status.toString(),
        'appointmentset': appointmentset.toString(),
        'app_date': app_date.toString(),
        'sms': sms.toString(),
        'app_note': app_note.toString(),
        'in_t': in_t.toString(),
      };
      final res = await post(
        data,
        crmProspectDetailsFollowupNextAppointmentUrl,
        {},
      );
      if (res != null) {
        print("Filter:${data}");
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<NearbyOpenLeadsResponse?> loadNearbyOpenLeadsAPI(
    empId,
    session,
    emp_loc,
    radius,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'emp_loc': (emp_loc).toString(),
        'radius': radius.toString(),
      };
      final res = await post(data, crmNearbyOpenLeadsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return NearbyOpenLeadsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmDashboardFollowUpResponse?> crmDashboardFollowUpAPI(
    empId,
    session,
      type,
  ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': (type).toString(),
      };
      final res = await post(data, crmDashboardFollowUpUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return crmDashboardFollowUpResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<crmDashboardQuotationResponse?> crmDashboardQuotationsAPI(
      empId,
      session,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, crmDashboardQuotationsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return crmDashboardQuotationResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

///hrm modules
  ///
  ///

  static Future<ogresponse?> ogChartAPI(
      empId,
      session,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, ogcharturl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return ogresponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }
  static Future<hrmAccessiblePagesResponse?> hrmAccessiblePagesAPI(
      empId,
      session,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
      };
      final res = await post(data, HrmAccessiblePagesUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return hrmAccessiblePagesResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<attendanceRequestListResponse?> attendanceRequestListAPI(
      empId,
      session,
      type,
      from,
      to,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'type': (type),
        'from': (from),
        'to': (to),
      };
      final res = await post(data, AttendanceRequestListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return attendanceRequestListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<attendanceRequestDetailsResponse?> attendanceRequestDetailAPI(
      empId,
      session,
      attendanceRequestId,
      ) async {
    try {
      Map<String, String> data = {
        'emp_id': (empId).toString(),
        'session_id': (session).toString(),
        'attendance_request_id': (attendanceRequestId),
      };
      final res = await post(data, AttendanceRequestDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return attendanceRequestDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<CommonResponse?> addAttendanceRequestAPI({
    required String sessionId,
    required String empId,
    required String process,
    required String type,
    required String loc,
    required String checkDate,
    String? checkInTime,
    String? checkInLoc,
    File? checkInProof,
    String? checkOutTime,
    String? checkOutLoc,
    File? checkOutProof,
    String? note,
  }) async {
    try {
      var request = http.MultipartRequest('POST', Uri.parse(AddAttendanceRequestUrl));

      // Add basic fields that are always required
      Map<String, String> fields = {
        "session_id": sessionId,
        "emp_id": empId,
        "process": process,
        "type": type,
        "loc": loc,
        "check_date": checkDate,
        "note": note ?? "",
      };

      // Conditionally add check-in fields based on type
      if (type == "Check In" || type == "Check In/Out") {
        fields["check_in_time"] = checkInTime ?? "";
        fields["check_in_loc"] = checkInLoc ?? "";

        if (checkInProof != null) {
          request.files.add(await http.MultipartFile.fromPath("check_in_proof", checkInProof.path));
        }
      }

      // Conditionally add check-out fields based on type
      if (type == "Check Out" || type == "Check In/Out") {
        fields["check_out_time"] = checkOutTime ?? "";
        fields["check_out_loc"] = checkOutLoc ?? "";

        if (checkOutProof != null) {
          request.files.add(await http.MultipartFile.fromPath("check_out_proof", checkOutProof.path));
        }
      }

      // Add all fields to the request
      request.fields.addAll(fields);

      // Log the actual fields being sent
      debugPrint("addAttendanceRequestAPI - Type: $type");
      debugPrint("addAttendanceRequestAPI - Fields: $fields");
      debugPrint("addAttendanceRequestAPI - Files: ${request.files.map((f) => f.filename).toList()}");

      var response = await request.send();
      var resBody = await response.stream.bytesToString();

      debugPrint("Server Response: $resBody");

      if (response.statusCode == 200) {
        return CommonResponse.fromJson(jsonDecode(resBody));
      } else {
        return null;
      }
    } catch (e) {
      debugPrint("API Error: $e");
      return null;
    }
  }




  //reward list
  static Future<rewardListResponse?> rewardListAPI(
      empId,
      session,
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
      };
      final res = await post(data, RewardListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return rewardListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  //tour exp
  static Future<tourExpensesListResponse?> tourExpensesListAPI(
      empId,
      session,
      pageNumber,
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'page_number': (pageNumber),
      };
      final res = await post(data, TourExpensesListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return tourExpensesListResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<tourExpensesDetailsResponse?> tourExpensesDetailAPI(
      session,
      empId,
      tourBillId,
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'tour_bill_id': (tourBillId),
      };
      final res = await post(data, TourExpensesDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return tourExpensesDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<tourExpensesAddViewResponse?> tourExpensesAddViewAPI(
      empId,
      session,
      tourBillId,
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'tour_bill_id': (tourBillId),
      };
      final res = await post(data, TourExpensesAddViewUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return tourExpensesAddViewResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }
  static Future<CommonResponse?> addTourBillAPI({
    required String sessionId,
    required String empId,
    required String placeOfVisit,
    required String daAmount,
    required String tourType,
    required String tourDate,
    required List<Map<String, dynamic>> travelExpenses,
    required List<Map<String, dynamic>> hotelExpenses,
    required List<Map<String, dynamic>> otherExpenses,
    List<File>? travelImages,
    List<File>? hotelImages,
    List<File>? otherImages,
  }) async {
    try {
      var request = http.MultipartRequest("POST", Uri.parse(AddTourExpensesUrl));

      /// Add text fields
      request.fields['session_id'] = sessionId;
      request.fields['emp_id'] = empId;
      request.fields['place_of_visit'] = placeOfVisit;
      request.fields['da_amount'] = daAmount;
      request.fields['tour_type'] = tourType;
      request.fields['tour_date'] = tourDate;

      /// Convert expense lists to JSON string
      request.fields['travel_expenses'] = jsonEncode(travelExpenses);
      request.fields['hotel_expenses'] = jsonEncode(hotelExpenses);
      request.fields['other_expenses'] = jsonEncode(otherExpenses);

      /// Add hotel images
      if (hotelImages!.isNotEmpty) {
        for (var file in hotelImages) {
          if (file.path.isNotEmpty) {
            request.files.add(
              await http.MultipartFile.fromPath(
                "hotel_images[]",
                file.path,
              ),
            );
          }
        }
      }

      /// Add travel images
      if (travelImages!.isNotEmpty) {
        for (var file in travelImages) {
          if (file.path.isNotEmpty) {
            request.files.add(
              await http.MultipartFile.fromPath(
                "travel_images[]",
                file.path,
              ),
            );
          }
        }
      }

      /// Add other images
      if (otherImages!.isNotEmpty) {
        for (var file in otherImages) {
          if (file.path.isNotEmpty) {
            request.files.add(
              await http.MultipartFile.fromPath(
                "other_images[]",
                file.path,
              ),
            );
          }
        }
      }
      /// Send request
      var response = await request.send();
      var resBody = await response.stream.bytesToString();

      debugPrint("Request Fields: ${request.fields}");
      debugPrint("Response: $resBody");

      if (response.statusCode == 200) {
        return CommonResponse.fromJson(jsonDecode(resBody));
      } else {
        debugPrint("Error: ${response.statusCode} - $resBody");
        return null;
      }
    } catch (e) {
      debugPrint("Error in addTourBillAPI: $e");
      return null;
    }
  }




  // Leave Application api
  static Future<leaveApplicationLIstResponse?> leaveApplicationListAPI(
      session,
      empId,
      dateFrom,
      dateTo
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'requested_date_from': (dateFrom),
        'requested_date_to': (dateTo),
      };
      final res = await post(data, LeaveApplicationListUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return leaveApplicationLIstResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }

  static Future<leaveApplicationDetailsResponse?> leaveApplicationDetailAPI(
      session,
      empId,
      leaveRequestId,
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'leave_request_id': (leaveRequestId),
      };
      final res = await post(data, LeaveApplicationDetailsUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return leaveApplicationDetailsResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }
  //add leave request
  static Future<CommonResponse?> leaveRequestAddAPI(
      session,
      empId,
      fromDate,
      fromTime,
      toDate,
      toTime,
      leaveType,
      reason
      ) async {
    try {
      Map<String, String> data = {
        'session_id': (session).toString(),
        'emp_id': (empId).toString(),
        'from_date': (fromDate).toString(),
        'from_time': (fromTime).toString(),
        'to_date': (toDate).toString(),
        'to_time': (toTime).toString(),
        'leave_type': (leaveType).toString(),
        'reason': (reason).toString(),
      };
      final res = await post(data, LeaveRequestAdditionUrl, {});
      if (res != null) {
        print(data);
        debugPrint(res.body);
        return CommonResponse.fromJson(jsonDecode(res.body));
      } else {
        debugPrint("Null Response");
        return null;
      }
    } catch (e) {
      debugPrint('hello bev=bug $e ');
      return null;
    }
  }


  // static Future<CommonResponse?> TpcIssueListApprovalAPI(
  //     empId,
  //     session,
  //     tpc_payment_mode,
  //     tpc_payment_reference_no,
  //     order_id,
  //     order_tpc_feedback,
  //     tpc_paym_attachment
  //     ) async {
  //   try {
  //     Map<String, String> data = {
  //       'emp_id': (empId).toString(),
  //       'session_id': (session).toString(),
  //       'tpc_payment_mode':tpc_payment_mode.toString(),
  //       'tpc_payment_reference_no':tpc_payment_reference_no.toString(),
  //       'order_id':order_id.toString(),
  //       'order_tpc_feedback':order_tpc_feedback.toString(),
  //     };
  //     var res;
  //     if (tpc_paym_attachment != null) {
  //       res = await postImageNew(
  //         data,
  //         {},
  //         ordersApprovePendingTPCIssueListUrl,
  //         tpc_paym_attachment,
  //         "tpc_paym_attachment",
  //       );
  //       res = jsonDecode(res);
  //     } else {
  //       res = await post(data, ordersApprovePendingTPCIssueListUrl, {});
  //       res = jsonDecode(res.body);
  //       return CommonResponse.fromJson(res);
  //     }
  //   } catch (e) {
  //     debugPrint('hello bev=bug $e ');
  //     return null;
  //   }
  // }
}
