// // ResendExchangeInteractor.swift // GME Remit // // Created by gme_2 on 18/03/2019. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation class ResendExchangeInteractor { 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 output: ResendExchangeInteractorOutput? private let service: ResendExchangeServiceType var transactionId: String? // MARK: Initialization init(service: ResendExchangeServiceType, transactionId: String?) { self.service = service self.transactionId = transactionId } // MARK: Converting entities } // MARK: ResendExchange interactor input interface extension ResendExchangeInteractor: ResendExchangeInteractorInput { func viewIsReady() { self.service.fetch(transactionId: self.transactionId ?? "", success: { (model) in // ResendDetail guard let model = model else {return} self.output?.show(model: model) }) { (error) in self.output?.show(error: error) } } 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) { var 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 ] if !payoutPartner.isEmpty { param[ApiConstants.payOutPartner] = payoutPartner } self.service.calculate(params: param, success: { (model) in guard let model = model else {return} self.output?.show(model: model) }) { (error) in self.output?.showExchangeRate(error: error) } } }