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.

82 lines
2.0 KiB

  1. //
  2. // RecipientsPresenter.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 08/08/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class RecipientsPresenter {
  10. // MARK: Properties
  11. weak var viewModel: RecipientsViewModelInterface?
  12. var interactor: RecipientsInteractorInput?
  13. var wireframe: RecipientsWireframeInput?
  14. }
  15. // MARK: Recipients module interface
  16. extension RecipientsPresenter: RecipientsModuleInterface {
  17. func openSelectAccount(with accounts: [Account]) {
  18. wireframe?.openSelectAccount(with: accounts)
  19. }
  20. func openAddRecipient(with delegate: SetupRecipientDelegate) {
  21. wireframe?.openAddRecipient(with: delegate)
  22. }
  23. func openEditRecipient(who recipient: Recipient, with delegate: SetupRecipientDelegate) {
  24. wireframe?.openEditRecipient(who: recipient, with: delegate)
  25. }
  26. func deleteRecipient(who recipient: Recipient) {
  27. viewModel?.progress(isShow: true)
  28. interactor?.deleteRecipient(who: recipient)
  29. }
  30. func fetchRecipients(isRefresh: Bool) {
  31. viewModel?.progress(isShow: true)
  32. interactor?.fetchRecipients(isRefresh: isRefresh)
  33. }
  34. func goNextStep(who recipient: Recipient, with account: Account) {
  35. wireframe?.goNextStep(who: recipient, with: account)
  36. }
  37. }
  38. // MARK: Recipients interactor output interface
  39. extension RecipientsPresenter: RecipientsInteractorOutput {
  40. func setRecipients(using model: [Recipient]) {
  41. viewModel?.progress(isShow: false)
  42. viewModel?.setRecipients(using: model)
  43. }
  44. func setAccounts(using model: [Account]) {
  45. viewModel?.setAccounts(using: model)
  46. }
  47. func setError(with error: Error) {
  48. viewModel?.progress(isShow: false)
  49. viewModel?.setError(with: error)
  50. }
  51. }
  52. extension RecipientsPresenter: RecipientsWireframeOutput {
  53. func setSelectedAccount(_ account: Account) {
  54. viewModel?.setSelectedAccount(account)
  55. }
  56. func openedSetupRecipient() {
  57. viewModel?.progress(isShow: false)
  58. }
  59. func setSelectAccountError(with error: Error) {
  60. viewModel?.setError(with: error)
  61. }
  62. }