// // 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(isAuth: Bool, success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) } extension FetchCountryCurrencyInformation { func fetchCountryCurrencyInfo(isAuth: Bool = true, success: @escaping ([ExchangeRateModel]?) -> (), failure: @escaping (Error) -> ()) { let url = baseUrl + "/mobile/countriesServices" auth.request(method: .get, url: url , params: nil, needsAuthorization: isAuth, 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(isAuth: Bool, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> ()) } extension getExchangeRateInformation { func getExchangeRateInformation(isAuth: Bool = true, params: [String: String], success: @escaping (ExchangeRateDetailModel?) -> (), failure: @escaping (Error) -> () ) { let url = baseUrl + "/mobile/calculateDefExRate" auth.request(method: .post, url: url, params: params, needsAuthorization: isAuth, 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) } }