chargebee 2.40.0 → 3.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/LICENSE +1 -1
  3. package/README.md +90 -172
  4. package/cjs/RequestWrapper.js +81 -0
  5. package/cjs/asyncApiSupport.js +39 -0
  6. package/cjs/chargebee.cjs.js +13 -0
  7. package/cjs/chargebee.cjs.worker.js +9 -0
  8. package/cjs/chargebeeError.js +17 -0
  9. package/cjs/coreCommon.js +72 -0
  10. package/cjs/createChargebee.js +92 -0
  11. package/cjs/environment.js +18 -0
  12. package/cjs/filter.js +1 -0
  13. package/cjs/net/ClientInterface.js +40 -0
  14. package/cjs/net/FetchClient.js +86 -0
  15. package/cjs/net/NodeClient.js +61 -0
  16. package/cjs/package.json +1 -0
  17. package/cjs/resources/api_endpoints.js +1086 -0
  18. package/cjs/util.js +218 -0
  19. package/esm/RequestWrapper.js +77 -0
  20. package/esm/asyncApiSupport.js +35 -0
  21. package/esm/chargebee.esm.js +9 -0
  22. package/esm/chargebee.esm.worker.js +5 -0
  23. package/esm/chargebeeError.js +13 -0
  24. package/esm/coreCommon.js +67 -0
  25. package/esm/createChargebee.js +88 -0
  26. package/esm/environment.js +15 -0
  27. package/esm/filter.js +1 -0
  28. package/esm/net/ClientInterface.js +35 -0
  29. package/esm/net/FetchClient.js +81 -0
  30. package/esm/net/NodeClient.js +56 -0
  31. package/esm/package.json +1 -0
  32. package/esm/resources/api_endpoints.js +1083 -0
  33. package/esm/util.js +202 -0
  34. package/package.json +69 -38
  35. package/types/core.d.ts +558 -89
  36. package/types/index.d.ts +91 -54
  37. package/types/resources/Address.d.ts +57 -272
  38. package/types/resources/AdvanceInvoiceSchedule.d.ts +21 -94
  39. package/types/resources/AttachedItem.d.ts +91 -329
  40. package/types/resources/Attribute.d.ts +5 -5
  41. package/types/resources/BusinessEntity.d.ts +49 -69
  42. package/types/resources/BusinessEntityTransfer.d.ts +11 -17
  43. package/types/resources/Card.d.ts +146 -424
  44. package/types/resources/Comment.d.ts +72 -189
  45. package/types/resources/Contact.d.ts +12 -64
  46. package/types/resources/ContractTerm.d.ts +15 -96
  47. package/types/resources/Coupon.d.ts +282 -758
  48. package/types/resources/CouponCode.d.ts +56 -52
  49. package/types/resources/CouponSet.d.ts +92 -234
  50. package/types/resources/CreditNote.d.ts +588 -1758
  51. package/types/resources/CreditNoteEstimate.d.ts +131 -157
  52. package/types/resources/Currency.d.ts +75 -62
  53. package/types/resources/Customer.d.ts +892 -835
  54. package/types/resources/CustomerEntitlement.d.ts +36 -0
  55. package/types/resources/DifferentialPrice.d.ts +116 -314
  56. package/types/resources/Discount.d.ts +20 -125
  57. package/types/resources/Download.d.ts +6 -22
  58. package/types/resources/Entitlement.d.ts +51 -160
  59. package/types/resources/EntitlementOverride.d.ts +58 -139
  60. package/types/resources/Estimate.d.ts +1178 -527
  61. package/types/resources/Event.d.ts +67 -178
  62. package/types/resources/Export.d.ts +563 -723
  63. package/types/resources/Feature.d.ts +117 -433
  64. package/types/resources/GatewayErrorDetail.d.ts +16 -72
  65. package/types/resources/Gift.d.ts +265 -432
  66. package/types/resources/Hierarchy.d.ts +8 -36
  67. package/types/resources/HostedPage.d.ts +1017 -1153
  68. package/types/resources/ImpactedItem.d.ts +13 -50
  69. package/types/resources/ImpactedItemPrice.d.ts +13 -15
  70. package/types/resources/ImpactedSubscription.d.ts +13 -45
  71. package/types/resources/InAppSubscription.d.ts +93 -389
  72. package/types/resources/Installment.d.ts +35 -110
  73. package/types/resources/InstallmentConfig.d.ts +54 -155
  74. package/types/resources/InstallmentDetail.d.ts +19 -27
  75. package/types/resources/Invoice.d.ts +1574 -3157
  76. package/types/resources/InvoiceEstimate.d.ts +131 -161
  77. package/types/resources/Item.d.ts +133 -611
  78. package/types/resources/ItemEntitlement.d.ts +78 -215
  79. package/types/resources/ItemFamily.d.ts +69 -178
  80. package/types/resources/ItemPrice.d.ts +291 -1203
  81. package/types/resources/Metadata.d.ts +3 -5
  82. package/types/resources/Order.d.ts +538 -1471
  83. package/types/resources/PaymentIntent.d.ts +163 -347
  84. package/types/resources/PaymentReferenceNumber.d.ts +7 -29
  85. package/types/resources/PaymentSource.d.ts +476 -1272
  86. package/types/resources/PaymentVoucher.d.ts +87 -306
  87. package/types/resources/PortalSession.d.ts +71 -207
  88. package/types/resources/PriceVariant.d.ts +91 -279
  89. package/types/resources/PricingPageSession.d.ts +92 -41
  90. package/types/resources/PromotionalCredit.d.ts +90 -346
  91. package/types/resources/Purchase.d.ts +185 -315
  92. package/types/resources/Quote.d.ts +1406 -887
  93. package/types/resources/QuoteLineGroup.d.ts +125 -452
  94. package/types/resources/QuotedCharge.d.ts +45 -274
  95. package/types/resources/QuotedSubscription.d.ts +100 -488
  96. package/types/resources/Ramp.d.ts +233 -724
  97. package/types/resources/ResourceMigration.d.ts +25 -80
  98. package/types/resources/SiteMigrationDetail.d.ts +34 -112
  99. package/types/resources/Subscription.d.ts +2390 -4335
  100. package/types/resources/SubscriptionEntitlement.d.ts +59 -160
  101. package/types/resources/SubscriptionEstimate.d.ts +51 -75
  102. package/types/resources/TaxWithheld.d.ts +15 -40
  103. package/types/resources/ThirdPartyPaymentMethod.d.ts +7 -29
  104. package/types/resources/TimeMachine.d.ts +43 -97
  105. package/types/resources/Token.d.ts +15 -85
  106. package/types/resources/Transaction.d.ts +278 -900
  107. package/types/resources/UnbilledCharge.d.ts +189 -164
  108. package/types/resources/Usage.d.ts +89 -279
  109. package/types/resources/VirtualBankAccount.d.ts +103 -255
  110. package/types/resources/filter.d.ts +52 -0
  111. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -81
  112. package/.github/ISSUE_TEMPLATE/config.yml +0 -6
  113. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -34
  114. package/.github/PULL_REQUEST_TEMPLATE.md +0 -8
  115. package/lib/chargebee.js +0 -512
  116. package/lib/resources/api_endpoints.js +0 -2912
  117. package/types/resources/NonSubscription.d.ts +0 -30
  118. package/types/resources/Session.d.ts +0 -41
package/lib/chargebee.js DELETED
@@ -1,512 +0,0 @@
1
- var ChargeBee = {};
2
-
3
- var Q = require("q");
4
- var os = require("os");
5
- var Buffer = require("safer-buffer").Buffer;
6
- const IDEMPOTENCY_HEADER = "chargebee-idempotency-key";
7
- const IDEMPOTENCY_REPLAYED_HEADER = 'chargebee-idempotency-replayed';
8
-
9
- ChargeBee._env = {
10
- protocol: 'https',
11
- hostSuffix: '.chargebee.com',
12
- apiPath: '/api/v2',
13
- timeout: 80000,
14
- clientVersion: 'v2.40.0',
15
- port: 443,
16
- timemachineWaitInMillis: 3000,
17
- exportWaitInMillis: 3000
18
- };
19
-
20
- ChargeBee.configure = function(conf) {
21
- ChargeBee._util.extend(true, ChargeBee._env, conf);
22
- };
23
-
24
- ChargeBee.updateRequestTimeoutInMillis = function(timeout) {
25
- ChargeBee._env.timeout = timeout;
26
- };
27
-
28
- ChargeBee._endpoints = require('./resources/api_endpoints.js');
29
-
30
- RequestWrapper.prototype.setIdempotencyKey = function(idempotencyKey) {
31
- this.headers({[IDEMPOTENCY_HEADER]: idempotencyKey});
32
- return this;
33
- };
34
-
35
-
36
-
37
- ChargeBee._waitToProcessComplete = function(retrieveHandling){
38
- if(typeof retrieveHandling == 'undefined' || !ChargeBee._util.isFunction(retrieveHandling)){
39
- throw new Error('The handling parameter should be a method.');
40
- }
41
- function DummyRequestWrapper() {
42
- this.env = {};
43
- ChargeBee._util.extend(true, this.env, ChargeBee._env);
44
- }
45
- DummyRequestWrapper.prototype.request = function(callBack, envOptions) {
46
- var jsonConstructor = {}.constructor;
47
- if (typeof envOptions !== 'undefined') {
48
- ChargeBee._util.extend(true, this.env, envOptions);
49
- } else if (typeof callBack !== 'undefined' && callBack.constructor === jsonConstructor && !ChargeBee._util.isFunction(callBack)) {
50
- ChargeBee._util.extend(true, this.env, callBack);
51
- callBack = undefined;
52
- }
53
- if (typeof callBack !== 'undefined' && !ChargeBee._util.isFunction(callBack)) {
54
- throw new Error('The callback parameter passed is incorrect.');
55
- }
56
- var deferred = ChargeBee._util.createDeferred(callBack);
57
- var _self = this;
58
- function retrieve() {
59
- retrieveHandling(deferred, _self);
60
- };
61
- retrieve();
62
- return deferred.promise;
63
- };
64
- return new DummyRequestWrapper();
65
- }
66
-
67
-
68
- ChargeBee._timeMachineWait = function() {
69
- var count = 0;
70
- var retrieve = function (deferred, _self) {
71
- module.exports.time_machine.retrieve("delorean").request(
72
- function(error, result) {
73
- if (error) {
74
- deferred.reject(error);
75
- } else {
76
- var time_machine = result.time_machine;
77
- if (time_machine.time_travel_status === 'succeeded') {
78
- deferred.resolve(result);
79
- } else if (time_machine.time_travel_status === 'in_progress') {
80
- if (count++ > 30) {
81
- throw new Error("The time travel is taking too much time");
82
- }
83
- setTimeout(function(){
84
- retrieve(deferred, _self);
85
- }, _self.env.timemachineWaitInMillis);
86
- } else {
87
- deferred.reject(result);
88
- }
89
- }
90
- });
91
- };
92
- return ChargeBee._waitToProcessComplete(retrieve);
93
- };
94
-
95
- ChargeBee._waitForExport = function(exportId){
96
- var count = 0;
97
- var retrieve = function(deferred, _self) {
98
- module.exports.export.retrieve(exportId).request(
99
- function(error, result) {
100
- if (error) {
101
- deferred.reject(error);
102
- } else {
103
- var exportObj = result.export;
104
- if (exportObj.status === 'completed') {
105
- deferred.resolve(result);
106
- } else if (exportObj.status === 'in_process') {
107
- if (count++ > 30) {
108
- throw new Error("Export is taking too long");
109
- }
110
- setTimeout(function(){
111
- retrieve(deferred, _self);
112
- }, _self.env.exportWaitInMillis);
113
- } else {
114
- deferred.reject(result);
115
- }
116
- }
117
- });
118
- };
119
- return ChargeBee._waitToProcessComplete(retrieve);
120
- }
121
-
122
-
123
- function createApiFunc(apiCall) {
124
- return function() {
125
- return new RequestWrapper(arguments, apiCall);
126
- };
127
- }
128
-
129
- function RequestWrapper(args, apiCall) {
130
- this.args = args;
131
- this.httpHeaders = {};
132
- this.apiCall = apiCall;
133
- if (this.apiCall.hasIdInUrl) {
134
- validateIdParam(this.args[0]);
135
- }
136
- }
137
-
138
- RequestWrapper.prototype.headers = function(headers) {
139
- Object.assign(this.httpHeaders,headers);
140
- return this;
141
- };
142
-
143
-
144
- RequestWrapper.prototype.request = function(callBack, envOptions) {
145
- var env = {};
146
- var jsonConstructor = {}.constructor;
147
- ChargeBee._util.extend(true, env, ChargeBee._env);
148
- if (typeof envOptions !== 'undefined') {
149
- ChargeBee._util.extend(true, env, envOptions);
150
- } else if(typeof callBack !== 'undefined' && callBack.constructor === jsonConstructor && !ChargeBee._util.isFunction(callBack)){
151
- ChargeBee._util.extend(true, env, callBack);
152
- callBack = undefined;
153
- }
154
- var deferred = ChargeBee._util.createDeferred(callBack);
155
- var urlIdParam = this.apiCall.hasIdInUrl ? this.args[0] : null;
156
- var params = this.apiCall.hasIdInUrl ? this.args[1] : this.args[0];
157
- if (typeof callBack !== 'undefined' && !ChargeBee._util.isFunction(callBack)) {
158
- throw new Error('The callback parameter passed is incorrect.');
159
- }
160
- function callBackWrapper(err, response) {
161
- if (err) {
162
- deferred.reject(err);
163
- } else {
164
- deferred.resolve(response);
165
- }
166
- };
167
- ChargeBee._core.makeApiRequest(env, callBackWrapper, this.apiCall.httpMethod, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam, params, this.httpHeaders, this.apiCall.isListReq);
168
- return deferred.promise;
169
- };
170
-
171
- function validateIdParam(idParam) {
172
- if (typeof idParam === 'undefined' || typeof idParam !== 'string' || idParam.trim().length < 1) {
173
- throw new Error('the required id parameter missing or wrong');
174
- }
175
- return idParam;
176
- }
177
-
178
-
179
- ChargeBee._core = (function() {
180
- var coreRef = {};
181
- var http = require('http');
182
- var https = require('https');
183
-
184
- coreRef.timeoutHandler = function(req, callBack) {
185
- return function() {
186
- req._isAborted = true;
187
- req.abort();
188
- throwError(callBack,'io_error', 504, 'timeout', 'request aborted due to timeout.');
189
- };
190
-
191
- };
192
-
193
- coreRef.responseHandler = function(req, callBack) {
194
- return function(res) {
195
- var response = '';
196
- res.setEncoding('utf8');
197
- res.on('data', function(chunk) {
198
- response += chunk;
199
- });
200
- res.on('end', function() {
201
- try {
202
- response = JSON.parse(response);
203
- } catch (e) {
204
- if (response.includes('503')) {
205
- return throwError(
206
- callBack,
207
- 'internal_temporary_error',
208
- 503,
209
- 'internal_temporary_error',
210
- 'Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime.',
211
- e
212
- );
213
- }
214
- else if(response.includes('504')) {
215
- return throwError(
216
- callBack,
217
- 'gateway_timeout',
218
- 504,
219
- 'gateway_timeout',
220
- 'The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com.',
221
- e
222
- );
223
- }
224
- else {
225
- return throwError(
226
- callBack,
227
- 'internal_error',
228
- 500,
229
- 'internal_error',
230
- 'Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com.',
231
- e
232
- );
233
- }
234
- }
235
- if (res.statusCode < 200 || res.statusCode > 299) {
236
- response.http_status_code = res.statusCode;
237
- callBack(response, null);
238
- } else {
239
- response.isIdempotencyReplayed = false;
240
- if (ChargeBee._util.isNotUndefinedNEmpty(res.headers[IDEMPOTENCY_REPLAYED_HEADER])) {
241
- response.isIdempotencyReplayed = res.headers[IDEMPOTENCY_REPLAYED_HEADER];
242
- }
243
- response.headers = res.headers;
244
-
245
- callBack(null, response);
246
- }
247
- });
248
- };
249
- };
250
-
251
- coreRef.errorHandler = function(req, callBack) {
252
- return function(error) {
253
- if (req._isAborted)
254
- return;
255
- throwError(callBack,'io_error', 503, 'connection_error', 'connection error while making request.', error);
256
- };
257
- };
258
-
259
- coreRef.makeApiRequest = function(env, callBack, httpMethod, urlPrefix, urlSuffix, urlIdParam, params, headers, isListReq) {
260
- var path = getApiURL(env, urlPrefix, urlSuffix, urlIdParam);
261
- if (typeof params === 'undefined' || params === null) {
262
- params = {};
263
- }
264
- if (httpMethod === 'GET') {
265
- var queryParam = isListReq ? encodeListParams(params) : encodeParams(params);
266
- path += "?" + queryParam;
267
- params = {};
268
- }
269
- var data = encodeParams(params);
270
- var protocol = (env.protocol === 'http' ? http : https);
271
-
272
- ChargeBee._util.extend(true, headers, {
273
- 'Authorization': 'Basic ' + Buffer.from(env.api_key+':').toString('base64'),
274
- 'Accept': 'application/json',
275
- 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
276
- "Content-Length": data.length,
277
- 'User-Agent': "Chargebee-NodeJs-Client " + env.clientVersion,
278
- 'Lang-Version': process.version,
279
- 'OS-Version': os.platform() + " " + os.arch() + " " + os.release()
280
- });
281
-
282
- var req = protocol.request({
283
- "hostname": getHost(env),
284
- "path": path,
285
- "method": httpMethod,
286
- "port": env.port,
287
- "headers": headers
288
- });
289
- req.setTimeout(env.timeout, coreRef.timeoutHandler(req, callBack));
290
- req.on('response', coreRef.responseHandler(req, callBack));
291
- req.on('error', coreRef.errorHandler(req, callBack));
292
- req.write(data);
293
- req.end();
294
- };
295
-
296
-
297
-
298
- function getApiURL(env, urlPrefix, urlSuffix, urlIdParam) {
299
- if (typeof env.api_key === 'undefined' || typeof env.site === 'undefined') {
300
- throw new Error('Your site or api key is not configured.');
301
- }
302
- return env.apiPath + urlPrefix + (urlIdParam !== null ? //
303
- '/' + encodeURIComponent(urlIdParam).replace(/%2F/g,'/') : '') + (urlSuffix !== null ? urlSuffix : '');
304
- }
305
-
306
- function getHost(env) {
307
- return env.site + env.hostSuffix;
308
- }
309
-
310
- var encodeListParams = function(paramObj) {
311
- var key, value;
312
- for (key in paramObj) {
313
- value = paramObj[key];
314
- if(typeof value !== 'undefined' && value !== null && ChargeBee._util.isArray(value)){
315
- paramObj[key] = JSON.stringify(value);
316
- }else{
317
- paramObj[key] = value;
318
- }
319
- }
320
- return encodeParams(paramObj);
321
- }
322
-
323
- var encodeParams = function(paramObj, serialized, scope, index) {
324
- var key, value;
325
- if (typeof serialized === 'undefined' || serialized === null) {
326
- serialized = [];
327
- }
328
- for (key in paramObj) {
329
- value = paramObj[key];
330
- if (scope) {
331
- key = "" + scope + "[" + key + "]";
332
- }
333
- if (typeof index !== 'undefined' && index !== null) {
334
- key = key + "[" + index + "]";
335
- }
336
-
337
- if (ChargeBee._util.isArray(value)) {
338
- for (var arrIdx = 0; arrIdx < value.length; arrIdx++) {
339
- if (typeof value[arrIdx] === 'object' || ChargeBee._util.isArray(value[arrIdx])) {
340
- encodeParams(value[arrIdx], serialized, key, arrIdx);
341
- } else {
342
- if (typeof value[arrIdx] !== 'undefined') {
343
- serialized.push(encodeURIComponent(key + "[" + arrIdx + "]") + "=" + encodeURIComponent(ChargeBee._util.trim(value[arrIdx]) !== '' ? value[arrIdx] : ''));
344
- }
345
- }
346
- }
347
- } else if(["meta_data", "metadata"].indexOf(key) !== -1) {
348
- var attrVal="";
349
- if(value !== null) {
350
- attrVal = encodeURIComponent(Object.prototype.toString.call(value) === "[object String]" ? ChargeBee._util.trim(value) : JSON.stringify(value));
351
- }
352
- serialized.push(encodeURIComponent(key) + "=" + attrVal);
353
- } else if (typeof value === 'object' && !ChargeBee._util.isArray(value)) {
354
- encodeParams(value, serialized, key);
355
- } else {
356
- if (typeof value !== 'undefined') {
357
- serialized.push(encodeURIComponent(key) + "=" + encodeURIComponent(ChargeBee._util.trim(value) !== '' ? value : ''));
358
- }
359
- }
360
- }
361
-
362
- return serialized.join('&').replace(/%20/g, '+');
363
- };
364
- var throwError = function(callBack,type,httpStatusCode, errorCode, message, detail) {
365
- var error = {
366
- 'message': message,
367
- 'type':type,
368
- 'api_error_code':errorCode,
369
- 'http_status_code':httpStatusCode,
370
-
371
- 'http_code': httpStatusCode,
372
- 'error_code': errorCode,
373
- };
374
- if (typeof detail !== "undefined") {
375
- error['detail'] = detail;
376
- }
377
- return callBack(error, null);
378
- };
379
-
380
- return coreRef;
381
- }).call(this);
382
-
383
- ChargeBee._util = (function() {
384
- var util = {};
385
-
386
- util.extend = function(deep, target, copy) {
387
- util.extendsFn.call(this, deep, target, copy);
388
- };
389
-
390
- util.extendsFn = function() {
391
- var options, name, src, copy, copyIsArray, clone,
392
- target = arguments[0] || {},
393
- i = 1,
394
- length = arguments.length,
395
- deep = false;
396
- if (typeof target === "boolean") {
397
- deep = target;
398
- target = arguments[1] || {};
399
- i = 2;
400
- }
401
- if (typeof target !== "object" && typeof target !== "function") {
402
- target = {};
403
- }
404
- if (length === i) {
405
- target = this;
406
- --i;
407
- }
408
- for (; i < length; i++) {
409
- if ((options = arguments[ i ]) !== null) {
410
- for (name in options) {
411
- src = target[ name ];
412
- copy = options[ name ];
413
-
414
- if (target === copy) {
415
- continue;
416
- }
417
- if (deep && copy && (typeof copy === 'object' || (copyIsArray = (util.isArray(copy))))) {
418
- if (copyIsArray) {
419
- copyIsArray = false;
420
- clone = src && util.isArray(src) ? src : [];
421
- } else {
422
- clone = src && typeof src === 'object' ? src : {};
423
- }
424
- target[ name ] = util.extend.call(this, deep, clone, copy);
425
- } else if (copy !== undefined) {
426
- target[ name ] = copy;
427
- }
428
- }
429
- }
430
- }
431
- return target;
432
- };
433
-
434
- util.indexOf = function(array, item) {
435
- if (![].indexOf()) {
436
- for (var i = 0; i < array.length; i++) {
437
- if (array[i] === item) {
438
- return i;
439
- }
440
- }
441
- return -1;
442
- } else {
443
- return array.indexOf(item);
444
- }
445
- };
446
-
447
- util.trim = function(str) {
448
- return str !== '' ? str : str.replace(/^\s+|\s+$/g, '');
449
- };
450
-
451
- util.isEmptyObject = function(obj) {
452
- var name;
453
- for (name in obj) {
454
- return false;
455
- }
456
- return true;
457
- };
458
-
459
- util.isNotUndefinedNEmpty = function(obj) {
460
- if (typeof obj !== 'undefined' && !util.isEmptyObject(obj)) {
461
- return true;
462
- }
463
- return false;
464
- };
465
-
466
- util.isArray = Array.isArray || function(obj) {
467
- return Object.prototype.toString.call(obj) === '[object Array]';
468
- };
469
-
470
- util.isFunction = function(obj) {
471
- return typeof obj === 'function';
472
- };
473
-
474
- util.createDeferred = function(callback) {
475
- var deferred = Q.defer();
476
- if (callback) {
477
- deferred.promise.then(function(res) {
478
- setTimeout(function() {
479
- callback(null, res);
480
- }, 0);
481
- }, function(err) {
482
- setTimeout(function() {
483
- callback(err, null);
484
- }, 0);
485
- });
486
- };
487
- return deferred;
488
- };
489
- return util;
490
-
491
- }).call(this);
492
-
493
- (function() {
494
- module.exports.configure = ChargeBee.configure;
495
- for (var res in ChargeBee._endpoints) {
496
- module.exports[res] = {};
497
- var apiCalls = ChargeBee._endpoints[res];
498
- for (var apiIdx = 0; apiIdx < apiCalls.length; apiIdx++) {
499
- var metaArr = apiCalls[apiIdx];
500
- var apiCall = {"methodName": metaArr[0],
501
- "httpMethod": metaArr[1],
502
- "urlPrefix": metaArr[2],
503
- "urlSuffix": metaArr[3],
504
- "hasIdInUrl": metaArr[4],
505
- "isListReq": metaArr[0]==="list"};
506
- module.exports[res][apiCall.methodName] = createApiFunc(apiCall);
507
- }
508
- }
509
- module.exports.time_machine.wait_for_time_travel_completion = ChargeBee._timeMachineWait;
510
- module.exports.export.wait_for_export_completion = ChargeBee._waitForExport;
511
- module.exports.updateRequestTimeoutInMillis = ChargeBee.updateRequestTimeoutInMillis;
512
- })();