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.
69 lines
2.2 KiB
69 lines
2.2 KiB
//
|
|
// autoRefundService.swift
|
|
// GME Remit
|
|
//
|
|
// Created by Mac on 11/21/18.
|
|
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
|
|
import Alamofire
|
|
|
|
|
|
protocol FetchAutoRefundInfo: ApiServiceType {
|
|
func fetchAutoRefundInfo(username: String, success: @escaping (AutoRefund) -> (), failure: @escaping (Error) -> ())
|
|
}
|
|
|
|
|
|
extension FetchAutoRefundInfo {
|
|
func fetchAutoRefundInfo(username: String, success: @escaping (AutoRefund) -> (), failure: @escaping (Error) -> ()) {
|
|
let url = baseUrl + "refund/\(username)"
|
|
auth.request(method: .get, url: url, params: nil, encoding: URLEncoding.default, success: { (response: AutoRefundContainer) in
|
|
if let model = response.data {
|
|
success(model)
|
|
}else {
|
|
let error = NSError.init(domain: "FetchAutoRefundInfo", code: 0, userInfo: [NSLocalizedDescriptionKey : "Could not parse json"])
|
|
}
|
|
}) { (error) in
|
|
failure(error)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protocol RefundService: ApiServiceType {
|
|
func refund(amount: String, userName: String, chargeAmount: String, userId: String, success: @escaping (SuccessMessage?) -> (), failure: @escaping (Error) -> ())
|
|
}
|
|
|
|
extension RefundService {
|
|
func refund(amount: String, userName: String, chargeAmount: String, userId: String, success: @escaping (SuccessMessage?) -> (), failure: @escaping (Error) -> ()) {
|
|
let url = baseUrl + "refund/proceed"
|
|
let params = [
|
|
"Username": userName,
|
|
"Amount": amount,
|
|
"ChargeAmount": chargeAmount,
|
|
"UserId": userId
|
|
]
|
|
auth.request(method: .post, url: url, params: params, success: { (response: SuccessMessageContainer) in
|
|
if (response.errorCode ?? "") == "1" {
|
|
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
|
|
failure(error)
|
|
}else {
|
|
|
|
success(response.data)
|
|
}
|
|
}) { (error) in
|
|
failure(error)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//{
|
|
// "Username":"demo.gme@gmeremit.com",
|
|
// "Amount":"11000",
|
|
// "ChargeAmount":"1000",
|
|
// "UserId":"39442"
|
|
//}
|