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
2.1 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. //
  2. // ExchangeRateApiService.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 22/08/2018.
  6. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. import Alamofire
  10. protocol FetchCountryCurrencyInformation: ApiServiceType {
  11. func fetchCountryCurrencyInfo(isAuth: Bool, success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ())
  12. }
  13. extension FetchCountryCurrencyInformation {
  14. func fetchCountryCurrencyInfo(isAuth: Bool = true, success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) {
  15. let url = baseUrl + "/mobile/countriesServices"
  16. auth.request(method: .get, url: url , params: nil, needsAuthorization: isAuth, success: { (response: ExchangeRateContainer) in
  17. if (response.errorCode ?? "") == "1" {
  18. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  19. failure(error)
  20. }else {
  21. let model = response.data
  22. success(model)
  23. }
  24. }) { (error) in
  25. failure(error)
  26. }
  27. }
  28. }
  29. protocol getExchangeRateInformation: ApiServiceType {
  30. func getExchangeRateInformation(isAuth: Bool, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> ())
  31. }
  32. extension getExchangeRateInformation {
  33. func getExchangeRateInformation(isAuth: Bool = true, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> () ) {
  34. let url = baseUrl + "/mobile/calculateDefExRate"
  35. auth.request(method: .post, url: url, params: params, needsAuthorization: isAuth, success: { (response: ExchangeRateDetailContainer) in
  36. if (response.errorCode ?? "") == "1" {
  37. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  38. failure(error)
  39. }else {
  40. let model = response.data
  41. success(model)
  42. }
  43. }, failure: failure)
  44. }
  45. }