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

//
// 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)
}
}