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/RetrieveCustomersHandler')
  9. 9 : , require('../handlers/RetrieveCustomersPageHandler'), require('../OrbipayApiError'));
  10. 10 : }
  11. 11 : }(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveCustomersHandler, RetrieveCustomersPageHandler, OrbipayApiError) {
  12. 12 : 'use strict';
  13. 13 :
  14. 14 : /**
  15. 15 : * The Customers wrapper module.
  16. 16 : * @module wrappers/Customers
  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 Customer = require('./Customer');
  26. 26 : obj['list'] = ApiClient.convertToType(data['list'], [Customer]);
  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('page_size')) {
  47. 47 : obj['page_size'] = data['page_size'];
  48. 48 : }
  49. 49 : if (data.hasOwnProperty('customer_reference')) {
  50. 50 : obj['customer_reference'] = data['customer_reference'];
  51. 51 : }
  52. 52 : if (data.hasOwnProperty('ssn')) {
  53. 53 : obj['ssn'] = data['ssn'];
  54. 54 : }
  55. 55 : if (data.hasOwnProperty('email')) {
  56. 56 : obj['email'] = data['email'];
  57. 57 : }
  58. 58 : if (data.hasOwnProperty('account_number')) {
  59. 59 : obj['account_number'] = data['account_number'];
  60. 60 : }
  61. 61 : }
  62. 62 : return obj;
  63. 63 : };
  64. 64 :
  65. 65 :
  66. 66 : exports.prototype = Object.create(Base.prototype);
  67. 67 : exports.prototype.constructor = exports;
  68. 68 :
  69. 69 : /**
  70. 70 : * @member [Customer] list
  71. 71 : */
  72. 72 : exports.prototype['list'] = undefined;
  73. 73 : /**
  74. 74 : * The total number of customers available matching the search criteria.
  75. 75 : * @member {String} total_results_count
  76. 76 : */
  77. 77 : exports.prototype['total_results_count'] = undefined;
  78. 78 : /**
  79. 79 : * true if there are more results or pages
  80. 80 : * @member {String} has_more_results
  81. 81 : */
  82. 82 : exports.prototype['has_more_results'] = undefined;
  83. 83 : /**
  84. 84 : * This URL fetches the next or previous set of payments, based on the presence of after_object or before_object parameter.
  85. 85 : * @member {String} url
  86. 86 : */
  87. 87 : exports.prototype['url'] = undefined;
  88. 88 : /**
  89. 89 : * The id of the object before which the previous set of objects are to be retrieved.
  90. 90 : * @member {String} from_index
  91. 91 : */
  92. 92 : exports.prototype['from_index'] = undefined;
  93. 93 : /**
  94. 94 : * The id of the object after which the next set of objects are to be retrieved.
  95. 95 : * @member {String} to_index
  96. 96 : */
  97. 97 : exports.prototype['to_index'] = undefined;
  98. 98 : /**
  99. 99 : * The query id of the object.
  100. 100 : * @member {String} query_id
  101. 101 : */
  102. 102 : exports.prototype['query_id'] = undefined;
  103. 103 : /**
  104. 104 : * The maximum number of objects returned in the query.
  105. 105 : * @member {String} page_size
  106. 106 : */
  107. 107 : exports.prototype['page_size'] = undefined;
  108. 108 : /**
  109. 109 : * Unique ID assigned by the biller/client system for a given customer.
  110. 110 : * @member {String} customer_reference
  111. 111 : */
  112. 112 : exports.prototype['customer_reference'] = undefined;
  113. 113 : /**
  114. 114 : * The SSN of the customer if the account holder is an individual or the tax ID, if the customer is a business.
  115. 115 : * @member {String} ssn
  116. 116 : */
  117. 117 : exports.prototype['ssn'] = undefined;
  118. 118 : /**
  119. 119 : * This field contains the customer’s email address within EBPP.
  120. 120 : * @member {String} email
  121. 121 : */
  122. 122 : exports.prototype['email'] = undefined;
  123. 123 : /**
  124. 124 : * Customer Account Number of the customer to get details of.
  125. 125 : * @member {String} account_number
  126. 126 : */
  127. 127 : exports.prototype['account_number'] = undefined;
  128. 128 :
  129. 129 : /**
  130. 130 : * @param {String} client_key - The client_key of Customers.
  131. 131 : * @return {module:wrappers/Customers} The instance of <code>Customers</code>.
  132. 132 : */
  133. 133 : exports.prototype.forClient = function (client_key) {
  134. 134 : var _this = this;
  135. 135 : Base.prototype.forClient.call(_this,client_key);
  136. 136 : return _this;
  137. 137 : };
  138. 138 : /**
  139. 139 : * @param {String} channel - The channel of Customers.
  140. 140 : * @return {module:wrappers/Customers} The instance of <code>Customers</code>.
  141. 141 : */
  142. 142 : exports.prototype.videChannel = function (channel) {
  143. 143 : var _this = this;
  144. 144 : Base.prototype.videChannel.call(_this,channel);
  145. 145 : return _this;
  146. 146 : };
  147. 147 : /**
  148. 148 : * @param {String} customer_reference - The customer_reference of Customers.
  149. 149 : * @param {String} ssn - The ssn of Customers.
  150. 150 : * @param {String} email - The email of Customers.
  151. 151 : * @param {String} account_number - The account_number of Customers.
  152. 152 : * @param {String} page_size - The page_size of Customers.
  153. 153 : * @param {String} query_id - The query_id of Customers.
  154. 154 : * @param {String} from_index - The from_index of Customers.
  155. 155 : * @param {String} to_index - The to_index of Customers.
  156. 156 : * @return {module:wrappers/Customers} The instance of <code>Customers</code>.
  157. 157 : */
  158. 158 : exports.prototype.findBy = function (filterParameters) {
  159. 159 : var _this = this;
  160. 160 : if(filterParameters){
  161. 161 :
  162. 162 : _this['customer_reference'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'customer_reference', false);
  163. 163 :
  164. 164 : _this['ssn'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'ssn', false);
  165. 165 :
  166. 166 : _this['email'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'email', false);
  167. 167 :
  168. 168 : _this['account_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_number', false);
  169. 169 :
  170. 170 : _this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
  171. 171 :
  172. 172 : _this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
  173. 173 :
  174. 174 : _this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
  175. 175 :
  176. 176 : _this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
  177. 177 : }
  178. 178 : return _this;
  179. 179 : };
  180. 180 :
  181. 181 : exports.prototype.retrievedBy = function (requestor, requestor_type) {
  182. 182 : var _this = this;
  183. 183 : _this.requestedBy(requestor, requestor_type);
  184. 184 : return _this;
  185. 185 : };
  186. 186 :
  187. 187 : exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
  188. 188 : var _this = this;
  189. 189 : var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
  190. 190 : try {
  191. 191 : var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
  192. 192 : if (callback) {
  193. 193 : callback(response['exception'], response['data'])
  194. 194 : }
  195. 195 : } catch (e) {
  196. 196 : exception = OrbipayApiError.getDefaultException(e);
  197. 197 : if (callback) {
  198. 198 : callback(exception)
  199. 199 : }
  200. 200 : }
  201. 201 : };
  202. 202 : try {
  203. 203 : _this.withContext(invocation_context, live_mode, api_end_point);
  204. 204 : var handler = new RetrieveCustomersHandler();
  205. 205 : if (callback && CommonUtil.isFunction(callback)) {
  206. 206 : return handler.process(_this, internalCallback);
  207. 207 : } else {
  208. 208 : return handler.process(_this);
  209. 209 : }
  210. 210 : }
  211. 211 : catch (e){
  212. 212 : var error = OrbipayApiError.getDefaultException(e);
  213. 213 : if (callback) {
  214. 214 : callback(error)
  215. 215 : }
  216. 216 : }
  217. 217 : };
  218. 218 : exports.prototype.getPage = 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 RetrieveCustomersPageHandler();
  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 :
  250. 250 : return exports;
  251. 251 :
  252. 252 : }));