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.

59 lines
2.2 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(success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ())
  12. }
  13. extension FetchCountryCurrencyInformation {
  14. func fetchCountryCurrencyInfo(success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) {
  15. let url = baseUrl + "mobile/countriesServices"
  16. // let url = "http://www.mocky.io/v2/5b7e22b3300000630084c052"
  17. auth.request(method: .get, url: url , params: nil, success: { (response: ExchangeRateContainer) in
  18. if (response.errorCode ?? "") == "1" {
  19. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  20. failure(error)
  21. }else {
  22. let model = response.data
  23. success(model)
  24. }
  25. }) { (error) in
  26. failure(error)
  27. }
  28. }
  29. }
  30. protocol getExchangeRateInformation: ApiServiceType {
  31. func getExchangeRateInformation(params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> ())
  32. }
  33. extension getExchangeRateInformation {
  34. func getExchangeRateInformation(params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> () ) {
  35. let url = baseUrl + "mobile/calculateDefExRate"
  36. // http://121.156.120.71:5001/api/v1/mobile/countriesServices
  37. // let url = "http://www.mocky.io/v2/5b7e62d2300000690084c117"
  38. auth.request(method: .post, url: url, params: params, success: { (response: ExchangeRateDetailContainer) in
  39. if (response.errorCode ?? "") == "1" {
  40. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  41. failure(error)
  42. }else {
  43. let model = response.data
  44. success(model)
  45. }
  46. }, failure: failure)
  47. }
  48. }