// // OrderHistoryService.swift // GME Remit // // Created by InKwon Devik Kim on 14/05/2019. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. // import Foundation class OrderHistoryService: OrderHistoryServiceType { func fetchOrderHistory( from startDate: String, to endDate: String, success: @escaping([Order]?) -> Void, failure: @escaping(Error) -> Void ) { guard let userId = GMEDB.shared.user.string(.userId) else { let error = NSError.init( domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : "no exist email"]) failure(error) return } let parameter = [ "userId": userId, "startDate": startDate, "endDate": endDate ] let url = baseUrlWithoutVersion + "v2/reward/productOrderedList" // let url = baseUrlWithoutVersion + "v2/reward/productOrderd" auth.request( method: .post, url: url, params: parameter, success: { (response: OrderContainer) 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($0) } ) } }