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.

56 lines
1.2 KiB

5 years ago
5 years ago
5 years ago
  1. //
  2. // ManageAgreementInteractor.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 2019/12/23.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class ManageAgreementInteractor {
  10. // MARK: Properties
  11. weak var output: ManageAgreementInteractorOutput?
  12. private let service: ManageAgreementServiceType
  13. private var documents: [AgreePDFDocument]?
  14. // MARK: Initialization
  15. init(service: ManageAgreementServiceType) {
  16. self.service = service
  17. }
  18. }
  19. // MARK: ManageAgreement interactor input interface
  20. extension ManageAgreementInteractor: ManageAgreementInteractorInput {
  21. func fetchDocuments() {
  22. guard let documents = documents else {
  23. service.fetchDocuments(
  24. success: {[weak self] in
  25. self?.documents = $0
  26. self?.output?.setDocuments(with: $0)
  27. },
  28. failure: {[weak self] in self?.output?.setError(with: $0)}
  29. )
  30. return
  31. }
  32. output?.setDocuments(with: documents)
  33. }
  34. func agreement(_ flag: Bool) {
  35. service.agreement(
  36. flag,
  37. success: {[weak self] in
  38. self?.output?.resultAgreement()
  39. },
  40. failure: {[weak self] in
  41. self?.output?.setError(with: $0)
  42. }
  43. )
  44. }
  45. }