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/RetrieveCustomerAccountsHandler')
  9. 9 : , require('../handlers/RetrieveCustomerAccountsPageHandler'), require('../OrbipayApiError'));
  10. 10 : }
  11. 11 : }(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveCustomerAccountsHandler, RetrieveCustomerAccountsPageHandler, OrbipayApiError) {
  12. 12 : 'use strict';
  13. 13 :
  14. 14 : /**
  15. 15 : * The CustomerAccounts wrapper module.
  16. 16 : * @module wrappers/CustomerAccounts
  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 CustomerAccount = require('./CustomerAccount');
  26. 26 : obj['list'] = ApiClient.convertToType(data['list'], [CustomerAccount]);
  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 : }
  59. 59 : return obj;
  60. 60 : };
  61. 61 :
  62. 62 :
  63. 63 : exports.prototype = Object.create(Base.prototype);
  64. 64 : exports.prototype.constructor = exports;
  65. 65 :
  66. 66 : /**
  67. 67 : * @member [CustomerAccount] list
  68. 68 : */
  69. 69 : exports.prototype['list'] = undefined;
  70. 70 : /**
  71. 71 : * total number of Customer accounts of customer available with matching criteria
  72. 72 : * @member {String} total_results_count
  73. 73 : */
  74. 74 : exports.prototype['total_results_count'] = undefined;
  75. 75 : /**
  76. 76 : * true if there are more results or pages
  77. 77 : * @member {String} has_more_results
  78. 78 : */
  79. 79 : exports.prototype['has_more_results'] = undefined;
  80. 80 : /**
  81. 81 : * This URL fetches the next or previous set of customer accounts, based on the presence of after_object or before_object parameter.
  82. 82 : * @member {String} url
  83. 83 : */
  84. 84 : exports.prototype['url'] = undefined;
  85. 85 : /**
  86. 86 : * The id of the object before which the previous set of objects are to be retrieved.
  87. 87 : * @member {String} from_index
  88. 88 : */
  89. 89 : exports.prototype['from_index'] = undefined;
  90. 90 : /**
  91. 91 : * The id of the object after which the next set of objects are to be retrieved.
  92. 92 : * @member {String} to_index
  93. 93 : */
  94. 94 : exports.prototype['to_index'] = undefined;
  95. 95 : /**
  96. 96 : * The query id of the object.
  97. 97 : * @member {String} query_id
  98. 98 : */
  99. 99 : exports.prototype['query_id'] = undefined;
  100. 100 : /**
  101. 101 : * The unique identifier assigned by EBPP to the customer.
  102. 102 : * @member {String} ID_CUSTOMER
  103. 103 : */
  104. 104 : exports.prototype['ID_CUSTOMER'] = undefined;
  105. 105 : /**
  106. 106 : * The maximum number of objects returned in the query.
  107. 107 : * @member {String} page_size
  108. 108 : */
  109. 109 : exports.prototype['page_size'] = undefined;
  110. 110 : /**
  111. 111 : * The Account Number to get details of.
  112. 112 : * @member {String} account_number
  113. 113 : */
  114. 114 : exports.prototype['account_number'] = undefined;
  115. 115 : /**
  116. 116 : * The status of the customer's account in EBPP. This can take multiple values in the format key=value1&key=value2....
  117. 117 : * @member [String] status
  118. 118 : */
  119. 119 : exports.prototype['status'] = undefined;
  120. 120 :
  121. 121 : /**
  122. 122 : * @param {String} client_key - The client_key of CustomerAccounts.
  123. 123 : * @return {module:wrappers/CustomerAccounts} The instance of <code>CustomerAccounts</code>.
  124. 124 : */
  125. 125 : exports.prototype.forClient = function (client_key) {
  126. 126 : var _this = this;
  127. 127 : Base.prototype.forClient.call(_this,client_key);
  128. 128 : return _this;
  129. 129 : };
  130. 130 : /**
  131. 131 : * @param [CustomerAccount] list - The list of CustomerAccounts.
  132. 132 : * @return {module:wrappers/CustomerAccounts} The instance of <code>CustomerAccounts</code>.
  133. 133 : */
  134. 134 : exports.prototype.setList = function (list) {
  135. 135 : var _this = this;
  136. 136 :
  137. 137 : _this['list'] = list;
  138. 138 :
  139. 139 :
  140. 140 : return _this;
  141. 141 : };
  142. 142 : /**
  143. 143 : * @param {String} channel - The channel of CustomerAccounts.
  144. 144 : * @return {module:wrappers/CustomerAccounts} The instance of <code>CustomerAccounts</code>.
  145. 145 : */
  146. 146 : exports.prototype.videChannel = function (channel) {
  147. 147 : var _this = this;
  148. 148 : Base.prototype.videChannel.call(_this,channel);
  149. 149 : return _this;
  150. 150 : };
  151. 151 : /**
  152. 152 : * @param {String} account_number - The account_number of CustomerAccounts.
  153. 153 : * @param [String] status - The status of CustomerAccounts.
  154. 154 : * @param {String} page_size - The page_size of CustomerAccounts.
  155. 155 : * @param {String} query_id - The query_id of CustomerAccounts.
  156. 156 : * @param {String} from_index - The from_index of CustomerAccounts.
  157. 157 : * @param {String} to_index - The to_index of CustomerAccounts.
  158. 158 : * @return {module:wrappers/CustomerAccounts} The instance of <code>CustomerAccounts</code>.
  159. 159 : */
  160. 160 : exports.prototype.findBy = function (filterParameters) {
  161. 161 : var _this = this;
  162. 162 : if(filterParameters){
  163. 163 :
  164. 164 : _this['account_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_number', false);
  165. 165 : _this['status'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'status', true);
  166. 166 :
  167. 167 :
  168. 168 : _this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
  169. 169 :
  170. 170 : _this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
  171. 171 :
  172. 172 : _this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
  173. 173 :
  174. 174 : _this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
  175. 175 : }
  176. 176 : return _this;
  177. 177 : };
  178. 178 : /**
  179. 179 : * @param {String} ID_CUSTOMER - The ID_CUSTOMER of CustomerAccounts.
  180. 180 : * @return {module:wrappers/CustomerAccounts} The instance of <code>CustomerAccounts</code>.
  181. 181 : */
  182. 182 : exports.prototype.forCustomer = function (id_customer) {
  183. 183 : var _this = this;
  184. 184 :
  185. 185 : _this['ID_CUSTOMER'] = id_customer;
  186. 186 :
  187. 187 :
  188. 188 : return _this;
  189. 189 : };
  190. 190 :
  191. 191 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  192. 192 : var _this = this;
  193. 193 : _this.requestedBy(requestor, requestor_type);
  194. 194 : return _this;
  195. 195 : };
  196. 196 :
  197. 197 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  198. 198 : var _this = this;
  199. 199 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  200. 200 : try {
  201. 201 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  202. 202 : if (callback) {
  203. 203 : callback(response['exception'], response['data'])
  204. 204 : }
  205. 205 : } catch (e) {
  206. 206 : exception = OrbipayApiError.getDefaultException(e);
  207. 207 : if (callback) {
  208. 208 : callback(exception)
  209. 209 : }
  210. 210 : }
  211. 211 : };
  212. 212 : try {
  213. 213 : _this.withContext(invocation_context, live_mode, api_end_point);
  214. 214 : var handler = new RetrieveCustomerAccountsHandler();
  215. 215 : if (callback && CommonUtil.isFunction(callback)) {
  216. 216 : return handler.process(_this, internalCallback);
  217. 217 : } else {
  218. 218 : return handler.process(_this);
  219. 219 : }
  220. 220 : }
  221. 221 : catch (e){
  222. 222 : var error = OrbipayApiError.getDefaultException(e);
  223. 223 : if (callback) {
  224. 224 : callback(error)
  225. 225 : }
  226. 226 : }
  227. 227 : };
  228. 228 : exports.prototype.getPage = function (invocation_context, callback, live_mode, api_end_point) {
  229. 229 : var _this = this;
  230. 230 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  231. 231 : try {
  232. 232 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  233. 233 : if (callback) {
  234. 234 : callback(response['exception'], response['data'])
  235. 235 : }
  236. 236 : } catch (e) {
  237. 237 : exception = OrbipayApiError.getDefaultException(e);
  238. 238 : if (callback) {
  239. 239 : callback(exception)
  240. 240 : }
  241. 241 : }
  242. 242 : };
  243. 243 : try {
  244. 244 : _this.withContext(invocation_context, live_mode, api_end_point);
  245. 245 : var handler = new RetrieveCustomerAccountsPageHandler();
  246. 246 : if (callback && CommonUtil.isFunction(callback)) {
  247. 247 : return handler.process(_this, internalCallback);
  248. 248 : } else {
  249. 249 : return handler.process(_this);
  250. 250 : }
  251. 251 : }
  252. 252 : catch (e){
  253. 253 : var error = OrbipayApiError.getDefaultException(e);
  254. 254 : if (callback) {
  255. 255 : callback(error)
  256. 256 : }
  257. 257 : }
  258. 258 : };
  259. 259 :
  260. 260 : return exports;
  261. 261 :
  262. 262 : }));