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.

42 lines
1.2 KiB

  1. //
  2. // SendMoneyExchangeRateInteractor.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 28/08/2018.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class SendMoneyExchangeRateInteractor {
  10. // MARK: Properties
  11. weak var output: SendMoneyExchangeRateInteractorOutput?
  12. private let service: SendMoneyExchangeRateServiceType
  13. // MARK: Initialization
  14. init(service: SendMoneyExchangeRateServiceType) {
  15. self.service = service
  16. }
  17. // MARK: Converting entities
  18. }
  19. // MARK: SendMoneyExchangeRate interactor input interface
  20. extension SendMoneyExchangeRateInteractor: SendMoneyExchangeRateInteractorInput {
  21. func calculate(params: [String : String]) {
  22. self.service.calculate(params: params, success: { (model) in
  23. if let model = model {
  24. self.output?.show(model: model)
  25. }else {
  26. let error = NSError.init(domain: "SendMoneyExchangeRateInteractor", code: 0, userInfo: [NSLocalizedDescriptionKey : "Failed to map exchange rate from server"])
  27. self.output?.show(error: error)
  28. }
  29. }) { (error) in
  30. self.output?.show(error: error)
  31. }
  32. }
  33. }