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('id')) {
  70. 70 : obj['id'] = data['id'];
  71. 71 : }
  72. 72 : if (data.hasOwnProperty('url')) {
  73. 73 : obj['url'] = data['url'];
  74. 74 : }
  75. 75 : if (data.hasOwnProperty('status')) {
  76. 76 : obj['status'] = data['status'];
  77. 77 : }
  78. 78 : if (data.hasOwnProperty('custom_fields')) {
  79. 79 : obj['custom_fields'] = data['custom_fields'];
  80. 80 : }
  81. 81 : if (data.hasOwnProperty('comments')) {
  82. 82 : obj['comments'] = data['comments'];
  83. 83 : }
  84. 84 : if (data.hasOwnProperty('audit_info')) {
  85. 85 : var AuditInfo = require('./AuditInfo');
  86. 86 : obj['audit_info'] = AuditInfo.constructFromObject(data['audit_info']);
  87. 87 : }
  88. 88 : if (data.hasOwnProperty('ID_CUSTOMER_ACCOUNT')) {
  89. 89 : obj['ID_CUSTOMER_ACCOUNT'] = data['ID_CUSTOMER_ACCOUNT'];
  90. 90 : }
  91. 91 : if (data.hasOwnProperty('ID_CUSTOMER')) {
  92. 92 : obj['ID_CUSTOMER'] = data['ID_CUSTOMER'];
  93. 93 : }
  94. 94 : }
  95. 95 : return obj;
  96. 96 : };
  97. 97 :
  98. 98 :
  99. 99 : exports.prototype = Object.create(Base.prototype);
  100. 100 : exports.prototype.constructor = exports;
  101. 101 :
  102. 102 : /**
  103. 103 : * The name as specified on the account.
  104. 104 : * @member {String} account_holder_name
  105. 105 : */
  106. 106 : exports.prototype['account_holder_name'] = undefined;
  107. 107 : /**
  108. 108 : * The nickname by which a customer might want to identify the account.
  109. 109 : * @member {String} nickname
  110. 110 : */
  111. 111 : exports.prototype['nickname'] = undefined;
  112. 112 : /**
  113. 113 : * @member {Address} address
  114. 114 : */
  115. 115 : exports.prototype['address'] = undefined;
  116. 116 : /**
  117. 117 : * The unique identifier in the client system for the customer account.
  118. 118 : * @member {String} customer_account_reference
  119. 119 : */
  120. 120 : exports.prototype['customer_account_reference'] = undefined;
  121. 121 : /**
  122. 122 : * The number or reference that a customer uses to identify the customer's account.
  123. 123 : * @member {String} account_number
  124. 124 : */
  125. 125 : exports.prototype['account_number'] = undefined;
  126. 126 : /**
  127. 127 : * The current balance on the customer's account with the biller.
  128. 128 : * @member {String} current_balance
  129. 129 : */
  130. 130 : exports.prototype['current_balance'] = undefined;
  131. 131 : /**
  132. 132 : * The balance on the customer’s account with the biller as reported on the last statement.
  133. 133 : * @member {String} current_statement_balance
  134. 134 : */
  135. 135 : exports.prototype['current_statement_balance'] = undefined;
  136. 136 : /**
  137. 137 : * The minimum payment amount, as specified by the biller, that needs to be made against the customer’s account.
  138. 138 : * @member {String} minimum_payment_due
  139. 139 : */
  140. 140 : exports.prototype['minimum_payment_due'] = undefined;
  141. 141 : /**
  142. 142 : * The amount that is due from the past bills/statements on the customer’s account with the biller.
  143. 143 : * @member {String} past_amount_due
  144. 144 : */
  145. 145 : exports.prototype['past_amount_due'] = undefined;
  146. 146 : /**
  147. 147 : * 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.
  148. 148 : * @member {String} payment_due_date
  149. 149 : */
  150. 150 : exports.prototype['payment_due_date'] = undefined;
  151. 151 : /**
  152. 152 : * 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.
  153. 153 : * @member {String} statement_date
  154. 154 : */
  155. 155 : exports.prototype['statement_date'] = undefined;
  156. 156 : /**
  157. 157 : * Id is a unique identifier assigned to the customer account in EBPP.
  158. 158 : * @member {String} id
  159. 159 : */
  160. 160 : exports.prototype['id'] = undefined;
  161. 161 : /**
  162. 162 : * This URL fetches the Account details.
  163. 163 : * @member {String} url
  164. 164 : */
  165. 165 : exports.prototype['url'] = undefined;
  166. 166 : /**
  167. 167 : * The status of the customer's account in EBPP.
  168. 168 : * @member {String} status
  169. 169 : */
  170. 170 : exports.prototype['status'] = undefined;
  171. 171 : /**
  172. 172 : * 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.
  173. 173 : * @member {{String: String}} custom_fields
  174. 174 : */
  175. 175 : exports.prototype['custom_fields'] = undefined;
  176. 176 : /**
  177. 177 : * 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.
  178. 178 : * @member {String} comments
  179. 179 : */
  180. 180 : exports.prototype['comments'] = undefined;
  181. 181 : /**
  182. 182 : * @member {AuditInfo} audit_info
  183. 183 : */
  184. 184 : exports.prototype['audit_info'] = undefined;
  185. 185 : /**
  186. 186 : * The unique identifier assigned by EBPP to the Customer Account.
  187. 187 : * @member {String} ID_CUSTOMER_ACCOUNT
  188. 188 : */
  189. 189 : exports.prototype['ID_CUSTOMER_ACCOUNT'] = undefined;
  190. 190 : /**
  191. 191 : * The unique identifier assigned by EBPP to the customer.
  192. 192 : * @member {String} ID_CUSTOMER
  193. 193 : */
  194. 194 : exports.prototype['ID_CUSTOMER'] = undefined;
  195. 195 :
  196. 196 : /**
  197. 197 : * @param {String} client_key - The client_key of CustomerAccount.
  198. 198 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  199. 199 : */
  200. 200 : exports.prototype.forClient = function (client_key) {
  201. 201 : var _this = this;
  202. 202 : Base.prototype.forClient.call(_this,client_key);
  203. 203 : return _this;
  204. 204 : };
  205. 205 : /**
  206. 206 : * @param {String} channel - The channel of CustomerAccount.
  207. 207 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  208. 208 : */
  209. 209 : exports.prototype.videChannel = function (channel) {
  210. 210 : var _this = this;
  211. 211 : Base.prototype.videChannel.call(_this,channel);
  212. 212 : return _this;
  213. 213 : };
  214. 214 : /**
  215. 215 : * @param {String} account_holder_name - The account_holder_name of CustomerAccount.
  216. 216 : * @param {String} nickname - The nickname of CustomerAccount.
  217. 217 : * @param {String} account_number - The account_number of CustomerAccount.
  218. 218 : * @param {String} minimum_payment_due - The minimum_payment_due of CustomerAccount.
  219. 219 : * @param {String} past_amount_due - The past_amount_due of CustomerAccount.
  220. 220 : * @param {String} payment_due_date - The payment_due_date of CustomerAccount.
  221. 221 : * @param {String} statement_date - The statement_date of CustomerAccount.
  222. 222 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  223. 223 : */
  224. 224 : exports.prototype.withDetails = function (account_holder_name, nickname, account_number, minimum_payment_due, past_amount_due, payment_due_date, statement_date) {
  225. 225 : var _this = this;
  226. 226 :
  227. 227 : _this['account_holder_name'] = account_holder_name;
  228. 228 :
  229. 229 : _this['nickname'] = nickname;
  230. 230 :
  231. 231 : _this['account_number'] = account_number;
  232. 232 :
  233. 233 : _this['minimum_payment_due'] = minimum_payment_due;
  234. 234 :
  235. 235 : _this['past_amount_due'] = past_amount_due;
  236. 236 :
  237. 237 : _this['payment_due_date'] = payment_due_date;
  238. 238 :
  239. 239 : _this['statement_date'] = statement_date;
  240. 240 :
  241. 241 :
  242. 242 : return _this;
  243. 243 : };
  244. 244 : /**
  245. 245 : * @param {String} current_balance - The current_balance of CustomerAccount.
  246. 246 : * @param {String} current_statement_balance - The current_statement_balance of CustomerAccount.
  247. 247 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  248. 248 : */
  249. 249 : exports.prototype.withBalances = function (current_balance, current_statement_balance) {
  250. 250 : var _this = this;
  251. 251 :
  252. 252 : _this['current_balance'] = current_balance;
  253. 253 :
  254. 254 : _this['current_statement_balance'] = current_statement_balance;
  255. 255 :
  256. 256 :
  257. 257 : return _this;
  258. 258 : };
  259. 259 : /**
  260. 260 : * @param {String} customer_account_reference - The customer_account_reference of CustomerAccount.
  261. 261 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  262. 262 : */
  263. 263 : exports.prototype.withReference = function (customer_account_reference) {
  264. 264 : var _this = this;
  265. 265 :
  266. 266 : _this['customer_account_reference'] = customer_account_reference;
  267. 267 :
  268. 268 :
  269. 269 : return _this;
  270. 270 : };
  271. 271 : /**
  272. 272 : * @param {String} status - The status of CustomerAccount.
  273. 273 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  274. 274 : */
  275. 275 : exports.prototype.withStatus = function (status) {
  276. 276 : var _this = this;
  277. 277 :
  278. 278 : _this['status'] = status;
  279. 279 :
  280. 280 :
  281. 281 : return _this;
  282. 282 : };
  283. 283 : /**
  284. 284 : * @param {Address} address - The address of CustomerAccount.
  285. 285 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  286. 286 : */
  287. 287 : exports.prototype.withAddress = function (address) {
  288. 288 : var _this = this;
  289. 289 :
  290. 290 : _this['address'] = address;
  291. 291 :
  292. 292 :
  293. 293 : return _this;
  294. 294 : };
  295. 295 : /**
  296. 296 : * @param {{String: String}} custom_fields - The custom_fields of CustomerAccount.
  297. 297 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  298. 298 : */
  299. 299 : exports.prototype.withCustomFields = function (custom_fields) {
  300. 300 : var _this = this;
  301. 301 :
  302. 302 : _this['custom_fields'] = custom_fields;
  303. 303 :
  304. 304 :
  305. 305 : return _this;
  306. 306 : };
  307. 307 : /**
  308. 308 : * @param {String} comments - The comments of CustomerAccount.
  309. 309 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  310. 310 : */
  311. 311 : exports.prototype.withMemo = function (comments) {
  312. 312 : var _this = this;
  313. 313 :
  314. 314 : _this['comments'] = comments;
  315. 315 :
  316. 316 :
  317. 317 : return _this;
  318. 318 : };
  319. 319 : /**
  320. 320 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of CustomerAccount.
  321. 321 : * @return {module:wrappers/CustomerAccount} The instance of <code>CustomerAccount</code>.
  322. 322 : */
  323. 323 : exports.prototype.forCustomer = function (id_customer) {
  324. 324 : var _this = this;
  325. 325 :
  326. 326 : _this['ID_CUSTOMER'] = id_customer;
  327. 327 :
  328. 328 :
  329. 329 : return _this;
  330. 330 : };
  331. 331 :
  332. 332 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  333. 333 : var _this = this;
  334. 334 : _this.requestedBy(requestor, requestor_type);
  335. 335 : return _this;
  336. 336 : };
  337. 337 : exports.prototype.renewedBy = function (requestor, requestor_type) {
  338. 338 : var _this = this;
  339. 339 : _this.requestedBy(requestor, requestor_type);
  340. 340 : return _this;
  341. 341 : };
  342. 342 :
  343. 343 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  344. 344 : var _this = this;
  345. 345 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  346. 346 : try {
  347. 347 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  348. 348 : if (callback) {
  349. 349 : callback(response['exception'], response['data'])
  350. 350 : }
  351. 351 : } catch (e) {
  352. 352 : exception = OrbipayApiError.getDefaultException(e);
  353. 353 : if (callback) {
  354. 354 : callback(exception)
  355. 355 : }
  356. 356 : }
  357. 357 : };
  358. 358 : try {
  359. 359 : _this.withContext(invocation_context, live_mode, api_end_point);
  360. 360 : var handler = new GetCustomerAccountHandler();
  361. 361 : if (callback && CommonUtil.isFunction(callback)) {
  362. 362 : return handler.process(_this, internalCallback);
  363. 363 : } else {
  364. 364 : return handler.process(_this);
  365. 365 : }
  366. 366 : }
  367. 367 : catch (e){
  368. 368 : var error = OrbipayApiError.getDefaultException(e);
  369. 369 : if (callback) {
  370. 370 : callback(error)
  371. 371 : }
  372. 372 : }
  373. 373 : };
  374. 374 : exports.prototype.renew = 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 RenewCustomerAccountHandler();
  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 :
  406. 406 : return exports;
  407. 407 :
  408. 408 : }));