1. 1 :
  2. 2 :
  3. 3 : (function(root, factory) {
  4. 4 :
  5. 5 : if (typeof module === 'object' && module.exports) {
  6. 6 : // CommonJS-like environments that support module.exports, like Node.
  7. 7 : module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
  8. 8 : , require('../handlers/RetrieveFundingAccountsHandler')
  9. 9 : , require('../handlers/RetrieveFundingAccountsPageHandler'), require('../OrbipayApiError'));
  10. 10 : }
  11. 11 : }(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveFundingAccountsHandler, RetrieveFundingAccountsPageHandler, OrbipayApiError) {
  12. 12 : 'use strict';
  13. 13 :
  14. 14 : /**
  15. 15 : * The FundingAccounts wrapper module.
  16. 16 : * @module wrappers/FundingAccounts
  17. 17 : */
  18. 18 : var exports = function() {
  19. 19 :
  20. 20 : };
  21. 21 : exports.constructFromObject = function (data, obj) {
  22. 22 : if (data) {
  23. 23 : obj = obj || new exports();
  24. 24 : if (data.hasOwnProperty('list')) {
  25. 25 : var FundingAccount = require('./FundingAccount');
  26. 26 : obj['list'] = ApiClient.convertToType(data['list'], [FundingAccount]);
  27. 27 : }
  28. 28 : if (data.hasOwnProperty('total_results_count')) {
  29. 29 : obj['total_results_count'] = data['total_results_count'];
  30. 30 : }
  31. 31 : if (data.hasOwnProperty('has_more_results')) {
  32. 32 : obj['has_more_results'] = data['has_more_results'];
  33. 33 : }
  34. 34 : if (data.hasOwnProperty('url')) {
  35. 35 : obj['url'] = data['url'];
  36. 36 : }
  37. 37 : if (data.hasOwnProperty('from_index')) {
  38. 38 : obj['from_index'] = data['from_index'];
  39. 39 : }
  40. 40 : if (data.hasOwnProperty('to_index')) {
  41. 41 : obj['to_index'] = data['to_index'];
  42. 42 : }
  43. 43 : if (data.hasOwnProperty('query_id')) {
  44. 44 : obj['query_id'] = data['query_id'];
  45. 45 : }
  46. 46 : if (data.hasOwnProperty('ID_CUSTOMER')) {
  47. 47 : obj['ID_CUSTOMER'] = data['ID_CUSTOMER'];
  48. 48 : }
  49. 49 : if (data.hasOwnProperty('page_size')) {
  50. 50 : obj['page_size'] = data['page_size'];
  51. 51 : }
  52. 52 : if (data.hasOwnProperty('account_number')) {
  53. 53 : obj['account_number'] = data['account_number'];
  54. 54 : }
  55. 55 : if (data.hasOwnProperty('status')) {
  56. 56 : obj['status'] = data['status'];
  57. 57 : }
  58. 58 : if (data.hasOwnProperty('aba_routing_number')) {
  59. 59 : obj['aba_routing_number'] = data['aba_routing_number'];
  60. 60 : }
  61. 61 : if (data.hasOwnProperty('account_type')) {
  62. 62 : obj['account_type'] = data['account_type'];
  63. 63 : }
  64. 64 : if (data.hasOwnProperty('account_subtype')) {
  65. 65 : obj['account_subtype'] = data['account_subtype'];
  66. 66 : }
  67. 67 : }
  68. 68 : return obj;
  69. 69 : };
  70. 70 :
  71. 71 :
  72. 72 : exports.prototype = Object.create(Base.prototype);
  73. 73 : exports.prototype.constructor = exports;
  74. 74 :
  75. 75 : /**
  76. 76 : * @member [FundingAccount] list
  77. 77 : */
  78. 78 : exports.prototype['list'] = undefined;
  79. 79 : /**
  80. 80 : * The total number of funding accounts of the customer matching the search criteria.
  81. 81 : * @member {String} total_results_count
  82. 82 : */
  83. 83 : exports.prototype['total_results_count'] = undefined;
  84. 84 : /**
  85. 85 : * true if there are more results or pages
  86. 86 : * @member {String} has_more_results
  87. 87 : */
  88. 88 : exports.prototype['has_more_results'] = undefined;
  89. 89 : /**
  90. 90 : * This URL fetches the next or previous set of funding accounts, based on the presence of after_object or before_object parameter.
  91. 91 : * @member {String} url
  92. 92 : */
  93. 93 : exports.prototype['url'] = undefined;
  94. 94 : /**
  95. 95 : * The id of the object before which the previous set of objects are to be retrieved.
  96. 96 : * @member {String} from_index
  97. 97 : */
  98. 98 : exports.prototype['from_index'] = undefined;
  99. 99 : /**
  100. 100 : * The id of the object after which the next set of objects are to be retrieved.
  101. 101 : * @member {String} to_index
  102. 102 : */
  103. 103 : exports.prototype['to_index'] = undefined;
  104. 104 : /**
  105. 105 : * The query id of the object.
  106. 106 : * @member {String} query_id
  107. 107 : */
  108. 108 : exports.prototype['query_id'] = undefined;
  109. 109 : /**
  110. 110 : * The unique identifier assigned by EBPP to the customer.
  111. 111 : * @member {String} ID_CUSTOMER
  112. 112 : */
  113. 113 : exports.prototype['ID_CUSTOMER'] = undefined;
  114. 114 : /**
  115. 115 : * The maximum number of objects returned in the query.
  116. 116 : * @member {String} page_size
  117. 117 : */
  118. 118 : exports.prototype['page_size'] = undefined;
  119. 119 : /**
  120. 120 : * The Account Number to get details of.
  121. 121 : * @member {String} account_number
  122. 122 : */
  123. 123 : exports.prototype['account_number'] = undefined;
  124. 124 : /**
  125. 125 : * The status of the funding account in EBPP. This can take multiple values in the format key=value1&key=value2....
  126. 126 : * @member [String] status
  127. 127 : */
  128. 128 : exports.prototype['status'] = undefined;
  129. 129 : /**
  130. 130 : * The ABA/Routing number for the bank account.
  131. 131 : * @member {String} aba_routing_number
  132. 132 : */
  133. 133 : exports.prototype['aba_routing_number'] = undefined;
  134. 134 : /**
  135. 135 : * The type of the funding account. This can take multiple values in the format key=value1&key=value2....
  136. 136 : * @member [String] account_type
  137. 137 : */
  138. 138 : exports.prototype['account_type'] = undefined;
  139. 139 : /**
  140. 140 : * The sub type of the funding account. This is derived by EBPP in the case of card funding accounts. It needs to be passed when adding or editing a DDA/bank account.
  141. 141 : * @member {String} account_subtype
  142. 142 : */
  143. 143 : exports.prototype['account_subtype'] = undefined;
  144. 144 :
  145. 145 : /**
  146. 146 : * @param {String} client_key - The client_key of FundingAccounts.
  147. 147 : * @return {module:wrappers/FundingAccounts} The instance of <code>FundingAccounts</code>.
  148. 148 : */
  149. 149 : exports.prototype.forClient = function (client_key) {
  150. 150 : var _this = this;
  151. 151 : Base.prototype.forClient.call(_this,client_key);
  152. 152 : return _this;
  153. 153 : };
  154. 154 : /**
  155. 155 : * @param {String} channel - The channel of FundingAccounts.
  156. 156 : * @return {module:wrappers/FundingAccounts} The instance of <code>FundingAccounts</code>.
  157. 157 : */
  158. 158 : exports.prototype.videChannel = function (channel) {
  159. 159 : var _this = this;
  160. 160 : Base.prototype.videChannel.call(_this,channel);
  161. 161 : return _this;
  162. 162 : };
  163. 163 : /**
  164. 164 : * @param {String} aba_routing_number - The aba_routing_number of FundingAccounts.
  165. 165 : * @param [String] account_type - The account_type of FundingAccounts.
  166. 166 : * @param {String} account_subtype - The account_subtype of FundingAccounts.
  167. 167 : * @param {String} account_number - The account_number of FundingAccounts.
  168. 168 : * @param [String] status - The status of FundingAccounts.
  169. 169 : * @param {String} page_size - The page_size of FundingAccounts.
  170. 170 : * @param {String} query_id - The query_id of FundingAccounts.
  171. 171 : * @param {String} from_index - The from_index of FundingAccounts.
  172. 172 : * @param {String} to_index - The to_index of FundingAccounts.
  173. 173 : * @return {module:wrappers/FundingAccounts} The instance of <code>FundingAccounts</code>.
  174. 174 : */
  175. 175 : exports.prototype.findBy = function (filterParameters) {
  176. 176 : var _this = this;
  177. 177 : if(filterParameters){
  178. 178 :
  179. 179 : _this['aba_routing_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'aba_routing_number', false);
  180. 180 : _this['account_type'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_type', true);
  181. 181 :
  182. 182 :
  183. 183 : _this['account_subtype'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_subtype', false);
  184. 184 :
  185. 185 : _this['account_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_number', false);
  186. 186 : _this['status'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'status', true);
  187. 187 :
  188. 188 :
  189. 189 : _this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
  190. 190 :
  191. 191 : _this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
  192. 192 :
  193. 193 : _this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
  194. 194 :
  195. 195 : _this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
  196. 196 : }
  197. 197 : return _this;
  198. 198 : };
  199. 199 : /**
  200. 200 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of FundingAccounts.
  201. 201 : * @return {module:wrappers/FundingAccounts} The instance of <code>FundingAccounts</code>.
  202. 202 : */
  203. 203 : exports.prototype.forCustomer = function (id_customer) {
  204. 204 : var _this = this;
  205. 205 :
  206. 206 : _this['ID_CUSTOMER'] = id_customer;
  207. 207 :
  208. 208 :
  209. 209 : return _this;
  210. 210 : };
  211. 211 :
  212. 212 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  213. 213 : var _this = this;
  214. 214 : _this.requestedBy(requestor, requestor_type);
  215. 215 : return _this;
  216. 216 : };
  217. 217 :
  218. 218 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  219. 219 : var _this = this;
  220. 220 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  221. 221 : try {
  222. 222 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  223. 223 : if (callback) {
  224. 224 : callback(response['exception'], response['data'])
  225. 225 : }
  226. 226 : } catch (e) {
  227. 227 : exception = OrbipayApiError.getDefaultException(e);
  228. 228 : if (callback) {
  229. 229 : callback(exception)
  230. 230 : }
  231. 231 : }
  232. 232 : };
  233. 233 : try {
  234. 234 : _this.withContext(invocation_context, live_mode, api_end_point);
  235. 235 : var handler = new RetrieveFundingAccountsHandler();
  236. 236 : if (callback && CommonUtil.isFunction(callback)) {
  237. 237 : return handler.process(_this, internalCallback);
  238. 238 : } else {
  239. 239 : return handler.process(_this);
  240. 240 : }
  241. 241 : }
  242. 242 : catch (e){
  243. 243 : var error = OrbipayApiError.getDefaultException(e);
  244. 244 : if (callback) {
  245. 245 : callback(error)
  246. 246 : }
  247. 247 : }
  248. 248 : };
  249. 249 : exports.prototype.getPage = function (invocation_context, callback, live_mode, api_end_point) {
  250. 250 : var _this = this;
  251. 251 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  252. 252 : try {
  253. 253 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  254. 254 : if (callback) {
  255. 255 : callback(response['exception'], response['data'])
  256. 256 : }
  257. 257 : } catch (e) {
  258. 258 : exception = OrbipayApiError.getDefaultException(e);
  259. 259 : if (callback) {
  260. 260 : callback(exception)
  261. 261 : }
  262. 262 : }
  263. 263 : };
  264. 264 : try {
  265. 265 : _this.withContext(invocation_context, live_mode, api_end_point);
  266. 266 : var handler = new RetrieveFundingAccountsPageHandler();
  267. 267 : if (callback && CommonUtil.isFunction(callback)) {
  268. 268 : return handler.process(_this, internalCallback);
  269. 269 : } else {
  270. 270 : return handler.process(_this);
  271. 271 : }
  272. 272 : }
  273. 273 : catch (e){
  274. 274 : var error = OrbipayApiError.getDefaultException(e);
  275. 275 : if (callback) {
  276. 276 : callback(error)
  277. 277 : }
  278. 278 : }
  279. 279 : };
  280. 280 :
  281. 281 : return exports;
  282. 282 :
  283. 283 : }));