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/GetCustomerAccountHandler')
  9. 9 : , require('../handlers/RenewCustomerAccountHandler'), require('../OrbipayApiError'));
  10. 10 : }
  11. 11 : }(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, GetCustomerAccountHandler, RenewCustomerAccountHandler, OrbipayApiError) {
  12. 12 : 'use strict';
  13. 13 :
  14. 14 : /**
  15. 15 : * The CustomerAccount wrapper module.
  16. 16 : * @module wrappers/CustomerAccount
  17. 17 : */
  18. 18 : var exports = function(id_customer_account) {
  19. 19 : var _this = this;
  20. 20 : Base.call(_this);
  21. 21 : _this['ID_CUSTOMER_ACCOUNT'] = id_customer_account;
  22. 22 : _this.id = id_customer_account;
  23. 23 : };
  24. 24 :
  25. 25 : /**
  26. 26 : * Constructs a <code>CustomerAccount</code> from a plain JavaScript object, optionally creating a new instance.
  27. 27 : * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
  28. 28 : * @param {Object} data The plain JavaScript object bearing properties of interest.
  29. 29 : * @param {module:wrappers/CustomerAccount} obj Optional instance to populate.
  30. 30 : * @return {module:wrappers/CustomerAccount} The populated <code>CustomerAccount</code> instance.
  31. 31 : */
  32. 32 : exports.constructFromObject = function (data, obj) {
  33. 33 : if (data) {
  34. 34 : obj = obj || new exports();
  35. 35 : if (data.hasOwnProperty('account_holder_name')) {
  36. 36 : obj['account_holder_name'] = data['account_holder_name'];
  37. 37 : }
  38. 38 : if (data.hasOwnProperty('nickname')) {
  39. 39 : obj['nickname'] = data['nickname'];
  40. 40 : }
  41. 41 : if (data.hasOwnProperty('address')) {
  42. 42 : var Address = require('./Address');
  43. 43 : obj['address'] = Address.constructFromObject(data['address']);
  44. 44 : }
  45. 45 : if (data.hasOwnProperty('customer_account_reference')) {
  46. 46 : obj['customer_account_reference'] = data['customer_account_reference'];
  47. 47 : }
  48. 48 : if (data.hasOwnProperty('account_number')) {
  49. 49 : obj['account_number'] = data['account_number'];
  50. 50 : }
  51. 51 : if (data.hasOwnProperty('current_balance')) {
  52. 52 : obj['current_balance'] = data['current_balance'];
  53. 53 : }
  54. 54 : if (data.hasOwnProperty('current_statement_balance')) {
  55. 55 : obj['current_statement_balance'] = data['current_statement_balance'];
  56. 56 : }
  57. 57 : if (data.hasOwnProperty('minimum_payment_due')) {
  58. 58 : obj['minimum_payment_due'] = data['minimum_payment_due'];
  59. 59 : }
  60. 60 : if (data.hasOwnProperty('past_amount_due')) {
  61. 61 : obj['past_amount_due'] = data['past_amount_due'];
  62. 62 : }
  63. 63 : if (data.hasOwnProperty('payment_due_date')) {
  64. 64 : obj['payment_due_date'] = data['payment_due_date'];
  65. 65 : }
  66. 66 : if (data.hasOwnProperty('statement_date')) {
  67. 67 : obj['statement_date'] = data['statement_date'];
  68. 68 : }
  69. 69 : if (data.hasOwnProperty('payoff_amount')) {
  70. 70 : obj['payoff_amount'] = data['payoff_amount'];
  71. 71 : }
  72. 72 : if (data.hasOwnProperty('payoff_expiry_date')) {
  73. 73 : obj['payoff_expiry_date'] = data['payoff_expiry_date'];
  74. 74 : }
  75. 75 : if (data.hasOwnProperty('id')) {
  76. 76 : obj['id'] = data['id'];
  77. 77 : }
  78. 78 : if (data.hasOwnProperty('url')) {
  79. 79 : obj['url'] = data['url'];
  80. 80 : }
  81. 81 : if (data.hasOwnProperty('status')) {
  82. 82 : obj['status'] = data['status'];
  83. 83 : }
  84. 84 : if (data.hasOwnProperty('custom_fields')) {
  85. 85 : obj['custom_fields'] = data['custom_fields'];
  86. 86 : }
  87. 87 : if (data.hasOwnProperty('comments')) {
  88. 88 : obj['comments'] = data['comments'];
  89. 89 : }
  90. 90 : if (data.hasOwnProperty('audit_info')) {
  91. 91 : var AuditInfo = require('./AuditInfo');
  92. 92 : obj['audit_info'] = AuditInfo.constructFromObject(data['audit_info']);
  93. 93 : }
  94. 94 : if (data.hasOwnProperty('ID_CUSTOMER_ACCOUNT')) {
  95. 95 : obj['ID_CUSTOMER_ACCOUNT'] = data['ID_CUSTOMER_ACCOUNT'];
  96. 96 : }
  97. 97 : if (data.hasOwnProperty('ID_CUSTOMER')) {
  98. 98 : obj['ID_CUSTOMER'] = data['ID_CUSTOMER'];
  99. 99 : }
  100. 100 : }
  101. 101 : return obj;
  102. 102 : };
  103. 103 :
  104. 104 :
  105. 105 : exports.prototype = Object.create(Base.prototype);
  106. 106 : exports.prototype.constructor = exports;
  107. 107 :
  108. 108 : /**
  109. 109 : * The name as specified on the account.
  110. 110 : * @member {String} account_holder_name
  111. 111 : */
  112. 112 : exports.prototype['account_holder_name'] = undefined;
  113. 113 : /**
  114. 114 : * The nickname by which a customer might want to identify the account.
  115. 115 : * @member {String} nickname
  116. 116 : */
  117. 117 : exports.prototype['nickname'] = undefined;
  118. 118 : /**
  119. 119 : * @member {Address} address
  120. 120 : */
  121. 121 : exports.prototype['address'] = undefined;
  122. 122 : /**
  123. 123 : * The unique identifier in the client system for the customer account.
  124. 124 : * @member {String} customer_account_reference
  125. 125 : */
  126. 126 : exports.prototype['customer_account_reference'] = undefined;
  127. 127 : /**
  128. 128 : * The number or reference that a customer uses to identify the customer's account.
  129. 129 : * @member {String} account_number
  130. 130 : */
  131. 131 : exports.prototype['account_number'] = undefined;
  132. 132 : /**
  133. 133 : * The current balance on the customer's account with the biller.
  134. 134 : * @member {String} current_balance
  135. 135 : */
  136. 136 : exports.prototype['current_balance'] = undefined;
  137. 137 : /**
  138. 138 : * The balance on the customer’s account with the biller as reported on the last statement.
  139. 139 : * @member {String} current_statement_balance
  140. 140 : */
  141. 141 : exports.prototype['current_statement_balance'] = undefined;
  142. 142 : /**
  143. 143 : * The minimum payment amount, as specified by the biller, that needs to be made against the customer’s account.
  144. 144 : * @member {String} minimum_payment_due
  145. 145 : */
  146. 146 : exports.prototype['minimum_payment_due'] = undefined;
  147. 147 : /**
  148. 148 : * The amount that is due from the past bills/statements on the customer’s account with the biller.
  149. 149 : * @member {String} past_amount_due
  150. 150 : */
  151. 151 : exports.prototype['past_amount_due'] = undefined;
  152. 152 : /**
  153. 153 : * The date by which the customer needs to clear the dues against the customer's account with the biller. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  154. 154 : * @member {String} payment_due_date
  155. 155 : */
  156. 156 : exports.prototype['payment_due_date'] = undefined;
  157. 157 : /**
  158. 158 : * The date on which the biller generates the statement for the customer's account. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  159. 159 : * @member {String} statement_date
  160. 160 : */
  161. 161 : exports.prototype['statement_date'] = undefined;
  162. 162 : /**
  163. 163 : * This field contains the computed current loan payoff amount at the time of inquiry for the customer’s account with the biller.
  164. 164 : * @member {String} payoff_amount
  165. 165 : */
  166. 166 : exports.prototype['payoff_amount'] = undefined;
  167. 167 : /**
  168. 168 : * The date till the payoff_amount is valid for the customer’s account with the biller. It must be in ISO8601 full-date format, namely, YYYY-MM-DD.
  169. 169 : * @member {String} payoff_expiry_date
  170. 170 : */
  171. 171 : exports.prototype['payoff_expiry_date'] = undefined;
  172. 172 : /**
  173. 173 : * Id is a unique identifier assigned to the customer account in EBPP.
  174. 174 : * @member {String} id
  175. 175 : */
  176. 176 : exports.prototype['id'] = undefined;
  177. 177 : /**
  178. 178 : * This URL fetches the Account details.
  179. 179 : * @member {String} url
  180. 180 : */
  181. 181 : exports.prototype['url'] = undefined;
  182. 182 : /**
  183. 183 : * The status of the customer's account in EBPP.
  184. 184 : * @member {String} status
  185. 185 : */
  186. 186 : exports.prototype['status'] = undefined;
  187. 187 : /**
  188. 188 : * The additional information or meta-information that EBPP can accept, maintain and transmit back to the client. The custom fields need to be configured with EBPP before they can be accepted. EBPP would reject custom fields that are not pre-configured. Please contact <a href = \"mailto: support@billerpayments.com\">support@billerpayments.com</a> for more information on configuring and using custom fields. Only the custom fields enabled for the client, in EBPP, would be accepted in the requests.
  189. 189 : * @member {{String: String}} custom_fields
  190. 190 : */
  191. 191 : exports.prototype['custom_fields'] = undefined;
  192. 192 : /**
  193. 193 : * Comments that can be used to recollect the operation performed on the resource object. API clients need to ensure that no sensitive information is passed in the memo. Alacriti (EBPP) is not responsible for the security of any sensitive information that may be passed as part of the memo.
  194. 194 : * @member {String} comments
  195. 195 : */
  196. 196 : exports.prototype['comments'] = undefined;
  197. 197 : /**
  198. 198 : * @member {AuditInfo} audit_info
  199. 199 : */
  200. 200 : exports.prototype['audit_info'] = undefined;
  201. 201 : /**
  202. 202 : * The unique identifier assigned by EBPP to the Customer Account.
  203. 203 : * @member {String} ID_CUSTOMER_ACCOUNT
  204. 204 : */
  205. 205 : exports.prototype['ID_CUSTOMER_ACCOUNT'] = undefined;
  206. 206 : /**
  207. 207 : * The unique identifier assigned by EBPP to the customer.
  208. 208 : * @member {String} ID_CUSTOMER
  209. 209 : */
  210. 210 : exports.prototype['ID_CUSTOMER'] = undefined;
  211. 211 :
  212. 212 : /**
  213. 213 : * @param {String} client_key - The client_key of CustomerAccount.
  214. 214 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  215. 215 : */
  216. 216 : exports.prototype.forClient = function (client_key) {
  217. 217 : var _this = this;
  218. 218 : Base.prototype.forClient.call(_this,client_key);
  219. 219 : return _this;
  220. 220 : };
  221. 221 : /**
  222. 222 : * @param {String} channel - The channel of CustomerAccount.
  223. 223 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  224. 224 : */
  225. 225 : exports.prototype.videChannel = function (channel) {
  226. 226 : var _this = this;
  227. 227 : Base.prototype.videChannel.call(_this,channel);
  228. 228 : return _this;
  229. 229 : };
  230. 230 : /**
  231. 231 : * @param {String} account_holder_name - The account_holder_name of CustomerAccount.
  232. 232 : * @param {String} nickname - The nickname of CustomerAccount.
  233. 233 : * @param {String} account_number - The account_number of CustomerAccount.
  234. 234 : * @param {String} minimum_payment_due - The minimum_payment_due of CustomerAccount.
  235. 235 : * @param {String} past_amount_due - The past_amount_due of CustomerAccount.
  236. 236 : * @param {String} payment_due_date - The payment_due_date of CustomerAccount.
  237. 237 : * @param {String} statement_date - The statement_date of CustomerAccount.
  238. 238 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  239. 239 : */
  240. 240 : exports.prototype.withDetails = function (account_holder_name, nickname, account_number, minimum_payment_due, past_amount_due, payment_due_date, statement_date) {
  241. 241 : var _this = this;
  242. 242 :
  243. 243 : _this['account_holder_name'] = account_holder_name;
  244. 244 :
  245. 245 : _this['nickname'] = nickname;
  246. 246 :
  247. 247 : _this['account_number'] = account_number;
  248. 248 :
  249. 249 : _this['minimum_payment_due'] = minimum_payment_due;
  250. 250 :
  251. 251 : _this['past_amount_due'] = past_amount_due;
  252. 252 :
  253. 253 : _this['payment_due_date'] = payment_due_date;
  254. 254 :
  255. 255 : _this['statement_date'] = statement_date;
  256. 256 :
  257. 257 :
  258. 258 : return _this;
  259. 259 : };
  260. 260 : /**
  261. 261 : * @param {String} payoff_amount - The payoff_amount of CustomerAccount.
  262. 262 : * @param {String} payoff_expiry_date - The payoff_expiry_date of CustomerAccount.
  263. 263 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  264. 264 : */
  265. 265 : exports.prototype.withPayoffDetails = function (payoff_amount, payoff_expiry_date) {
  266. 266 : var _this = this;
  267. 267 :
  268. 268 : _this['payoff_amount'] = payoff_amount;
  269. 269 :
  270. 270 : _this['payoff_expiry_date'] = payoff_expiry_date;
  271. 271 :
  272. 272 :
  273. 273 : return _this;
  274. 274 : };
  275. 275 : /**
  276. 276 : * @param {String} current_balance - The current_balance of CustomerAccount.
  277. 277 : * @param {String} current_statement_balance - The current_statement_balance of CustomerAccount.
  278. 278 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  279. 279 : */
  280. 280 : exports.prototype.withBalances = function (current_balance, current_statement_balance) {
  281. 281 : var _this = this;
  282. 282 :
  283. 283 : _this['current_balance'] = current_balance;
  284. 284 :
  285. 285 : _this['current_statement_balance'] = current_statement_balance;
  286. 286 :
  287. 287 :
  288. 288 : return _this;
  289. 289 : };
  290. 290 : /**
  291. 291 : * @param {String} customer_account_reference - The customer_account_reference of CustomerAccount.
  292. 292 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  293. 293 : */
  294. 294 : exports.prototype.withReference = function (customer_account_reference) {
  295. 295 : var _this = this;
  296. 296 :
  297. 297 : _this['customer_account_reference'] = customer_account_reference;
  298. 298 :
  299. 299 :
  300. 300 : return _this;
  301. 301 : };
  302. 302 : /**
  303. 303 : * @param {String} status - The status of CustomerAccount.
  304. 304 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  305. 305 : */
  306. 306 : exports.prototype.withStatus = function (status) {
  307. 307 : var _this = this;
  308. 308 :
  309. 309 : _this['status'] = status;
  310. 310 :
  311. 311 :
  312. 312 : return _this;
  313. 313 : };
  314. 314 : /**
  315. 315 : * @param {Address} address - The address of CustomerAccount.
  316. 316 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  317. 317 : */
  318. 318 : exports.prototype.withAddress = function (address) {
  319. 319 : var _this = this;
  320. 320 :
  321. 321 : _this['address'] = address;
  322. 322 :
  323. 323 :
  324. 324 : return _this;
  325. 325 : };
  326. 326 : /**
  327. 327 : * @param {{String: String}} custom_fields - The custom_fields of CustomerAccount.
  328. 328 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  329. 329 : */
  330. 330 : exports.prototype.withCustomFields = function (custom_fields) {
  331. 331 : var _this = this;
  332. 332 :
  333. 333 : _this['custom_fields'] = custom_fields;
  334. 334 :
  335. 335 :
  336. 336 : return _this;
  337. 337 : };
  338. 338 : /**
  339. 339 : * @param {String} comments - The comments of CustomerAccount.
  340. 340 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  341. 341 : */
  342. 342 : exports.prototype.withMemo = function (comments) {
  343. 343 : var _this = this;
  344. 344 :
  345. 345 : _this['comments'] = comments;
  346. 346 :
  347. 347 :
  348. 348 : return _this;
  349. 349 : };
  350. 350 : /**
  351. 351 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of CustomerAccount.
  352. 352 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  353. 353 : */
  354. 354 : exports.prototype.forCustomer = function (id_customer) {
  355. 355 : var _this = this;
  356. 356 :
  357. 357 : _this['ID_CUSTOMER'] = id_customer;
  358. 358 :
  359. 359 :
  360. 360 : return _this;
  361. 361 : };
  362. 362 :
  363. 363 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  364. 364 : var _this = this;
  365. 365 : _this.requestedBy(requestor, requestor_type);
  366. 366 : return _this;
  367. 367 : };
  368. 368 : exports.prototype.renewedBy = function (requestor, requestor_type) {
  369. 369 : var _this = this;
  370. 370 : _this.requestedBy(requestor, requestor_type);
  371. 371 : return _this;
  372. 372 : };
  373. 373 :
  374. 374 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  375. 375 : var _this = this;
  376. 376 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  377. 377 : try {
  378. 378 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  379. 379 : if (callback) {
  380. 380 : callback(response['exception'], response['data'])
  381. 381 : }
  382. 382 : } catch (e) {
  383. 383 : exception = OrbipayApiError.getDefaultException(e);
  384. 384 : if (callback) {
  385. 385 : callback(exception)
  386. 386 : }
  387. 387 : }
  388. 388 : };
  389. 389 : try {
  390. 390 : _this.withContext(invocation_context, live_mode, api_end_point);
  391. 391 : var handler = new GetCustomerAccountHandler();
  392. 392 : if (callback && CommonUtil.isFunction(callback)) {
  393. 393 : return handler.process(_this, internalCallback);
  394. 394 : } else {
  395. 395 : return handler.process(_this);
  396. 396 : }
  397. 397 : }
  398. 398 : catch (e){
  399. 399 : var error = OrbipayApiError.getDefaultException(e);
  400. 400 : if (callback) {
  401. 401 : callback(error)
  402. 402 : }
  403. 403 : }
  404. 404 : };
  405. 405 : exports.prototype.renew = function (invocation_context, callback, live_mode, api_end_point) {
  406. 406 : var _this = this;
  407. 407 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  408. 408 : try {
  409. 409 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  410. 410 : if (callback) {
  411. 411 : callback(response['exception'], response['data'])
  412. 412 : }
  413. 413 : } catch (e) {
  414. 414 : exception = OrbipayApiError.getDefaultException(e);
  415. 415 : if (callback) {
  416. 416 : callback(exception)
  417. 417 : }
  418. 418 : }
  419. 419 : };
  420. 420 : try {
  421. 421 : _this.withContext(invocation_context, live_mode, api_end_point);
  422. 422 : var handler = new RenewCustomerAccountHandler();
  423. 423 : if (callback && CommonUtil.isFunction(callback)) {
  424. 424 : return handler.process(_this, internalCallback);
  425. 425 : } else {
  426. 426 : return handler.process(_this);
  427. 427 : }
  428. 428 : }
  429. 429 : catch (e){
  430. 430 : var error = OrbipayApiError.getDefaultException(e);
  431. 431 : if (callback) {
  432. 432 : callback(error)
  433. 433 : }
  434. 434 : }
  435. 435 : };
  436. 436 :
  437. 437 : return exports;
  438. 438 :
  439. 439 : }));