// // SendMoneyExchangeRatePresenter.swift // GMERemittance // // Created by gme_2 on 28/08/2018. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation class SendMoneyExchangeRatePresenter { 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: Properties weak var view: SendMoneyExchangeRateViewInterface? var interactor: SendMoneyExchangeRateInteractorInput? var wireframe: SendMoneyExchangeRateWireframeInput? // MARK: Converting entities } // MARK: SendMoneyExchangeRate module interface extension SendMoneyExchangeRatePresenter: SendMoneyExchangeRateModuleInterface { 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() 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.interactor?.calculate(params: param) } func viewIsReady() { } } // MARK: SendMoneyExchangeRate interactor output interface extension SendMoneyExchangeRatePresenter: SendMoneyExchangeRateInteractorOutput { func show(model: SendMoneyExchangeRateModel) { self.view?.hideLoading() self.view?.show(model: model) } func show(error: Error) { self.view?.hideLoading() self.view?.show(error: error.localizedDescription) } }