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.

283 lines
7.6 KiB

5 years ago
5 years ago
  1. //
  2. // TotalManageAccountsService.swift
  3. // GME Remit
  4. //
  5. // Created by InKwon James Kim on 2019/11/15.
  6. //Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import Foundation
  9. class TotalManageAccountsService: TotalManageAccountsServiceType {
  10. func fetchAutodebitAccounts(
  11. username: String,
  12. success: @escaping (KFTCModel?) -> Void,
  13. failure: @escaping (Error) -> Void
  14. ) {
  15. let test =
  16. """
  17. {
  18. "Id" : "",
  19. "Extra" : "",
  20. "Extra2" : "",
  21. "Data" : {
  22. "URL" : "https://testapi.open-platform.or.kr/oauth/2.0/authorize2?response_type=code&client_id=l7xx9a67eaeb6a684f15b441769931d582b3&redirect_uri=http://gmeuat.gmeremit.com:5013/Dashboard/AutoDebit&scope=login+inquiry+transfer&client_info=mobile_40154&auth_type=1&bg_color=%23F4F8FB&txt_color=%23000000&btn1_color=%23EF343B&btn2_color=%2322246B&edit_option=off&invoke_type=ajax",
  23. "Header" : [
  24. {
  25. "Key" : "Kftc-Bfop-UserSeqNo",
  26. "Value" : "1100033843"
  27. },
  28. {
  29. "Key" : "Kftc-Bfop-UserCI",
  30. "Value" : "mAjbMK7hXiDfv2mUMEfocsYaYUyOKVzzAIwPo8pcVI/3Iqy+LVkkTM8PGJkcpsaVzqh03TBn0HkryMdGXkb6xg=="
  31. },
  32. {
  33. "Key" : "Kftc-Bfop-UserName",
  34. "Value" : "김한성"
  35. },
  36. {
  37. "Key" : "Kftc-Bfop-UserInfo",
  38. "Value" : ""
  39. },
  40. {
  41. "Key" : "Kftc-Bfop-UserCellNo",
  42. "Value" : ""
  43. },
  44. {
  45. "Key" : "Kftc-Bfop-PhoneCarrier",
  46. "Value" : ""
  47. },
  48. {
  49. "Key" : "Kftc-Bfop-UserEmail",
  50. "Value" : ""
  51. }
  52. ],
  53. "Language" : [
  54. {
  55. "Key" : "eng",
  56. "Value" : "English"
  57. },
  58. {
  59. "Key" : "kor",
  60. "Value" : "Korean"
  61. },
  62. {
  63. "Key" : "vnm",
  64. "Value" : "Vietnamese"
  65. },
  66. {
  67. "Key" : "idn",
  68. "Value" : "Indonesia"
  69. },
  70. {
  71. "Key" : "khm",
  72. "Value" : "Khmer"
  73. },
  74. {
  75. "Key" : "phl",
  76. "Value" : "Philippines"
  77. },
  78. {
  79. "Key" : "npl",
  80. "Value" : "Nepalese"
  81. },
  82. {
  83. "Key" : "bgd",
  84. "Value" : "Bangladesh"
  85. },
  86. {
  87. "Key" : "pak",
  88. "Value" : "Pakistan"
  89. },
  90. {
  91. "Key" : "rus",
  92. "Value" : "Russian"
  93. },
  94. {
  95. "Key" : "uzb",
  96. "Value" : "Uzbekistan"
  97. },
  98. {
  99. "Key" : "mng",
  100. "Value" : "Mongolia"
  101. },
  102. {
  103. "Key" : "lka",
  104. "Value" : "Sri Lanka"
  105. }
  106. ],
  107. "AccountList" : [
  108. {
  109. "BankCode" : "034",
  110. "UserCi" : null,
  111. "AccountNum" : null,
  112. "BankName" : "광주은행",
  113. "WalletName" : null,
  114. "AutoDebit" : null,
  115. "Type" : null,
  116. "FintechUseNo" : "101055699969776524847629",
  117. "AccountNumMasked" : "11111111***",
  118. "FullAccountName" : null,
  119. "IsApproved" : null,
  120. "AccHolderInfoType" : null,
  121. "Scope" : null,
  122. "UserSeqNo" : null,
  123. "KftcAccountId" : "seExx5jztZNXJh+76iUiKA==",
  124. "CustomerId" : null,
  125. "BankCodeStd" : "034",
  126. "IsShowRefresh" : "N",
  127. "AccessToken" : null,
  128. "AccHolderInfo" : null,
  129. "AccountName" : null,
  130. "IsInboundPennyTestRequested" : true,
  131. "TokenType" : null
  132. },
  133. {
  134. "BankCode" : "088",
  135. "UserCi" : null,
  136. "AccountNum" : null,
  137. "BankName" : "신한은행",
  138. "WalletName" : null,
  139. "AutoDebit" : null,
  140. "Type" : null,
  141. "FintechUseNo" : "101055699969776524847629",
  142. "AccountNumMasked" : "22222222***",
  143. "FullAccountName" : null,
  144. "IsApproved" : null,
  145. "AccHolderInfoType" : null,
  146. "Scope" : null,
  147. "UserSeqNo" : null,
  148. "KftcAccountId" : "seExx5jztZNXJh+76iUiKA==",
  149. "CustomerId" : null,
  150. "BankCodeStd" : "034",
  151. "IsShowRefresh" : "N",
  152. "AccessToken" : null,
  153. "AccHolderInfo" : null,
  154. "AccountName" : null,
  155. "IsInboundPennyTestRequested" : true,
  156. "TokenType" : null
  157. },
  158. {
  159. "BankCode" : "081",
  160. "UserCi" : null,
  161. "AccountNum" : null,
  162. "BankName" : "KEB 하나은행",
  163. "WalletName" : null,
  164. "AutoDebit" : null,
  165. "Type" : null,
  166. "FintechUseNo" : "101055699969776524847629",
  167. "AccountNumMasked" : "33333333***",
  168. "FullAccountName" : null,
  169. "IsApproved" : null,
  170. "AccHolderInfoType" : null,
  171. "Scope" : null,
  172. "UserSeqNo" : null,
  173. "KftcAccountId" : "seExx5jztZNXJh+76iUiKA==",
  174. "CustomerId" : null,
  175. "BankCodeStd" : "034",
  176. "IsShowRefresh" : "N",
  177. "AccessToken" : null,
  178. "AccHolderInfo" : null,
  179. "AccountName" : null,
  180. "IsInboundPennyTestRequested" : false,
  181. "TokenType" : null
  182. },
  183. ]
  184. },
  185. "ErrorCode" : "0",
  186. "Msg" : "Success"
  187. }
  188. """
  189. guard let data = ResponseContainerObject<KFTCModel>(JSONString: test)?.data else {
  190. return
  191. }
  192. success(data)
  193. }
  194. func fetchInboundAccounts(
  195. success: @escaping ([InboundAccount]) -> Void,
  196. failure: @escaping (Error) -> Void
  197. ) {
  198. //APIRouter.fetchInboundAccounts.json(success: success, failure: failure)
  199. //FIXME: TEST
  200. let test =
  201. """
  202. {
  203. "Id" : "",
  204. "Extra" : "",
  205. "Extra2" : "",
  206. "Data" : [
  207. {
  208. "AccountNo" : "11111111***",
  209. "Bank" : "Kwangju Bank(KJ)",
  210. "IsPennyTestSuccess" : false,
  211. "BankCode" : "034",
  212. "IsPrimary" : false
  213. },
  214. {
  215. "AccountNo" : "22222222***",
  216. "Bank" : "Shinhan Bank",
  217. "IsPennyTestSuccess" : true,
  218. "BankCode" : "088",
  219. "IsPrimary" : false
  220. },
  221. {
  222. "AccountNo" : "40790204056295",
  223. "Bank" : "Kookmin-Bank(KB)",
  224. "IsPennyTestSuccess" : true,
  225. "BankCode" : "004",
  226. "IsPrimary" : true
  227. },
  228. {
  229. "AccountNo" : "549237567203123",
  230. "Bank" : "Industrial Bank of Korea(IBK)",
  231. "IsPennyTestSuccess" : true,
  232. "BankCode" : "003",
  233. "IsPrimary" : false
  234. },
  235. {
  236. "AccountNo" : "110223458102",
  237. "Bank" : "Suhyup Local Cooperatives",
  238. "IsPennyTestSuccess" : false,
  239. "BankCode" : "007",
  240. "IsPrimary" : false
  241. }
  242. ],
  243. "ErrorCode" : "0",
  244. "Msg" : "Success"
  245. }
  246. """
  247. guard let data = ResponseContainerArray<InboundAccount>(JSONString: test)?.data else {
  248. return
  249. }
  250. success(data)
  251. }
  252. func refreshTokenStep1(
  253. username: String,
  254. success: @escaping (KFTCModel?) -> Void,
  255. failure: @escaping (Error) -> Void
  256. ) {
  257. APIRouter.renewalToken(username: username)
  258. .request(
  259. success: { (response: KftcAccountContainer) in
  260. if (response.errorCode ?? "") == "1" {
  261. let error = NSError(
  262. domain: "Network",
  263. code: 0,
  264. userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
  265. )
  266. failure(error)
  267. } else {
  268. let model = response.data
  269. success(model)
  270. }
  271. },
  272. failure: failure
  273. )
  274. }
  275. }