chargebee 2.22.2 → 2.22.3

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.
package/CHANGELOG.md CHANGED
@@ -3,9 +3,6 @@
3
3
 
4
4
  #### New Feature:
5
5
  * Added setIdempotencyKey("UUID") utility to pass **Idempotency key** along with request headers to allow a safe retry of POST requests.
6
- * Added isIdempotencyReplayed utility to differentiate between original and replayed requests.
7
- * Added headers utility to fetch the response headers.
8
-
9
6
 
10
7
  ### v2.21.0 (2023-04-28)
11
8
  * * *
package/README.md CHANGED
@@ -47,7 +47,7 @@ try {
47
47
  // other params
48
48
  })
49
49
  .request();
50
- // access customer as result.response.customer;
50
+ // access customer as result.customer;
51
51
  } catch (err) {
52
52
  // handle error
53
53
  }
@@ -64,7 +64,7 @@ chargebee.customer
64
64
  .request()
65
65
  .then((result) => {
66
66
  // handle result
67
- // access customer as result.response.customer;
67
+ // access customer as result.customer;
68
68
  })
69
69
  .catch((err) => {
70
70
  // handle error
@@ -97,7 +97,7 @@ The response object returned by the `request()` method is generic response wrapp
97
97
 
98
98
  ```js
99
99
  const result = await chargebee.customer.create({ email: 'john@test.com' }).request();
100
- console.log(result.response.customer);
100
+ console.log(result.customer);
101
101
  ```
102
102
 
103
103
  Other resources can be accessed by the same approach. For subscription, it will be `result.subscription`
@@ -112,7 +112,7 @@ const result = await chargebee.subscription
112
112
  .request();
113
113
 
114
114
  // A list of Subscription objects
115
- console.log(result.response.list.map((obj) => obj.subscription));
115
+ console.log(result.list.map((obj) => obj.subscription));
116
116
  ```
117
117
 
118
118
  **Note**
@@ -121,14 +121,14 @@ If you have a `result` (or children further down the line) and are unsure what p
121
121
 
122
122
  ```js
123
123
  // ['list', 'next_offset']
124
- console.log(Object.keys(result.response));
124
+ console.log(Object.keys(result));
125
125
  // ['1', '2', '3'], e.g. `result.list` is an array with 3 entries
126
- console.log(Object.keys(result.response.list));
126
+ console.log(Object.keys(result.list));
127
127
  // ['activated_at', 'base_currency_code', ...]
128
128
  // ['activated_at', 'base_currency_code', ...]
129
129
  // ['activated_at', 'base_currency_code', ...]
130
130
  // Which means we've reached the bottom and should have all the information available from this request
131
- console.log(result.response.list.map((obj) => obj.subscription));
131
+ console.log(result.list.map((obj) => obj.subscription));
132
132
  ```
133
133
 
134
134
  #### Using filters in the List API
@@ -144,8 +144,8 @@ const fetchCustomers = async (offset) => {
144
144
  }).request();
145
145
 
146
146
  return {
147
- customers: result.response.list.map((obj) => obj.customer),
148
- next_offset: result.response.next_offset,
147
+ customers: result.list.map((obj) => obj.customer),
148
+ next_offset: result.next_offset,
149
149
  };
150
150
  };
151
151
 
@@ -174,7 +174,7 @@ const result = await chargebee.customer
174
174
  .setIdempotencyKey("safeKey")
175
175
  .request();
176
176
 
177
- const customer = result.response.customer;
177
+ const customer = result.customer;
178
178
  console.log(customer.cf_host_url);
179
179
  ```
180
180
 
@@ -187,13 +187,9 @@ const result = await chargebee.customer
187
187
  .create({ email: 'john@test.com' })
188
188
  .setIdempotencyKey("safeKey")
189
189
  .request();
190
- const customer = result.response.customer;
191
- console.log(result.headers); // Retrieves response headers
192
- console.log(result.isIdempotencyReplayed); // Retrieves idempotency replayed header
190
+ const customer = result.customer;
193
191
  ```
194
192
 
195
- `isIdempotencyReplayed()` method can be accessed to differentiate between original and replayed requests.
196
-
197
193
  ### Processing Webhooks - API Version Check
198
194
 
199
195
  An attribute, <b>api_version</b>, is added to the [Event](https://apidocs.chargebee.com/docs/api/events) resource, which indicates the API version based on which the event content is structured. In your webhook servers, ensure this \_api_version* is the same as the [API version](https://apidocs.chargebee.com/docs/api#versions) used by your webhook server's client library.
package/lib/chargebee.js CHANGED
@@ -4,14 +4,13 @@ var Q = require("q");
4
4
  var os = require("os");
5
5
  var Buffer = require("safer-buffer").Buffer;
6
6
  const IDEMPOTENCY_HEADER = "chargebee-idempotency-key";
7
- const IDEMPOTENCY_REPLAY_HEADER = 'chargebee-idempotency-replayed';
8
7
 
9
8
  ChargeBee._env = {
10
9
  protocol: 'https',
11
10
  hostSuffix: '.chargebee.com',
12
11
  apiPath: '/api/v2',
13
12
  timeout: 80000,
14
- clientVersion: 'v2.22.2',
13
+ clientVersion: 'v2.22.3',
15
14
  port: 443,
16
15
  timemachineWaitInMillis: 3000,
17
16
  exportWaitInMillis: 3000
@@ -157,11 +156,11 @@ RequestWrapper.prototype.request = function(callBack, envOptions) {
157
156
  if (typeof callBack !== 'undefined' && !ChargeBee._util.isFunction(callBack)) {
158
157
  throw new Error('The callback parameter passed is incorrect.');
159
158
  }
160
- function callBackWrapper(err, response, headers, isIdempotencyReplayed) {
159
+ function callBackWrapper(err, response) {
161
160
  if (err) {
162
161
  deferred.reject(err);
163
162
  } else {
164
- deferred.resolve({'response': response, 'headers': headers, 'isIdempotencyReplayed' : isIdempotencyReplayed});
163
+ deferred.resolve(response);
165
164
  }
166
165
  };
167
166
  ChargeBee._core.makeApiRequest(env, callBackWrapper, this.apiCall.httpMethod, this.apiCall.urlPrefix, this.apiCall.urlSuffix, urlIdParam, params, this.httpHeaders, this.apiCall.isListReq);
@@ -234,13 +233,9 @@ ChargeBee._core = (function() {
234
233
  }
235
234
  if (res.statusCode < 200 || res.statusCode > 299) {
236
235
  response.http_status_code = res.statusCode;
237
- callBack(response, null, res.headers);
236
+ callBack(response, null);
238
237
  } else {
239
- isIdempotencyReplayed = false
240
- if(typeof res.headers[IDEMPOTENCY_REPLAY_HEADER] !== 'undefined' && res.headers[IDEMPOTENCY_REPLAY_HEADER] !== ''){
241
- isIdempotencyReplayed = res.headers[IDEMPOTENCY_REPLAY_HEADER];
242
- }
243
- callBack(null, response, res.headers, isIdempotencyReplayed);
238
+ callBack(null, response);
244
239
  }
245
240
  });
246
241
  };
@@ -474,7 +469,7 @@ ChargeBee._util = (function() {
474
469
  if (callback) {
475
470
  deferred.promise.then(function(res) {
476
471
  setTimeout(function() {
477
- callback(null, res.response, res.headers, isIdempotencyReplayed);
472
+ callback(null, res);
478
473
  }, 0);
479
474
  }, function(err) {
480
475
  setTimeout(function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name":"chargebee",
3
- "version":"2.22.2",
3
+ "version":"2.22.3",
4
4
  "description":"A library for integrating with ChargeBee.",
5
5
  "keywords":[
6
6
  "payments",