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.

47 lines
1.1 KiB

6 years ago
6 years ago
  1. //
  2. // AddReciepientInteractor.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 26/08/2018.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class AddReciepientInteractor {
  10. // MARK: Properties
  11. weak var output: AddReciepientInteractorOutput?
  12. private let service: AddReciepientServiceType
  13. // MARK: Initialization
  14. init(service: AddReciepientServiceType) {
  15. self.service = service
  16. }
  17. // MARK: Converting entities
  18. }
  19. // MARK: AddReciepient interactor input interface
  20. extension AddReciepientInteractor: AddReciepientInteractorInput {
  21. func viewIsReady() {
  22. self.service.fetch(success: { (model) in
  23. self.output?.show(model: model)
  24. }) { (error) in
  25. self.output?.show(error: error)
  26. }
  27. }
  28. func save(reciepient: Recipient) {
  29. let myUsername = Utility.getMyUserName()
  30. self.service.save(model: reciepient.serialize(), username: myUsername, success: { (reciepient) in
  31. self.output?.success()
  32. }) { (error) in
  33. self.output?.show(error: error)
  34. }
  35. }
  36. }