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.

75 lines
1.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. //
  2. // SendMoneyCodePresenter.swift
  3. // GME Remit
  4. //
  5. // Created by gme_2 on 27/02/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class SendMoneyCodePresenter {
  10. // MARK: Properties
  11. weak var view: SendMoneyCodeViewInterface?
  12. var interactor: SendMoneyCodeInteractorInput?
  13. var wireframe: SendMoneyCodeWireframeInput?
  14. var otpCount = 0
  15. // MARK: Converting entities
  16. }
  17. // MARK: SendMoneyCode module interface
  18. extension SendMoneyCodePresenter: SendMoneyCodeModuleInterface {
  19. func changeProfileResendOTP(newValue: String) {
  20. if otpCount < 2 {
  21. view?.showLoading()
  22. interactor?.changeProfileResendOTP(newValue: newValue)
  23. otpCount += 1
  24. } else {
  25. let error = NSError(
  26. domain: "OTP Count Error",
  27. code: 0,
  28. message: "The transaction request period has expired.\nPlease try to send money again."
  29. )
  30. self.view?.expiredError(error: error)
  31. }
  32. }
  33. func viewIsReady() {
  34. if otpCount < 3 {
  35. self.view?.showLoading()
  36. interactor?.viewIsReady()
  37. otpCount += 1
  38. } else {
  39. let error = NSError(
  40. domain: "OTP Count Error",
  41. code: 0,
  42. message: "The transaction request period has expired.\nPlease try to send money again."
  43. )
  44. self.view?.expiredError(error: error)
  45. }
  46. }
  47. }
  48. // MARK: SendMoneyCode interactor output interface
  49. extension SendMoneyCodePresenter: SendMoneyCodeInteractorOutput {
  50. func show(error: Error) {
  51. self.view?.hideLoading()
  52. self.view?.show(error: error.localizedDescription)
  53. }
  54. func successChangeProfileInformation() {
  55. self.view?.hideLoading()
  56. view?.successChangeProfileInformation()
  57. }
  58. func show(message: String) {
  59. self.view?.hideLoading()
  60. self.view?.show(message: message)
  61. }
  62. }