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.

84 lines
2.1 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. viewModel?.progress(isShow: true)
  22. wireframe?.openAddRecipient(with: delegate)
  23. }
  24. func openEditRecipient(who recipient: Recipient, with delegate: SetupRecipientDelegate) {
  25. viewModel?.progress(isShow: true)
  26. wireframe?.openEditRecipient(who: recipient, with: delegate)
  27. }
  28. func deleteRecipient(who recipient: Recipient) {
  29. viewModel?.progress(isShow: true)
  30. interactor?.deleteRecipient(who: recipient)
  31. }
  32. func fetchRecipients(isRefresh: Bool) {
  33. viewModel?.progress(isShow: true)
  34. interactor?.fetchRecipients(isRefresh: isRefresh)
  35. }
  36. func goNextStep(who recipient: Recipient, with account: Account) {
  37. wireframe?.goNextStep(who: recipient, with: account)
  38. }
  39. }
  40. // MARK: Recipients interactor output interface
  41. extension RecipientsPresenter: RecipientsInteractorOutput {
  42. func setRecipients(using model: [Recipient]) {
  43. viewModel?.progress(isShow: false)
  44. viewModel?.setRecipients(using: model)
  45. }
  46. func setAccounts(using model: [Account]) {
  47. viewModel?.setAccounts(using: model)
  48. }
  49. func setError(with error: Error) {
  50. viewModel?.progress(isShow: false)
  51. viewModel?.setError(with: error)
  52. }
  53. }
  54. extension RecipientsPresenter: RecipientsWireframeOutput {
  55. func setSelectedAccount(_ account: Account) {
  56. viewModel?.setSelectedAccount(account)
  57. }
  58. func openedSetupRecipient() {
  59. viewModel?.progress(isShow: false)
  60. }
  61. func setSelectAccountError(with error: Error) {
  62. viewModel?.setError(with: error)
  63. }
  64. }