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