Browse Source

send money exchange rate model shown to view controller

pull/1/head
gme_2 6 years ago
parent
commit
1e7870d7bc
  1. 26
      GMERemittance/Model/SendMoneyExchangeRate.swift
  2. 13
      GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Interactor/SendMoneyExchangeRateInteractor.swift
  3. 3
      GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Interactor/SendMoneyExchangeRateInteractorIO.swift
  4. 25
      GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Service/SendMoneyExchangeRateServiceType.swift
  5. 11
      GMERemittance/Module/SendMoneyExchangeRate/User Interface/Presenter/SendMoneyExchangeRatePresenter.swift
  6. 18
      GMERemittance/Module/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift
  7. 1
      GMERemittance/Module/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewInterface.swift

26
GMERemittance/Model/SendMoneyExchangeRate.swift

@ -9,29 +9,6 @@
import Foundation
import ObjectMapper
//{
// "ErrorCode": "0",
// "Msg": "Success",
// "Id": "",
// "Data": {
// "Id": null,
// "scCharge": null,
// "exRateDisplay": "0.097",
// "exRate": "0.09703302",
// "pCurr": "NPR",
// "pAmt": "150000.00",
// "sAmt": null,
// "disc": "0.00",
// "collAmt": "15000.00",
// "collCurr": "KRW",
// "amountLimitPerDay": "20000.00",
// "minAmountLimitPerTran": null,
// "maxAmountLimitPerTran": null,
// "schemeId": null
// }
//}
class SendMoneyExchangeRateModel: Mappable {
var id: String?
var transferFee: String?
@ -51,6 +28,7 @@ class SendMoneyExchangeRateModel: Mappable {
recipientAmount <- map["pAmt"]
senderAmount <- map["collAmt"]
senderCurrency <- map["collCurr"]
}
}
@ -58,7 +36,7 @@ class SendMoneyExchangeRateModelContainer: Mappable {
var errorCode: String?
var message: String?
var id: String?
var data: [SendMoneyExchangeRateModel]?
var data: SendMoneyExchangeRateModel?
required init?(map: Map) {

13
GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Interactor/SendMoneyExchangeRateInteractor.swift

@ -28,8 +28,15 @@ class SendMoneyExchangeRateInteractor {
extension SendMoneyExchangeRateInteractor: SendMoneyExchangeRateInteractorInput {
func calculate(params: [String : String]) {
self.service.calculate(params: params, success: { (model) in
if let model = model {
self.output?.show(model: model)
}else {
let error = NSError.init(domain: "SendMoneyExchangeRateInteractor", code: 0, userInfo: [NSLocalizedDescriptionKey : "Failed to map exchange rate from server"])
self.output?.show(error: error)
}
}) { (error) in
self.output?.show(error: error)
}
}
}

3
GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Interactor/SendMoneyExchangeRateInteractorIO.swift

@ -11,5 +11,6 @@ protocol SendMoneyExchangeRateInteractorInput: class {
}
protocol SendMoneyExchangeRateInteractorOutput: class {
func show(model: SendMoneyExchangeRateModel)
func show(error: Error)
}

25
GMERemittance/Module/SendMoneyExchangeRate/Application Logic/Service/SendMoneyExchangeRateServiceType.swift

@ -8,6 +8,27 @@
import Foundation
protocol SendMoneyExchangeRateServiceType: class {
func calculate(params: [String: String], success: ())
protocol SendMoneyExchangeRateServiceType: class, FetchSendMoneyExchangeRateService {
}
protocol FetchSendMoneyExchangeRateService: ApiServiceType {
func calculate(params: [String: String], success: @escaping (SendMoneyExchangeRateModel?) -> (), failure: @escaping (Error) -> ())
}
extension FetchSendMoneyExchangeRateService {
func calculate(params: [String: String], success: @escaping (SendMoneyExchangeRateModel?) -> (), failure: @escaping (Error) -> ()) {
let url = baseUrl + "mobile/sendmoney/calculate"
auth.request(method: .post, url: url, params: params, success: { (response: SendMoneyExchangeRateModelContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}else {
let model = response.data
success(model)
}
}) { (error) in
failure(error)
}
}
}

11
GMERemittance/Module/SendMoneyExchangeRate/User Interface/Presenter/SendMoneyExchangeRatePresenter.swift

@ -10,7 +10,6 @@ import Foundation
class SendMoneyExchangeRatePresenter {
struct ApiConstants {
static let senderAmount = "cAmount"
static let senderCurrency = "sCurrency"
@ -28,7 +27,6 @@ class SendMoneyExchangeRatePresenter {
}
// MARK: Properties
weak var view: SendMoneyExchangeRateViewInterface?
var interactor: SendMoneyExchangeRateInteractorInput?
var wireframe: SendMoneyExchangeRateWireframeInput?
@ -40,6 +38,7 @@ class SendMoneyExchangeRatePresenter {
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?) {
self.view?.showLoading()
let param: [String: String] =
[
ApiConstants.senderAmount : senderAmt ?? "",
@ -68,5 +67,13 @@ extension SendMoneyExchangeRatePresenter: SendMoneyExchangeRateModuleInterface {
// 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)
}
}

18
GMERemittance/Module/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift

@ -41,7 +41,14 @@ class SendMoneyExchangeRateViewController: UIViewController {
var currencyInfoViewModel: [SendMoneyExchangeRateCurrencyViewModel]?
var reciepient: Recipient?
var exchangeRateModel: SendMoneyExchangeRateModel? {
didSet {
self.reciepientTextField.text = self.exchangeRateModel?.recipientAmount
self.senderTextField.text = self.exchangeRateModel?.senderAmount
self.transferFeeInfoLabel.text = self.exchangeRateModel?.transferFee
self.transferFeeInfoLabel.isHidden = false
}
}
var requestModel: SendMoneyRequestModel?
var calcBy = ""
@ -144,6 +151,7 @@ class SendMoneyExchangeRateViewController: UIViewController {
}
private func configureViews() {
self.transferFeeInfoLabel.isHidden = true
let dropDownImage = #imageLiteral(resourceName: "dropdown_white").withRenderingMode(UIImageRenderingMode.alwaysTemplate)
let image = dropDownImage
self.dropDownImageView.image = image
@ -158,9 +166,6 @@ class SendMoneyExchangeRateViewController: 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)
}
@ -181,6 +186,11 @@ class SendMoneyExchangeRateViewController: UIViewController {
// MARK: SendMoneyExchangeRateViewInterface
extension SendMoneyExchangeRateViewController: SendMoneyExchangeRateViewInterface {
func show(model: SendMoneyExchangeRateModel) {
self.exchangeRateModel = model
}
func show(error: String) {
self.alert(message: error)
}

1
GMERemittance/Module/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewInterface.swift

@ -7,6 +7,7 @@
//
protocol SendMoneyExchangeRateViewInterface: class {
func show(model: SendMoneyExchangeRateModel)
func show(error: String)
func showLoading()
func hideLoading()

Loading…
Cancel
Save