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.

90 lines
3.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. //
  2. // ResendExchangeInteractor.swift
  3. // GME Remit
  4. //
  5. // Created by gme_2 on 18/03/2019.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class ResendExchangeInteractor {
  10. struct ApiConstants {
  11. static let senderAmount = "cAmount"
  12. static let senderCurrency = "sCurrency"
  13. static let recieverAmount = "pAmount"
  14. static let recieverCurrency = "pCurrency"
  15. static let recieverCountryId = "pCountry"
  16. static let paymentMethod = "paymentType"
  17. static let paymentMethodId = "serviceType"
  18. static let calcBy = "calcBy"
  19. static let recieverCountryName = "pCountryName"
  20. static let senderCountryId = "sCountry"
  21. static let bankId = "pAgent"
  22. static let payOutPartner = "payOutPartner"
  23. static let userId = "userId"
  24. }
  25. // MARK: Properties
  26. weak var output: ResendExchangeInteractorOutput?
  27. private let service: ResendExchangeServiceType
  28. var transactionId: String?
  29. // MARK: Initialization
  30. init(service: ResendExchangeServiceType, transactionId: String?) {
  31. self.service = service
  32. self.transactionId = transactionId
  33. }
  34. // MARK: Converting entities
  35. }
  36. // MARK: ResendExchange interactor input interface
  37. extension ResendExchangeInteractor: ResendExchangeInteractorInput {
  38. func viewIsReady() {
  39. self.service.fetch(transactionId: self.transactionId ?? "", success: { (model) in
  40. // ResendDetail
  41. guard let model = model else {return}
  42. self.output?.show(model: model)
  43. }) { (error) in
  44. self.output?.show(error: error)
  45. }
  46. }
  47. func calculate(senderAmt: String, senderCurrency: String, recieverAmt: String, recieverCurrency: String, recieverCountryName: String, recieverCountryId: String, paymentMethod: String, paymentMethodId: String, calcBy: String, senderCountryId: String, payoutPartner: String, userId: String, bankId: String) {
  48. var param: [String: String] =
  49. [
  50. ApiConstants.senderAmount : senderAmt,
  51. ApiConstants.senderCurrency : senderCurrency,
  52. ApiConstants.recieverAmount : recieverAmt,
  53. ApiConstants.recieverCurrency : recieverCurrency,
  54. ApiConstants.recieverCountryName: recieverCountryName,
  55. ApiConstants.recieverCountryId : recieverCountryId,
  56. ApiConstants.paymentMethod: paymentMethod,
  57. ApiConstants.paymentMethodId: paymentMethodId,
  58. ApiConstants.calcBy : calcBy,
  59. ApiConstants.senderCountryId : senderCountryId,
  60. // ApiConstants.payOutPartner : payoutPartner,
  61. ApiConstants.userId : userId,
  62. ApiConstants.bankId : bankId
  63. ]
  64. if !payoutPartner.isEmpty {
  65. param[ApiConstants.payOutPartner] = payoutPartner
  66. }
  67. self.service.calculate(params: param, success: { (model) in
  68. guard let model = model else {return}
  69. self.output?.show(model: model)
  70. }) { (error) in
  71. self.output?.showExchangeRate(error: error)
  72. }
  73. }
  74. }