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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // SetupRecipientPresenter.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 09/08/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class SetupRecipientPresenter {
  10. // MARK: Properties
  11. weak var viewModel: SetupRecipientViewModelInterface?
  12. var interactor: SetupRecipientInteractorInput?
  13. var wireframe: SetupRecipientWireframeInput?
  14. }
  15. // MARK: SetupRecipient module interface
  16. extension SetupRecipientPresenter: SetupRecipientModuleInterface {
  17. func fetchCountriesAndServiceTypes() {
  18. viewModel?.progress(isShow: true)
  19. interactor?.fetchCountriesAndServiceTypes()
  20. }
  21. func openSelectMode(with model: [TablePresenterProtocol], type: SetupOpenType) {
  22. wireframe?.openSelectMode(with: model, type: type)
  23. }
  24. func openBranches(countryCode: String, bankID: String) {
  25. wireframe?.openBranches(countryCode: countryCode, bankID: bankID)
  26. }
  27. func fetchDynamicRecipientFields(country: CountryAndServiceModel?, paymentMode: PaymentServiceType?) {
  28. viewModel?.progress(isShow: true)
  29. interactor?.fetchDynamicRecipientFields(
  30. country: country?.countryId ?? "",
  31. paymentMode: paymentMode?.id ?? ""
  32. )
  33. }
  34. func saveRecipient(at recipient: Recipient) {
  35. viewModel?.progress(isShow: true)
  36. if recipient.receiverID == nil {
  37. interactor?.addRecipient(at: recipient)
  38. } else {
  39. interactor?.editRecipient(at: recipient)
  40. }
  41. }
  42. func validateAccount(with validateAccountModel: ValidateAccountRequest, recipient: Recipient) {
  43. viewModel?.progress(isShow: true)
  44. interactor?.validateAccount(with: validateAccountModel, recipient: recipient)
  45. }
  46. }
  47. // MARK: SetupRecipient interactor output interface
  48. extension SetupRecipientPresenter: SetupRecipientInteractorOutput {
  49. func setCoutryServices(with model: [CountryAndServiceModel], recipient: Recipient?) {
  50. viewModel?.progress(isShow: false)
  51. viewModel?.setCoutryServices(with: model, recipient: recipient)
  52. }
  53. func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel]) {
  54. viewModel?.progress(isShow: false)
  55. viewModel?.setDynamicFields(with: model, nativeCountires: nativeCountires)
  56. }
  57. func setError(with error: Error) {
  58. viewModel?.progress(isShow: false)
  59. viewModel?.setError(with: error)
  60. }
  61. func success(with model: ResponseContainerObject<Recipient>) {
  62. viewModel?.progress(isShow: false)
  63. viewModel?.success(with: model)
  64. }
  65. }
  66. // MARK: SetupRecipient wireframe output interface
  67. extension SetupRecipientPresenter: SetupRecipientWireframeOutput {
  68. func setSelectedData(with model: TablePresenterProtocol?, type: SetupOpenType) {
  69. viewModel?.setSelectedData(with: model, type: type)
  70. }
  71. }