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