shishir sapkota
6 years ago
8 changed files with 196 additions and 64 deletions
-
8GME Remit.xcodeproj/project.pbxproj
-
2GMERemittance/AppDelegate.swift
-
47GMERemittance/Model/AutoRefund.swift
-
109GMERemittance/Module/Auto refund/AutoRefundsViewController.swift
-
6GMERemittance/Module/Auto refund/autoRefund.storyboard
-
68GMERemittance/Module/Auto refund/autoRefundService.swift
-
6GMERemittance/Utility/AppConstants.swift
-
2Pods/Pods.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist
@ -0,0 +1,47 @@ |
|||
// |
|||
// AutoRefund.swift |
|||
// GME Remit |
|||
// |
|||
// Created by Mac on 11/21/18. |
|||
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved. |
|||
// |
|||
|
|||
import Foundation |
|||
import ObjectMapper |
|||
|
|||
class AutoRefund: Mappable { |
|||
var currentBalance: String? |
|||
var minAmount: String? |
|||
var chargeAmount: String? |
|||
|
|||
required init?(map: Map) { |
|||
|
|||
} |
|||
|
|||
func mapping(map: Map) { |
|||
chargeAmount <- map["RefundCharge"] |
|||
minAmount <- map["MinimumAmount"] |
|||
currentBalance <- map["CurrentBalance"] |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
class AutoRefundContainer: Mappable { |
|||
var errorCode: String? |
|||
var message: String? |
|||
var id: String? |
|||
var data: AutoRefund? |
|||
|
|||
required init?(map: Map) { |
|||
|
|||
} |
|||
|
|||
func mapping(map: Map) { |
|||
errorCode <- map["ErrorCode"] |
|||
message <- map["Msg"] |
|||
id <- map["Id"] |
|||
data <- map["Data"] |
|||
} |
|||
} |
@ -0,0 +1,68 @@ |
|||
// |
|||
// 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 (String) -> (), failure: @escaping (Error) -> ()) |
|||
} |
|||
|
|||
extension RefundService { |
|||
func refund(amount: String, userName: String, chargeAmount: String, userId: String, success: @escaping (String) -> (), 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?.message ?? "") |
|||
} |
|||
}) { (error) in |
|||
failure(error) |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
//{ |
|||
// "Username":"demo.gme@gmeremit.com", |
|||
// "Amount":"11000", |
|||
// "ChargeAmount":"1000", |
|||
// "UserId":"39442" |
|||
//} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue