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.

72 lines
2.3 KiB

6 years ago
6 years ago
  1. //
  2. // AutoDebitService.swift
  3. // GME Remit
  4. //
  5. // Created by Mac on 12/19/18.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. import Alamofire
  10. class AutoDebitService: AutoDebitServiceType {
  11. // MARK: Properties
  12. // MARK: Initialization
  13. // MARK: Data management
  14. }
  15. protocol FetchAccountList: ApiServiceType {
  16. func fetchAccountList(username: String, success: @escaping (KFTCModel?) -> (), failure: @escaping (Error) -> ())
  17. }
  18. // kftc/GetKftcParameters/
  19. extension FetchAccountList {
  20. func fetchAccountList(username: String, success: @escaping (KFTCModel?) -> (), failure: @escaping (Error) -> ()) {
  21. let url = "http://gmeuat.gmeremit.com:5012/api/v2/" + "kftc/GetKftcParameters/" + username
  22. auth.request(method: .get, url: url, params: nil, encoding: URLEncoding.default, success: { (response: KftcAccountContainer) in
  23. if (response.errorCode ?? "") == "1" {
  24. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  25. failure(error)
  26. }else {
  27. let model = response.data
  28. success(model)
  29. }
  30. }) { (error) in
  31. failure(error)
  32. }
  33. }
  34. }
  35. //http://localhost:9500/api/v1/mobile/receiver/remove/sisir@mailinator.com/?receiverId=143313
  36. protocol DeleteAccountService: ApiServiceType {
  37. func deleteAccount(username: String, account: Account, success: @escaping () -> (), failure: @escaping (Error) -> ())
  38. }
  39. extension DeleteAccountService {
  40. func deleteAccount(username: String, account: Account, success: @escaping () -> (), failure: @escaping (Error) -> ()) {
  41. let url = "http://gmeuat.gmeremit.com:5022/api/v2/kftc/DeleteAccount/\(username)"
  42. auth.request(method: .post, url: url, params: nil, encoding: URLEncoding.default, success: { (response: KftcAccountContainer) in
  43. if (response.errorCode ?? "") == "1" {
  44. let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
  45. failure(error)
  46. }else {
  47. success()
  48. }
  49. }) { (error) in
  50. failure(error)
  51. }
  52. }
  53. }