

import '../../../../models/AddNewAccountRequestModel.dart';
import '../../../../models/AuthenticationRequest.dart';
import '../../../../models/BeneficiaryAccountModel.dart';
import '../../../../models/ChangePasswordRequest.dart';
import '../../../../models/ChangeTransactionPinRequest.dart';
import '../../../../models/CreateTransactionPinOTPRequest.dart';
import '../../../../models/CreateTransactionPinRequest.dart';
import '../../../../models/GLACCAddMoneyRequestModel.dart';
import '../../../../models/GenerateReportRequestModel.dart';
import '../../../../models/RegisterRequest.dart';
import '../../../../models/SignupOtpRequest.dart';
import '../../../../models/SignupStep3RequestModel.dart';
import '../../../../models/TransactionPinRequestModel.dart';
import '../../../../models/TransactionSubmitRequestModel.dart';
import '../../../../models/VerifyLoginOtpRequest.dart';
import '../../../../models/accept_receive_transaction.dart';
import '../../../../models/chanange_password_params.dart';
import '../../../../models/resen_ot_chanange_trans_pin.dart';
import '../../../../models/resend_ot_login_model.dart';
import '../../../../models/resend_otp_usend.dart';
import '../../../../models/upload_user_profile_model.dart';
import '../../../config/requset_attr.dart';
import '../../../config/server_request.dart';
import '../../../config/server_response.dart';
import '../../../constants/app_contants.dart';
import '../../../constants/url_constants.dart';
import '../../../enums/http_methods.dart';
import '../../../utils/SessionCache.dart';

class AppRemoteDataSource {
  Future<ServerResponse> fetchAccountDetails() {
    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["pctCstycode"] = SessionCache.instance.userInfo.pctCstycode;
    queryParams["cmpCustcode"] = SessionCache.instance.userInfo.cmpCustcode;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_ACCOUNT_DETAILS;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ACCOUNT_DETAILS, HttpMethod.GET, {}, headers, queryParams));
  }

  Future<ServerResponse> sendAddMoneyOtp(TransactionPinRequestModel transactionPinRequestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SEND_TRANSACTION_STEP_1;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SEND_ADD_MONEY_OTP, HttpMethod.POST, transactionPinRequestModel.toMap(), headers));
  }

  Future<ServerResponse> sendTransactionStep1(TransactionPinRequestModel transactionPinRequestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SEND_TRANSACTION_STEP_1;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SEND_TRANSACTION_STEP1, HttpMethod.POST, transactionPinRequestModel.toMap(), headers));
  }

  Future<ServerResponse> sendTransactionStep2(TransactionSubmitRequestModel transactionSubmitRequestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SEND_TRANSACTION_STEP_2;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SEND_TRANSACTION_STEP2, HttpMethod.POST, transactionSubmitRequestModel.toMap(), headers));
  }

  Future<ServerResponse> sendAddMoneyTransaction(GLACCAddMoneyRequestModel transactionSubmitRequestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SEND_TRANSACTION_STEP_2;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SEND_ADD_MONEY_TRANSACTION, HttpMethod.POST, transactionSubmitRequestModel.toMap(), headers));
  }

  Future<ServerResponse> getLoginOTP(AuthenticationRequest requestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.GET_LOGIN_OTP;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.LOGIN, HttpMethod.POST, requestModel.toMap()));
  }

// Future<ServerResponse> reSendOTP(ReSendOTPModel requestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.LOGIN_OTP, HttpMethod.POST, requestModel.toJson()));
// }

  Future<ServerResponse> validateLoginPin(VerifyLoginOtpRequest requestBody) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.VALIDATE_LOGIN_PIN;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.LOGIN_OTP, HttpMethod.POST, requestBody.toMap()));
  }

  ///Fetch Account Transactions
  Future<ServerResponse> fetchDepositAccountTransactions(String accountNumber, String fromDate, String toDate) async {
    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["mbmBkmsnumber"] = accountNumber;
    queryParams["sgtGntrvaluedatefrom"] = fromDate;
    queryParams["sgtGntrvaluedateto"] = toDate;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_DEPOSITE_ACCOUNT_TRANSACTIONS;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ACCOUNT_TRANSACTIONS, HttpMethod.GET, {}, headers, queryParams, {}));
  }


  Future<ServerResponse> addNewBeneficiary(BeneficiaryAccountModel beneficiaryModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.ADD_NEW_BENEFICIARY;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ADD_NEW_BENEIFCIARY, HttpMethod.POST, beneficiaryModel.toMap(), headers));
  }


// Future<ServerResponse> fetchLoanAccountDetails(String accountNumber) async {
//   Map<String, Object> queryParams = {};
//   queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
//   queryParams["mbmBkmsnumber"] = accountNumber;
//
//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.LOAN_ACCOUNT_DETAILS, HttpMethod.GET, {}, headers, queryParams, {}));
// }

// // http: //192.168.1.20:8080/MCONNECT/account/indvdetails?porOrgacode=0004&mbmBkmsnumber=0001325

// Future<ServerResponse> fetchLoanAccountTransactions(String accountNumber) async {
//   Map<String, Object> queryParams = {};
//   queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
//   queryParams["mbmBkmsnumber"] = accountNumber;
//
//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.LOAN_ACCOUNT_TRANSACTIONS, HttpMethod.GET, {}, headers, queryParams, {}));
// }

  /// Fetch User Activity Data
  Future<ServerResponse> fetchUserActivity(String fromDate, String toDate) async {
    Map<String, Object> paramParameters = {};
    paramParameters["organization"] = SessionCache.instance.userInfo.porOrgacode;
    paramParameters["customer"] = SessionCache.instance.userInfo.cmpCustcode;
    // paramParameters["customertype"] = "I";
    paramParameters["fromdate"] = fromDate;
    paramParameters["todate"] = toDate;

    //  "uco/account/activity/organization/{porOrgacode}/customer/{cmpCustcode}/fromdate/{fdate}/todate/{tdate}";
    // /organization/0006/customer/I003120/fromdate/2024-01-01/todate/2024-04-29
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = "Mobile";
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_USER_ACTIVITY;

    return ServerRequest.request(RequestAttr.withParamsAndBody(buildPathParameters(UrlContants.FETCH_USER_ACTIVITY, paramParameters), HttpMethod.GET, {}, headers, {}, {}));
  }


  /// Method for handling Parameter
  String buildPathParameters(String basePath, Map<String, Object> parameters) {
    parameters.forEach((key, value) {
      basePath += "/$key/$value";
    });
    return basePath;
  }


// Future<ServerResponse> generatePinForBeneficiaryAccount(BeneficiaryPinRequestModel beneficiaryPinRequestModel) {
//   Map<String, Object> paramParameters = {};
//   paramParameters["channel"] = SessionCache.instance.userInfo.channelCode;

//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//   headers["Devicename"] = "Mobile";
//   return ServerRequest.request(RequestAttr.withParamsAndBody(buildPathParameters(UrlContants.BENEFICIARY_PIN, paramParameters), HttpMethod.POST, beneficiaryPinRequestModel.toMap(), headers));
// }

  Future<ServerResponse> fetchExchangeRate() {
    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_EXCHANGE_RATE;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.EXCHANGE_RATE, HttpMethod.GET, {}, headers, queryParams));
  }

  Future<ServerResponse> fetchAccountInquiry(String type, String value) {
    Map<String, Object> queryParams = {};
    queryParams["acntTypeCode"] = type;
    queryParams["acntTypeValue"] = value;
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["channelCode"] = SessionCache.instance.userInfo.channelCode;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_ACCOUNT_IQUIRY;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ACCOUNT_INQUIRY, HttpMethod.GET, {}, headers, queryParams));
  }



  Future<ServerResponse> createTransactionPinOTP(CreateTransactionPinOTPRequest requestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.CREATE_TRANSACTION_PIN;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.CREATE_TRANSACTION_PIN_OTP, HttpMethod.POST, requestModel.toMap(), headers));
  }


  Future<ServerResponse> createTransactionPin(CreateTransactionPinRequest requestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.CREATE_TRANSACTION_PIN;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.CREATE_TRANSACTION_PIN, HttpMethod.POST, requestModel.toMap(), headers));
  }

  Future<ServerResponse> changeTransactionPin(ChangeTransactionPinRequest requestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.CHANGE_TRANSACTION_PIN;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.CHANGE_TRANSACTION_PIN, HttpMethod.PUT, requestModel.toMap(), headers));
  }


  Future<ServerResponse> generateReports(GenerateReportRequestModel requestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.GENERATE_REPORTS;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.GENERATE_REPORTS, HttpMethod.POST, requestModel.toMap(), headers));
  }

  Future<ServerResponse> fetchGlsAllAccounts() {
    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["glsTransaction"] = AppConstants.FETCH_GLS_ACCOUNTS;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FETCH_GLS_ACCOUNTS, HttpMethod.GET, {}, headers, queryParams));
  }

  Future<ServerResponse> uploadUserProfilePicture(UploadUserProfileModel uploadUserProfileModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.UPLOAD_USER_PROFILE_PICTURE;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.UPLOAD_USER_PROFILE_PICTURE, HttpMethod.POST, uploadUserProfileModel.toMap(), headers));
  }

// Future<ServerResponse> deleteBeneficiary(String accountNumber) {
//   Map<String, Object> paramParameters = {};
//   paramParameters["organization"] = SessionCache.instance.userInfo.porOrgacode;
//   paramParameters["customer"] = SessionCache.instance.userInfo.cmpCustcode;
//   paramParameters["customertype"] = "I";
//   paramParameters["account"] = accountNumber;
//
//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//   headers["Devicename"] = "Mobile";
//   return ServerRequest.request(RequestAttr.withParamsAndBody(buildPathParameters(UrlContants.DELETE_BENEFICIARYT, paramParameters), HttpMethod.DELETE, {}, headers, {}, {}));
// }

// ------------------ Forget password ----------------

// Future<ServerResponse> forgetPasswordStep1(ForgetPasswordStep1RequestModel forgetPasswordStep1RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FORGET_PASSWORD_STEP_1, HttpMethod.POST, forgetPasswordStep1RequestModel.toMap(), {}));
// }

// Future<ServerResponse> forgetPasswordStep2(ForgetPasswordStep2RequestModel forgetPasswordStep2RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FORGET_PASSWORD_STEP_2, HttpMethod.POST, forgetPasswordStep2RequestModel.toMap(), {}));
// }

// Future<ServerResponse> forgetPasswordStep3(ForgetPasswordStep3RequestModel forgetPasswordStep3RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FORGET_PASSWORD_STEP_3, HttpMethod.POST, forgetPasswordStep3RequestModel.toMap(), {}));
// }

// Future<ServerResponse> forgetPasswordStep4(ForgetPasswordStep4RequestModel forgetPasswordStep4RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FORGET_PASSWORD_STEP_4, HttpMethod.POST, forgetPasswordStep4RequestModel.toMap(), {}));
// }

// sign up process
  Future<ServerResponse> signupStep1(RegisterRequest registerRequest) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SIGNUP_STEP_1;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_1, HttpMethod.POST, registerRequest.toMap(), {}));
  }

  Future<ServerResponse> signupStep2(SignupOtpRequest signupOtpRequest) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SIGUP_STEP_2;
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_2, HttpMethod.POST, signupOtpRequest.toMap(), {}));
  }


  Future<ServerResponse> signupStep3(SignupStep3RequestModel signupStep3RequestModel) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.SIGUP_STEP_3;

    var header = {'Content-Type': 'application/json'};
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_3, HttpMethod.POST, signupStep3RequestModel.toMap(), headers));
  }


// Future<ServerResponse> signupStep4(SignUpStep4RequestModel signUpStep4RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_4, HttpMethod.POST, signUpStep4RequestModel.toMap(), {}));
// }

// Future<ServerResponse> signupStep4ResendOtp(SignUpStep4ResendOtpRequestModel signUpStep4ResendOtpRequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_4_RESEND_OTP, HttpMethod.POST, signUpStep4ResendOtpRequestModel.toMap(), {}));
// }

// Future<ServerResponse> signupStep5(SignUpStep5RequestModel signUpStep5RequestModel) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SIGNUP_STEP_5, HttpMethod.POST, signUpStep5RequestModel.toMap(), {}));
// }

  Future<ServerResponse> changePasswordSendOTP(ChangePasswordRequest changePasswordRequest) {
    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.CHANGE_PASSWORD_SEND_OTP;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.CHANGE_PASSWORD_SEND_OTP, HttpMethod.POST, changePasswordRequest.toMap(), headers));
  }

  Future<ServerResponse> changePassword(ChangePasswordParams changePasswordParams) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.CHANGE_PASSWORD;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.CHANGE_PASSWORD_SEND_OTP, HttpMethod.PATCH, changePasswordParams.toJson(), headers));
  }

  Future<ServerResponse> getPendingTransition(String accountNumber) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.GET_PENDING_TRANSITION;

    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["mbmBkmsnumber"] = accountNumber;

    return ServerRequest.request(RequestAttr.withHeaderAndParams(UrlContants.fetchPendingCredittransaction, HttpMethod.GET, headers, queryParams));
  }


  Future<ServerResponse> acceptReceiveTransition(AcceptReceiveTransactionModel requestModel) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.ACCEPT_RECEIVE_TRANSACTION;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ACCEPT_RECEIVE_TRANSACTION, HttpMethod.POST, requestModel.toMap(), headers));
  }

  Future<ServerResponse> reverseTransition(String nodeId, String sgtGntrnumber) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.REVERSE_TRANSACTION;

    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["nodeId"] = nodeId;
    queryParams["sgtGntrnumber"] = sgtGntrnumber;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.REVERSE_TRANSACTION, HttpMethod.POST, {},headers, queryParams));
  }

  Future<ServerResponse> fetchAccountStatement(String accountNumber) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_ACCOUNT_STATEMENT;

    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["mbmBkmsnumber"] = accountNumber;

    return ServerRequest.request(RequestAttr.withHeaderAndParams(UrlContants.FETCH_ACCOUNT_STATEMENT, HttpMethod.GET, headers, queryParams));
  }

  Future<ServerResponse> getCurrencyList() {
    Map<String, Object> queryParams = {};

    queryParams["porOrgacode"] = "1962";

    return ServerRequest.request(
      RequestAttr.withHeaderAndParams(UrlContants.fetchUcoDepositProducts, HttpMethod.GET, {}, queryParams),
    );
  }

  Future<ServerResponse> getConvertedCurrency(String baseCurrency, String targetCurrency, String sgtGntramtfc) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_ACCOUNT_STATEMENT;

    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["baseCurrency"] =  baseCurrency;
    queryParams["targetCurrency"] = targetCurrency;
    queryParams["sgtGntramtfc"] = sgtGntramtfc;

    return ServerRequest.request(RequestAttr.withHeaderAndParams(UrlContants.evaluateCurrency, HttpMethod.GET, headers, queryParams));
  }

  Future<ServerResponse> addNewAccount(AddNewAccountRequestModel addNewAccountModel) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["addNewAccount"] = AppConstants.ADD_NEW_ACCOUNT;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.ADD_NEW_ACCOUNT, HttpMethod.POST, addNewAccountModel.toMap(), headers));
  }

  Future<ServerResponse> resentOtpLoginSignUp(ResendOtpLoginModel model) {
    Map<String, Object> headers = {};
    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.resendOtp, HttpMethod.POST, model.toMap(), headers));
  }

  Future<ServerResponse> resendOtpUsend(ResendOtpUsendModel model) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.resendOtpUSend, HttpMethod.POST, model.toMap(), headers));
  }

  Future<ServerResponse> resendOtpTransPin(
    ResendOtpChangeTransPin resendOtpChangeTransPin,
  ) {

    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.resendTransOtp, HttpMethod.PUT, resendOtpChangeTransPin.toMap(), headers));
  }

  Future<ServerResponse> createPinResndOtp(CreateTransactionPinOTPRequest createTransactionPinRequest) {
    Map<String, Object> headers = {};

    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";

    return ServerRequest.request(RequestAttr.withParamsAndBody(
      UrlContants.createPinOtp,
      HttpMethod.PUT,
      createTransactionPinRequest.toMap(),
      headers,
    ));
  }

  Future<ServerResponse> fetchAllBeneficiary(String porOrgacode, String email) {
    Map<String, Object> queryParams = {};
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    queryParams["email"] = SessionCache.instance.userInfo.cmpUserId;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.FETCH_ALL_BENEFICIARY;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FETCH_ALL_BENEFICIARY, HttpMethod.GET, {}, headers, queryParams));
  }

  Future<ServerResponse> deleteBeneficiary(String mbmBkmsnumberRef, String email, String porOrgacode) {
    Map<String, Object> queryParams = {};
    queryParams["mbmBkmsnumberRef"] = mbmBkmsnumberRef;
    queryParams["email"] = SessionCache.instance.userInfo.cmpUserId;
    queryParams["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;

    Map<String, Object> headers = {};
    headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
    headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
    headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
    headers["Devicename"] = AppConstants.DEVICE_NAME;
    headers["porOrgacode"] = SessionCache.instance.userInfo.porOrgacode;
    headers["email"] = SessionCache.instance.userInfo.cmpUserId;
    headers["channalCode"] = SessionCache.instance.userInfo.channelCode;
    headers["userActivity"] = AppConstants.DELETE_BENEFICIARY;

    return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.DELETE_BENEFICIARY, HttpMethod.DELETE, {}, headers, queryParams));
  }

// Future<ServerResponse> loginResendOtp(LoginResendOtpRequestModel request) {
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.RESEND_OTP, HttpMethod.POST, request.toMap(), {}));
// }

// Future<ServerResponse> fetchPaymentPurposes() {
//   Map<String, Object> queryParams = {};
//
//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//   headers["Devicename"] = "Mobile";
//
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.FETCH_PAYMENT_PURPOSE, HttpMethod.GET, {}, headers, queryParams));
// }

// Future<ServerResponse> sendFeedBack(SendFeedBackRequestModel sendFeedBackRequestModel) {
//   Map<String, Object> headers = {};
//   headers["Authorization"] = "Bearer ${SessionCache.instance.userInfo.jwtToken}";
//   headers["Channelcode"] = SessionCache.instance.userInfo.channelCode;
//   headers["Cmpuserid"] = SessionCache.instance.userInfo.cmpUserId;
//   headers["Devicename"] = "Mobile";
//   return ServerRequest.request(RequestAttr.withParamsAndBody(UrlContants.SEND_FEED_BACK, HttpMethod.POST, sendFeedBackRequestModel.toMap(), headers));
// }

}
