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.
 
 
 
 

86 lines
2.7 KiB

//
// SetupRecipientPresenter.swift
// GME Remit
//
// Created by InKwon James Kim on 09/08/2019.
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import Foundation
class SetupRecipientPresenter {
// MARK: Properties
weak var viewModel: SetupRecipientViewModelInterface?
var interactor: SetupRecipientInteractorInput?
var wireframe: SetupRecipientWireframeInput?
}
// MARK: SetupRecipient module interface
extension SetupRecipientPresenter: SetupRecipientModuleInterface {
func fetchCountriesAndServiceTypes() {
viewModel?.progress(isShow: true)
interactor?.fetchCountriesAndServiceTypes()
}
func openSelectMode(with model: [TablePresenterProtocol], type: SetupOpenType) {
wireframe?.openSelectMode(with: model, type: type)
}
func openBranches(countryCode: String, bankID: String) {
wireframe?.openBranches(countryCode: countryCode, bankID: bankID)
}
func fetchDynamicRecipientFields(country: CountryAndServiceModel?, paymentMode: PaymentServiceType?) {
viewModel?.progress(isShow: true)
interactor?.fetchDynamicRecipientFields(
country: country?.countryId ?? "",
paymentMode: paymentMode?.id ?? ""
)
}
func saveRecipient(at recipient: Recipient) {
viewModel?.progress(isShow: true)
if recipient.receiverID == nil {
interactor?.addRecipient(at: recipient)
} else {
interactor?.editRecipient(at: recipient)
}
}
func validateAccount(with validateAccountModel: ValidateAccountRequest, recipient: Recipient) {
viewModel?.progress(isShow: true)
interactor?.validateAccount(with: validateAccountModel, recipient: recipient)
}
}
// MARK: SetupRecipient interactor output interface
extension SetupRecipientPresenter: SetupRecipientInteractorOutput {
func setCoutryServices(with model: [CountryAndServiceModel], recipient: Recipient?) {
viewModel?.progress(isShow: false)
viewModel?.setCoutryServices(with: model, recipient: recipient)
}
func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel]) {
viewModel?.progress(isShow: false)
viewModel?.setDynamicFields(with: model, nativeCountires: nativeCountires)
}
func setError(with error: Error) {
viewModel?.progress(isShow: false)
viewModel?.setError(with: error)
}
func success(with model: ResponseContainerObject<Recipient>) {
viewModel?.progress(isShow: false)
viewModel?.success(with: model)
}
}
// MARK: SetupRecipient wireframe output interface
extension SetupRecipientPresenter: SetupRecipientWireframeOutput {
func setSelectedData(with model: TablePresenterProtocol?, type: SetupOpenType) {
viewModel?.setSelectedData(with: model, type: type)
}
}