You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.0 KiB
101 lines
3.0 KiB
//
|
|
// 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)
|
|
}
|
|
}
|
|
|
|
// MARK: SendMoneyExchangeRate interactor output interface
|
|
|
|
extension SendMoneyExchangeRatePresenter: SendMoneyExchangeRateInteractorOutput {
|
|
func setError(with error: Error) {
|
|
view?.setError(with: error)
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|