From bb1d22eab10e616249c6d07c09ad03d65dce5acf Mon Sep 17 00:00:00 2001 From: gme_2 Date: Tue, 26 Mar 2019 16:41:48 +0900 Subject: [PATCH] amont send in request otp --- GMERemittance/Extension/StringExtension.swift | 4 ++++ GMERemittance/Model/SendMoneyExchangeRate.swift | 1 + .../View/SendMoneyExchangeRateViewController.swift | 6 ++++++ .../View/SendMoneyVerificationViewController.swift | 2 +- .../Interactor/SendMoneyCodeInteractor.swift | 11 +++++++++-- .../Service/SendMoneyCodeServiceType.swift | 8 ++++---- .../Wireframe/SendMoneyCodeWireframe.swift | 6 ++++-- GMERemittance/UrlManager.swift | 2 +- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/GMERemittance/Extension/StringExtension.swift b/GMERemittance/Extension/StringExtension.swift index b45f22cf..622aa8be 100644 --- a/GMERemittance/Extension/StringExtension.swift +++ b/GMERemittance/Extension/StringExtension.swift @@ -25,6 +25,10 @@ extension String { return components(separatedBy: .whitespaces).joined() } + func stringRemovingComma() -> String { + return components(separatedBy: ",").joined() + } + func getDateFromDateTime() -> String { return components(separatedBy: .whitespaces)[0] } diff --git a/GMERemittance/Model/SendMoneyExchangeRate.swift b/GMERemittance/Model/SendMoneyExchangeRate.swift index 9f1f5d8b..f8e66a33 100644 --- a/GMERemittance/Model/SendMoneyExchangeRate.swift +++ b/GMERemittance/Model/SendMoneyExchangeRate.swift @@ -21,6 +21,7 @@ class SendMoneyExchangeRateModel: Mappable { var calcBy: String? var forexId:String? var transferAmount: String? + var autodebitSendingAmount: String? init() {} diff --git a/GMERemittance/Module/SendMoney/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift b/GMERemittance/Module/SendMoney/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift index c133b406..cd900dd5 100644 --- a/GMERemittance/Module/SendMoney/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift +++ b/GMERemittance/Module/SendMoney/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift @@ -55,6 +55,7 @@ class SendMoneyExchangeRateViewController: UIViewController { // MARK: Properties + var plainSendingAmount: String? var action: ActionBehaviour? { didSet { @@ -172,9 +173,14 @@ class SendMoneyExchangeRateViewController: UIViewController { private func goToVerification() { self.exchangeRateModel?.calcBy = self.calcBy self.exchangeRateModel?.reciepientCurrency = self.selectedCurrencyViewModel?.currency ?? "" + self.exchangeRateModel?.autodebitSendingAmount = self.getPlainNumbers(number: self.senderTextField.text!) self.actionDelegate?.calculated(model: self.exchangeRateModel) self.actionDelegate?.continueToVerificationAction() } + + private func getPlainNumbers(number: String) -> String { + return number.stringRemovingComma() + } func calculateExchangeRate(senderAmount: String, reciepientAmount: String, calcBy: String) { let senderAmount = senderAmount // send sAmt amount diff --git a/GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift b/GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift index e859d93a..35b83605 100644 --- a/GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift +++ b/GMERemittance/Module/SendMoney/SendMoneyVerification/User Interface/View/SendMoneyVerificationViewController.swift @@ -227,7 +227,7 @@ class SendMoneyVerificationViewController: UITableViewController { showQwertyTranskeyAction() return } - SendMoneyCodeWireframe().open(completion: self.otpEntered, source: self) + SendMoneyCodeWireframe().open(requestmodel: self.requestModel, completion: self.otpEntered, source: self) } func otpEntered(otp: String) { diff --git a/GMERemittance/Module/SendMoneyCode/Application Logic/Interactor/SendMoneyCodeInteractor.swift b/GMERemittance/Module/SendMoneyCode/Application Logic/Interactor/SendMoneyCodeInteractor.swift index 3a195b66..d656675a 100644 --- a/GMERemittance/Module/SendMoneyCode/Application Logic/Interactor/SendMoneyCodeInteractor.swift +++ b/GMERemittance/Module/SendMoneyCode/Application Logic/Interactor/SendMoneyCodeInteractor.swift @@ -14,11 +14,13 @@ class SendMoneyCodeInteractor { weak var output: SendMoneyCodeInteractorOutput? private let service: SendMoneyCodeServiceType + private var request: SendMoneyRequestModel? // MARK: Initialization - init(service: SendMoneyCodeServiceType) { + init(service: SendMoneyCodeServiceType, request: SendMoneyRequestModel?) { self.service = service + self.request = request } // MARK: Converting entities @@ -29,7 +31,12 @@ class SendMoneyCodeInteractor { extension SendMoneyCodeInteractor: SendMoneyCodeInteractorInput { func viewIsReady() { let customerId = Utility.getMyUserName() - self.service.requestOtp(customerId: customerId, success: { (message) in + let params = [ + "amount": request?.exchangeRateDetail?.autodebitSendingAmount ?? "", + "kftcId": request?.autoDebitAccount?.kftcLogId ?? "", + "userId": Utility.getMyUserName() + ] + self.service.requestOtp(params: params, customerId: customerId, success: { (message) in self.output?.show(message: message) }) { (error) in self.output?.show(error: error) diff --git a/GMERemittance/Module/SendMoneyCode/Application Logic/Service/SendMoneyCodeServiceType.swift b/GMERemittance/Module/SendMoneyCode/Application Logic/Service/SendMoneyCodeServiceType.swift index aceb12cc..b2a41022 100644 --- a/GMERemittance/Module/SendMoneyCode/Application Logic/Service/SendMoneyCodeServiceType.swift +++ b/GMERemittance/Module/SendMoneyCode/Application Logic/Service/SendMoneyCodeServiceType.swift @@ -15,14 +15,14 @@ protocol SendMoneyCodeServiceType: class, OtpCodeRequestApiService { protocol OtpCodeRequestApiService: ApiServiceType { - func requestOtp(customerId: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) + func requestOtp(params: [String: String], customerId: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) } extension OtpCodeRequestApiService { - func requestOtp(customerId: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) { - let url = baseUrl + "/kftc/GetOTP/\(customerId)" - auth.request(method: .post, url: url, params: nil, encoding: JSONEncoding.default, success: { (response: SuccessMessageContainer) in + func requestOtp(params: [String: String], customerId: String, success: @escaping (String) -> (), failure: @escaping (Error) -> ()) { + let url = baseUrl + "/kftc/GetOTP" + auth.request(method: .post, url: url, params: params, encoding: JSONEncoding.default, success: { (response: SuccessMessageContainer) in if (response.errorCode ?? "") == "1" { diff --git a/GMERemittance/Module/SendMoneyCode/User Interface/Wireframe/SendMoneyCodeWireframe.swift b/GMERemittance/Module/SendMoneyCode/User Interface/Wireframe/SendMoneyCodeWireframe.swift index aa1f5d6e..7cfd2931 100644 --- a/GMERemittance/Module/SendMoneyCode/User Interface/Wireframe/SendMoneyCodeWireframe.swift +++ b/GMERemittance/Module/SendMoneyCode/User Interface/Wireframe/SendMoneyCodeWireframe.swift @@ -11,6 +11,7 @@ import UIKit class SendMoneyCodeWireframe { weak var view: UIViewController! var completion: ((String) -> ())? + var request: SendMoneyRequestModel? } extension SendMoneyCodeWireframe: SendMoneyCodeWireframeInput { @@ -19,7 +20,7 @@ extension SendMoneyCodeWireframe: SendMoneyCodeWireframeInput { func getMainView() -> UIViewController { let service = SendMoneyCodeService() - let interactor = SendMoneyCodeInteractor(service: service) + let interactor = SendMoneyCodeInteractor(service: service, request: self.request) let presenter = SendMoneyCodePresenter() let viewController = viewControllerFromStoryboard(of: SendMoneyCodeViewController.self) viewController.completion = self.completion @@ -33,8 +34,9 @@ extension SendMoneyCodeWireframe: SendMoneyCodeWireframeInput { return viewController } - func open(completion: @escaping (String) -> (), source: UIViewController) { + func open(requestmodel: SendMoneyRequestModel?, completion: @escaping (String) -> (), source: UIViewController) { self.completion = completion + self.request = requestmodel self.openMainView(source: source) } } diff --git a/GMERemittance/UrlManager.swift b/GMERemittance/UrlManager.swift index f54eec99..5f20ac55 100644 --- a/GMERemittance/UrlManager.swift +++ b/GMERemittance/UrlManager.swift @@ -25,7 +25,7 @@ class UrlManager { let oldUatServer = "http://gmeuat.gmeremit.com:5012/api/v1/" - let staggingServerUrl = "http://gmeuat.gmeremit.com:5022/api/" + let staggingServerUrl = "http://gmeuat.gmeremit.com:5026/api/" let liveServerUrl = "https://mobileapi.gmeremit.com:8002/api/" let uatServer = "http://gmeuat.gmeremit.com:5012/api/"