// // ExchangeRateApiService.swift // GMERemittance // // Created by gme_2 on 22/08/2018. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation import Alamofire protocol FetchCountryCurrencyInformation: ApiServiceType { func fetchCountryCurrencyInfo(success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) } extension FetchCountryCurrencyInformation { func fetchCountryCurrencyInfo(success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) { let url = oldBaseUrl + "mobile/countriesServices" // let url = "http://www.mocky.io/v2/5b7e22b3300000630084c052" auth.request(method: .get, url: url , params: nil, success: { (response: ExchangeRateContainer) in if (response.errorCode ?? "") == "1" { let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) failure(error) }else { let model = response.data success(model) } }) { (error) in failure(error) } } } protocol getExchangeRateInformation: ApiServiceType { func getExchangeRateInformation(params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> ()) } extension getExchangeRateInformation { func getExchangeRateInformation(params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> () ) { let url = oldBaseUrl + "mobile/calculateDefExRate" // http://121.156.120.71:5001/api/v1/mobile/countriesServices // let url = "http://www.mocky.io/v2/5b7e62d2300000690084c117" auth.request(method: .post, url: url, params: params, success: { (response: ExchangeRateDetailContainer) in if (response.errorCode ?? "") == "1" { let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]) failure(error) }else { let model = response.data success(model) } }, failure: failure) } }