diff --git a/GME Remit/Modules/RegisterModules/UserAuthentication/KYCVerifyStep1/User Interface/View/KYCVerifyStep1ViewController.swift b/GME Remit/Modules/RegisterModules/UserAuthentication/KYCVerifyStep1/User Interface/View/KYCVerifyStep1ViewController.swift index c89886e6..229018b2 100644 --- a/GME Remit/Modules/RegisterModules/UserAuthentication/KYCVerifyStep1/User Interface/View/KYCVerifyStep1ViewController.swift +++ b/GME Remit/Modules/RegisterModules/UserAuthentication/KYCVerifyStep1/User Interface/View/KYCVerifyStep1ViewController.swift @@ -179,7 +179,6 @@ class KYCVerifyStep1ViewController: UIViewController { } @IBAction func checkButtonTapped(_ sender: UIButton) { - print(isSelected) if isSelected == true { self.checkButton.setImage(UIImage(named: "uncheck"), for: .normal) isSelected = false diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractor.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractor.swift index d477d922..fe542eb8 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractor.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractor.swift @@ -27,11 +27,14 @@ class CDDIViewControllerInteractor { // MARK: CDDIViewController interactor input interface extension CDDIViewControllerInteractor: CDDIViewControllerInteractorInput { - func makeApiRequest() { - self.service.makeApiRequest(success: { (message) in - self.output?.success(message: message ?? "") - }) { (error) in - self.output?.show(error: error) - } + func fetchInformation() { + service.fetchKycInfo( + success: {[weak self] in + self?.output?.setModel(with: $0) + }, + failure: {[weak self] in + self?.output?.setError(with: $0) + } + ) } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractorIO.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractorIO.swift index 16353fff..f53e2a94 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractorIO.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Interactor/CDDIViewControllerInteractorIO.swift @@ -7,10 +7,12 @@ // protocol CDDIViewControllerInteractorInput: class { - func makeApiRequest() + func fetchInformation() } protocol CDDIViewControllerInteractorOutput: class { func show(error: Error) func success(message: String) + func setModel(with model: KYCInfoModel) + func setError(with error: Error) } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerService.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerService.swift index f12712d7..8472f725 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerService.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerService.swift @@ -9,23 +9,14 @@ import Foundation class CDDIViewControllerService: CDDIViewControllerServiceType { - func makeApiRequest( - success: @escaping (String?) -> Void, - failure: @escaping (Error) -> Void - ){ -// APIRouter -//// .requestOTP(mobileNumber: mobile) -// .request( -// needsAuthorization: false, -// success: {(response: ResponseMessage) in -// if (response.errorCode ?? "") == "1" { -// let error = NSError(domain: "Network", code: 0, message: response.message ?? "") -// failure(error) -// } else { -// success(response.message ?? "") -// } -// }, -// failure: {failure($0)} -// ) - } + func fetchKycInfo( + success: @escaping (KYCInfoModel) -> Void, + failure: @escaping (Error) -> Void + ) { + APIRouter.loadKYCInformation.json( + needsAuthorization: false, + success: success, + failure: failure + ) + } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerServiceType.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerServiceType.swift index 671f892d..aab7996c 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerServiceType.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Application Logic/Service/CDDIViewControllerServiceType.swift @@ -9,8 +9,8 @@ import Foundation protocol CDDIViewControllerServiceType: class { - func makeApiRequest( - success: @escaping (String?) -> Void, + func fetchKycInfo( + success: @escaping (KYCInfoModel) -> Void, failure: @escaping (Error) -> Void ) } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Module Interface/CDDIViewControllerModuleInterface.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Module Interface/CDDIViewControllerModuleInterface.swift index 1a3fa431..2cb2bf95 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Module Interface/CDDIViewControllerModuleInterface.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/Module Interface/CDDIViewControllerModuleInterface.swift @@ -7,5 +7,5 @@ // protocol CDDIViewControllerModuleInterface: class { - func makeApiRequest() + } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/Presenter/CDDIViewControllerPresenter.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/Presenter/CDDIViewControllerPresenter.swift index 883d37d9..d277a10b 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/Presenter/CDDIViewControllerPresenter.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/Presenter/CDDIViewControllerPresenter.swift @@ -7,8 +7,10 @@ // import Foundation +import RxSwift +import RxCocoa -class CDDIViewControllerPresenter { +class CDDIViewControllerPresenter: ViewModelType { // MARK: Properties @@ -17,20 +19,61 @@ class CDDIViewControllerPresenter { var wireframe: CDDIViewControllerWireframeInput? // MARK: Converting entities + + func fetchInformation() { + self.view?.showLoading() + self.interactor?.fetchInformation() + } + + struct Input { + let sourceOfFund: Driver + let purpose: Driver + let submit: Driver + } + + struct Output { + let isError: Driver + let isProgress: Driver + let purposes: Driver<[KeyValue]?> + let sourceOfFund: Driver<[KeyValue]?> + } + + private let disposeBag = DisposeBag() + private let errorLinker = PublishSubject() + private let progressLinker = PublishSubject() + private let model = PublishSubject() + + func transform(input: Input) -> Output { + + return Output( + isError: errorLinker.asDriverOnErrorJustComplete(), + isProgress: progressLinker.asDriverOnErrorJustComplete(), + purposes: model.map {$0.purpose}.asDriverOnErrorJustComplete(), + sourceOfFund: model.map {$0.sourceOfFund}.asDriverOnErrorJustComplete() + ) + } + } // MARK: CDDIViewController module interface extension CDDIViewControllerPresenter: CDDIViewControllerModuleInterface { - func makeApiRequest(){ - self.view?.showLoading() - self.interactor?.makeApiRequest() - } + } // MARK: CDDIViewController interactor output interface extension CDDIViewControllerPresenter: CDDIViewControllerInteractorOutput { + func setModel(with model: KYCInfoModel) { + progressLinker.onNext(false) + self.model.onNext(model) + } + + func setError(with error: Error) { + progressLinker.onNext(false) + errorLinker.onNext(error) + } + func show(error: Error) { self.view?.hideLoading() self.view?.show(error: error.localizedDescription) diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewController.storyboard b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewController.storyboard index ed5f32da..7380a9fe 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewController.storyboard +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewController.storyboard @@ -1,9 +1,9 @@ - + - + @@ -17,7 +17,7 @@ - + @@ -55,14 +55,14 @@ - + - + - + + + + diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift index 2a93d383..32e76099 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/CDDIViewController/User Interface/View/CDDIViewControllerViewController.swift @@ -7,20 +7,25 @@ // import UIKit +import RxSwift +import RxCocoa class CDDIViewControllerViewController: UIViewController { // MARK: Properties - var presenter: CDDIViewControllerModuleInterface? + var presenter: CDDIViewControllerPresenter! var reciepient: Recipient? var requestModel: SendMoneyRequestModel? weak var hudDelegate: HUDStatusDelegate? weak var actionDelegate: SendMoneyExchangeRateActionDelegate? + var exchangeRateModel: SendMoneyExchangeRateModel? + private let disposeBag = DisposeBag() // MARK: IBOutlets @IBOutlet weak var purposeOfRemit: ValidationTextField! @IBOutlet weak var sourceOfFund: ValidationTextField! + @IBOutlet weak var continueButton: UIButton! // MARK: VC's Life cycle @@ -29,26 +34,94 @@ class CDDIViewControllerViewController: UIViewController { self.setup() } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(true) + self.presenter.fetchInformation() + } + // MARK: IBActions @IBAction func continueButton(_ sender: UIButton) { + view.endEditing(true) actionDelegate?.continueToVerificationAction() } // MARK: Other Functions private func setup() { - // all setup should be done here + self.continueButton.layer.cornerRadius = 12 + sourceOfFund.useAsDropDown(items: nil) + sourceOfFund.validCondition = {!$0.isEmpty} + purposeOfRemit.useAsDropDown(items: nil) + purposeOfRemit.validCondition = {!$0.isEmpty} + setBinding() + } + + private func setBinding() { + let isValidInfo = Observable.combineLatest( + [ + sourceOfFund.valid, + purposeOfRemit.valid + ] + ).map { $0.allSatisfy { $0 } } + .distinctUntilChanged() + + + let input = CDDIViewControllerPresenter.Input( + sourceOfFund: sourceOfFund.selectedItem.map { + if $0?.cellTitle == "Others (please specify)" { + DispatchQueue.main.async { + let alert = UIAlertController(title: "specifySourceOfFund_text".localized(), message: "", preferredStyle: .alert) + alert.addTextField(configurationHandler: nil) + alert.addAction(UIAlertAction(title: "Submit", style: .default, handler: { [weak alert] (_) in + guard let textField = alert?.textFields?.first else { return } + let setSourceOfFund = KeyValue(id: textField.text ?? "", value: textField.text ?? "") + self.sourceOfFund.didSelect( + item: setSourceOfFund + ) + })) + self.present(alert, animated: true, completion: nil) + } + } + return $0 as? KeyValue + + }.asDriverOnErrorJustComplete(), + purpose: purposeOfRemit.selectedItem.map{$0 as? KeyValue}.asDriverOnErrorJustComplete(), + submit: continueButton.rx.tap.asDriverOnErrorJustComplete() + ) + + let output = presenter.transform(input: input) + + output.isError + .drive( + onNext: { self.alert(type: .error, message: $0.localizedDescription) } + ).disposed(by: disposeBag) + + output.isProgress + .drive( + onNext: { $0 ? self.showProgressHud() : self.hideProgressHud() } + ).disposed(by: disposeBag) + + output.purposes.drive(onNext: {[weak self] in + let configure = TablePresenterConfiguration(presenterTitle: "select_purpose_of_registration_text".localized()) + self?.purposeOfRemit.useAsDropDown(with: configure, items: $0) + }).disposed(by: disposeBag) + + output.sourceOfFund.drive(onNext: {[weak self] in + let configure = TablePresenterConfiguration(presenterTitle: "select_source_of_fund_text".localized()) + self?.sourceOfFund.useAsDropDown(with: configure, items: $0) + }).disposed(by: disposeBag) } + } // MARK: CDDIViewControllerViewInterface extension CDDIViewControllerViewController: CDDIViewControllerViewInterface { func showLoading() { - self.showProgressHud() + hudDelegate?.showLoading() } func hideLoading() { - self.hideProgressHud() + hudDelegate?.hideLoading() } func show(error: String) { diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift index 9ebabb6c..9b72e703 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift @@ -203,7 +203,6 @@ class SendMoneyExchangeRateViewController: UIViewController { calculate() case .continue: goToCDDI() - //goToVerification() } } } @@ -393,17 +392,6 @@ class SendMoneyExchangeRateViewController: UIViewController { actionDelegate?.continueToCDDI() } -// private func goToVerification() { -// exchangeRateModel?.calcBy = calcBy -// exchangeRateModel?.reciepientCurrency = selectedCurrencyViewModel?.currency ?? "" -// exchangeRateModel?.autodebitSendingAmount = getPlainNumbers(number: senderTextField.text!) -// -// -// actionDelegate?.calculated(model: exchangeRateModel) -// actionDelegate?.continueToVerificationAction() -// } - - private func getPlainNumbers(number: String) -> String { return number.stringRemovingComma() } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift index 51c7117d..ee5b80c0 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyParent/User Interface/View/SendMoneyParentViewController.swift @@ -145,10 +145,12 @@ class SendMoneyParentViewController: UIViewController { } @IBAction func cddiTapped(_ sender: UIButton) { + self.addCddiViewController() self.state = StateButtons.cddi } @IBAction func termsAndConditions(_ sender: UIButton) { + self.addTermsAndConditions() self.state = StateButtons.terms } // MARK: Other Functions @@ -350,6 +352,8 @@ class SendMoneyParentViewController: UIViewController { private func addCddiViewController() { guard let ccdiView = cddiViewController else {return} + ccdiView.requestModel = self.requestModel + ccdiView.actionDelegate = self self.addChild(ccdiView) @@ -375,6 +379,7 @@ class SendMoneyParentViewController: UIViewController { verificationViewController.reciepient = self.receipient verificationViewController.requestModel = self.requestModel + verificationViewController.actionDelegate = self self.addChild(verificationViewController) @@ -395,6 +400,8 @@ class SendMoneyParentViewController: UIViewController { private func addTermsAndConditions() { guard let termsView = termsViewController else {return} + termsView.reciepient = self.receipient + termsView.requestModel = self.requestModel self.addChild(termsView) diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift index 47786c99..fd53e69c 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift @@ -77,7 +77,7 @@ class SendMoneyVerificationViewController: UITableViewController { var reciepient: Recipient? var requestModel: SendMoneyRequestModel? weak var hudDelegate: HUDStatusDelegate? - + weak var actionDelegate: SendMoneyExchangeRateActionDelegate? lazy var pinViewOption: Options = { var options = Options() options.image = UIImage(named: "app logo") @@ -145,7 +145,8 @@ class SendMoneyVerificationViewController: UITableViewController { } @IBAction func submit(_ sender: UIButton) { - self.askPassword() + // self.askPassword() + actionDelegate?.continueToTermsAndConditions() } // MARK: Other Functions @@ -218,7 +219,7 @@ class SendMoneyVerificationViewController: UITableViewController { // biometricAuthenticationWireframe.openWithDelegate(on: self, delegate: self) // } else { // showSecureKeypad() - // } + // showSecureKeypad() } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractor.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractor.swift index ed19e8d3..7384e593 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractor.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractor.swift @@ -27,6 +27,45 @@ class TermsAndConditionInteractor { // MARK: TermsAndCondition interactor input interface extension TermsAndConditionInteractor: TermsAndConditionInteractorInput { + func submit(model: SendMoneyRequestModel, reciepient: Recipient) { + let params = self.getParams(model: model, reciepient: reciepient) + self.service.submit( + params: params, + success: { (response) in + + // UPDATE BALANCE + let balance = response?.data?.extra ?? "" + let userInfo = [SideMenuNavigationNotifications.availableBalance : balance] + + GMEDB.shared.user.set(balance, .availableBalance) + NotificationCenter.default.post( + name: self.getAvailableBalanceNotificationName(), + object: nil, + userInfo: userInfo + ) + + // UPDATE YEARLY LIMIT + let limit = response?.data?.remainingLimit ?? "" + let userInfo2 = [AppConstants.yearlyLimitNotification : limit] + NotificationCenter.default.post( + name: self.getAvailableBalanceNotificationName(), + object: nil, + userInfo: userInfo + ) + + NotificationCenter.default.post( + name: self.getYearlyLimitNotificationName(), + object: userInfo2 + ) + + // SHOW + self.output?.show(model: response) + }, + failure: { (error) in + self.output?.show(error: error) + }) + } + func makeApiRequest() { self.service.makeApiRequest(success: { (message) in self.output?.success(message: message ?? "") @@ -34,4 +73,49 @@ extension TermsAndConditionInteractor: TermsAndConditionInteractorInput { self.output?.show(error: error) } } + + func getParams(model: SendMoneyRequestModel, reciepient: Recipient) -> [String: Any] { + guard let username = GMEDB.shared.user.string(.userId) else {return [:]} + let senderId = GMEDB.shared.user.string(.senderId) + let recieverId = reciepient.receiverID + + let params: [String: Any] = + [ + "User": username, + "SenderId": senderId ?? "", + "ReceiverId": recieverId ?? "", + "DeliveryMethodId": model.paymemtMode?.id ?? "", + "PBranch": model.branch?.id ?? "", + // "PAgent": model.bank?.id ?? "", + "PaymentType": "wallet", + "PCurr": model.exchangeRateDetail?.reciepientCurrency ?? "", + "CollCurr": "JPY", + "CollAmt": model.exchangeRateDetail?.senderAmount ?? "", + "PayoutAmt": model.exchangeRateDetail?.recipientAmount ?? "", + "TransferAmt": model.exchangeRateDetail?.transferAmount ?? "", + "ServiceCharge": model.exchangeRateDetail?.transferFee ?? "", + "Discount": model.exchangeRateDetail?.discountPercent ?? "", + "ExRate": model.exchangeRateDetail?.apiExchangeRate ?? "", + "CalBy": model.exchangeRateDetail?.calcBy ?? "", + "FOREX_SESSION_ID": model.exchangeRateDetail?.forexId ?? "", + "PurposeOfRemittance": reciepient.purposeOfRemitID ?? "others", + "SourceOfFund": "3902", + "RelWithSender": reciepient.relationshipID ?? "", + "Occupation": "", + "IpAddress": "", + "RState": "", + "RLocation": "", + "TpExRate": "", + "TpPCurr": "", + "PayOutPartner": "394402", + "IsAgreed": "TRUE", + "TxnPassword": model.transactionPassword ?? "", + "ReceiverAccountNo": model.paymemtMode?.accountNumber ?? "", + "ProcessId": "", + // "schemeId": "", + "isUseBiometric": model.isUseBiometric ?? false + ] + + return params + } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractorIO.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractorIO.swift index 6efaca04..517b4b78 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractorIO.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Interactor/TermsAndConditionInteractorIO.swift @@ -8,9 +8,11 @@ protocol TermsAndConditionInteractorInput: class { func makeApiRequest() + func submit(model: SendMoneyRequestModel, reciepient: Recipient) } protocol TermsAndConditionInteractorOutput: class { func show(error: Error) func success(message: String) + func show(model: SendMoneySubmitModelContainer?) } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Service/TermsAndConditionServiceType.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Service/TermsAndConditionServiceType.swift index f46d78b5..a8e86fd6 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Service/TermsAndConditionServiceType.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Application Logic/Service/TermsAndConditionServiceType.swift @@ -8,9 +8,51 @@ import Foundation -protocol TermsAndConditionServiceType: class { +protocol TermsAndConditionServiceType: class, TermsAndConditionsApi { func makeApiRequest( success: @escaping (String?) -> Void, failure: @escaping (Error) -> Void ) + + +} + +protocol TermsAndConditionsApi: ApiServiceType { + func submit( + params: [String: Any], + success: @escaping (SendMoneySubmitModelContainer?) -> Void, + failure: @escaping (Error) -> Void + ) +} + +extension TermsAndConditionsApi { + func submit( + params: [String: Any], + success: @escaping (SendMoneySubmitModelContainer?) -> Void, + failure: @escaping (Error) -> Void + ) { + let url = baseUrl + "/mobile/sendmoney/dotransaction" + self.auth.request( + method: .post, + url: url, + params: params, + success: { (response: SendMoneySubmitModelContainer) in + if (response.errorCode ?? "") == "1" { + let error = NSError( + domain: "Network", + code: 0, + userInfo: [NSLocalizedDescriptionKey : response.message ?? ""] + ) + + failure(error) + } else { + let model = response + success(model) + } + }, + failure: { (error) in + failure(error) + } + ) + } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Module Interface/TermsAndConditionModuleInterface.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Module Interface/TermsAndConditionModuleInterface.swift index c97b0cb1..cb0358ca 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Module Interface/TermsAndConditionModuleInterface.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/Module Interface/TermsAndConditionModuleInterface.swift @@ -8,4 +8,6 @@ protocol TermsAndConditionModuleInterface: class { func makeApiRequest() + func submit(model: SendMoneyRequestModel, reciepient: Recipient) + func openReciept(transactionId: String) } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Presenter/TermsAndConditionPresenter.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Presenter/TermsAndConditionPresenter.swift index e17abcc4..f3c4ebe1 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Presenter/TermsAndConditionPresenter.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Presenter/TermsAndConditionPresenter.swift @@ -26,6 +26,15 @@ extension TermsAndConditionPresenter: TermsAndConditionModuleInterface { self.view?.showLoading() self.interactor?.makeApiRequest() } + + func submit(model: SendMoneyRequestModel, reciepient: Recipient) { + self.view?.showLoading() + self.interactor?.submit(model: model, reciepient: reciepient) + } + + func openReciept(transactionId: String) { + self.wireframe?.openReciept(transactionId: transactionId) + } } // MARK: TermsAndCondition interactor output interface @@ -40,4 +49,9 @@ extension TermsAndConditionPresenter: TermsAndConditionInteractorOutput { self.view?.hideLoading() self.view?.show(message: message) } + + func show(model: SendMoneySubmitModelContainer?) { + self.view?.hideLoading() + self.view?.show(model: model) + } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndCondition.storyboard b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndCondition.storyboard index f8a2573c..f830e8a8 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndCondition.storyboard +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndCondition.storyboard @@ -1,9 +1,9 @@ - + - + @@ -35,6 +35,9 @@ + + + - + @@ -67,18 +73,23 @@ - + - + + + + + + diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndConditionViewController.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndConditionViewController.swift index 3ef38171..af4e5d59 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndConditionViewController.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/View/TermsAndConditionViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import WebKit class TermsAndConditionViewController: UIViewController { @@ -16,23 +17,92 @@ class TermsAndConditionViewController: UIViewController { var reciepient: Recipient? var requestModel: SendMoneyRequestModel? weak var hudDelegate: HUDStatusDelegate? + private var isSelected = false + lazy var pinViewOption: Options = { + var options = Options() + options.image = UIImage(named: "app logo") + options.title = "enter_your_transaction_pin_text".localized() + options.pinColor = #colorLiteral(red: 0.93, green: 0.11, blue: 0.14, alpha: 1) + return options + }() + + var password: String? { + didSet { + guard + let model = self.requestModel, + let reciepient = self.reciepient, + let password = self.password, + password != "" + else { + return + } + model.transactionPassword = password + print(password) + self.presenter?.submit(model: model, reciepient: reciepient) + } + } // MARK: IBOutlets + @IBOutlet weak var continueButton: UIButton! + @IBOutlet weak var webView: WKWebView! + @IBOutlet weak var agreementButton: UIButton! // MARK: VC's Life cycle override func viewDidLoad() { super.viewDidLoad() + let url = URL(string: "http://211.25.249.199:9093/Document/TermsAndConditions/Trx_TermsAndConditions.html")! + self.webView.load(URLRequest(url: url)) + self.webView.scrollView.bounces = false self.setup() } // MARK: IBActions + @IBAction func agreementClicked(_ sender: UIButton) { + if isSelected == true { + self.agreementButton.setImage(UIImage(named: "uncheck"), for: .normal) + isSelected = false + self.continueButton.isUserInteractionEnabled = false + self.continueButton.backgroundColor = .themeText + } else if isSelected == false { + self.agreementButton.setImage(UIImage(named: "checked"), for: .normal) + isSelected = true + self.continueButton.isUserInteractionEnabled = true + self.continueButton.backgroundColor = .themeRed + } + } + @IBAction func continueClicked(_ sender: UIButton) { + if isSelected == true { + askPassword() + } + } // MARK: Other Functions private func setup() { // all setup should be done here } + + func askPassword() { + // if let isUseBiometric = KeyChain.shared.get(key: .biometricAuth), isUseBiometric == "1" { + // let biometricAuthenticationWireframe = BiometricAuthenticationWireframe() + // biometricAuthenticationWireframe.openWithDelegate(on: self, delegate: self) + // } else { + // showSecureKeypad() + // } + + showSecureKeypad() + } + + func showSecureKeypad() { + + PINKeyboardView.present(config: self.pinViewOption, over: self, pinEntered: {pin,ok in + if pin.count == 6 && ok == true { + self.password = pin + } + },presented:nil) + + } } // MARK: TermsAndConditionViewInterface diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframe.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframe.swift index 3b8678e0..18ae2d5c 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframe.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframe.swift @@ -10,6 +10,10 @@ import UIKit class TermsAndConditionWireframe { weak var view: UIViewController! + var reciepient: Recipient? + var model: SendMoneyRequestModel? + + private lazy var reciptWireframe = SendMoneyReceiptWireframe() } extension TermsAndConditionWireframe: TermsAndConditionWireframeInput { @@ -31,4 +35,10 @@ extension TermsAndConditionWireframe: TermsAndConditionWireframeInput { self.view = viewController return viewController } + + func openReciept(transactionId: String) { + if let navigation = self.view.navigationController { + reciptWireframe.openReciept(transactionId: transactionId, source: navigation) + } + } } diff --git a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframeInput.swift b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframeInput.swift index f9fb9a5b..210b300d 100644 --- a/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframeInput.swift +++ b/GME Remit/Modules/RemittanceModules/OverseasModules/TermsAndCondition/User Interface/Wireframe/TermsAndConditionWireframeInput.swift @@ -9,5 +9,5 @@ import Foundation protocol TermsAndConditionWireframeInput: WireframeInput { - + func openReciept(transactionId: String) }