From 5948d069b23d2071c7d62750dc91b34483e844ab Mon Sep 17 00:00:00 2001 From: gme_2 Date: Mon, 18 Mar 2019 15:40:02 +0900 Subject: [PATCH] added exchange rate model --- .../View/ResendExchangeViewController.swift | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/GMERemittance/Module/ResendExchange/User Interface/View/ResendExchangeViewController.swift b/GMERemittance/Module/ResendExchange/User Interface/View/ResendExchangeViewController.swift index 0fedf7df..774ce304 100644 --- a/GMERemittance/Module/ResendExchange/User Interface/View/ResendExchangeViewController.swift +++ b/GMERemittance/Module/ResendExchange/User Interface/View/ResendExchangeViewController.swift @@ -10,6 +10,23 @@ import UIKit class ResendExchangeViewController: UIViewController { + struct ApiConstants { + static let senderAmount = "cAmount" + static let senderCurrency = "sCurrency" + static let recieverAmount = "pAmount" + static let recieverCurrency = "pCurrency" + static let recieverCountryId = "pCountry" + static let paymentMethod = "paymentType" + static let paymentMethodId = "serviceType" + static let calcBy = "calcBy" + static let recieverCountryName = "pCountryName" + static let senderCountryId = "sCountry" + static let bankId = "pAgent" + static let payOutPartner = "payOutPartner" + static let userId = "userId" + } + + // MARK: IBOutlets @IBOutlet weak var exchangeBackground1: UIView! @@ -150,9 +167,54 @@ class ResendExchangeViewController: UIViewController { func calculate(senderAmt: String?, senderCurrency: String? = "KRW", recieverAmt: String?, recieverCurrency: String?, recieverCountryName: String?, recieverCountryId: String?, paymentMethod: String?, paymentMethodId: String? ,calcBy: String?, senderCountryId: String? = "118", payoutPartner: String?, userId: String?, bankId: String?) { // self.presenter?.calculate(senderAmt: senderAmt, senderCurrency: senderCurrency, recieverAmt: recieverAmt, recieverCurrency: recieverCurrency, recieverCountryName: recieverCountryName, recieverCountryId: recieverCountryId, paymentMethod: paymentMethod, paymentMethodId: paymentMethodId, calcBy: calcBy, senderCountryId: senderCountryId, payoutPartner: payoutPartner, userId: userId, bankId: bankId) + + let param: [String: String] = + [ + ApiConstants.senderAmount : senderAmt ?? "", + ApiConstants.senderCurrency : senderCurrency ?? "", + ApiConstants.recieverAmount : recieverAmt ?? "", + ApiConstants.recieverCurrency : recieverCurrency ?? "", + ApiConstants.recieverCountryName: recieverCountryName ?? "", + ApiConstants.recieverCountryId : recieverCountryId ?? "", + ApiConstants.paymentMethod: paymentMethod ?? "", + ApiConstants.paymentMethodId: paymentMethodId ?? "", + ApiConstants.calcBy : calcBy ?? "", + ApiConstants.senderCountryId : senderCountryId ?? "", + ApiConstants.payOutPartner : payoutPartner ?? "", + ApiConstants.userId : userId ?? "", + ApiConstants.bankId : bankId ?? "" + ] + + self.calculate(params: param, success: { (model) in + if let model = model { +// self.output?.show(model: model) + self.exchangeRateModel = model + }else { + let error = NSError.init(domain: "SendMoneyExchangeRateInteractor", code: 0, userInfo: [NSLocalizedDescriptionKey : "Failed to map exchange rate from server"]) + self.show(error: error.localizedDescription) + } + }) { (error) in + self.show(error: error.localizedDescription) + } + } +// func calculate(senderAmt: String?, senderCurrency: String?, recieverAmt: String?, recieverCurrency: String?, recieverCountryName: String?, recieverCountryId: String?, paymentMethod: String?, paymentMethodId: String?, calcBy: String?, senderCountryId: String?, payoutPartner: String?, userId: String?, bankId: String?) { +// let _senderAmt = senderAmt ?? "" +// let _recieverAmt = recieverAmt ?? "" +// if _senderAmt.isEmpty && _recieverAmt.isEmpty { +// let message = "please provide amount to calculate" +// self.view?.show(error: message) +// return +// } +// self.view?.showLoading() +// +// +// self.interactor?.calculate(params: param) +// } + + @objc private func textChanged(sender: UITextField) { self.action = .calculate switch sender { @@ -175,6 +237,10 @@ extension ResendExchangeViewController: ResendExchangeViewInterface { } +extension ResendExchangeViewController: FetchSendMoneyExchangeRateService { + +} + extension ResendExchangeViewController { @@ -190,3 +256,6 @@ extension ResendExchangeViewController { self.hideProgressHud() } } + + +