chargebee 3.3.0 → 3.4.0
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 +41 -0
- package/cjs/RequestWrapper.js +9 -3
- package/cjs/coreCommon.js +1 -0
- package/cjs/createChargebee.js +3 -0
- package/cjs/environment.js +1 -1
- package/cjs/resources/api_endpoints.js +2099 -366
- package/cjs/util.js +22 -17
- package/esm/RequestWrapper.js +9 -3
- package/esm/coreCommon.js +1 -0
- package/esm/createChargebee.js +3 -0
- package/esm/environment.js +1 -1
- package/esm/resources/api_endpoints.js +2099 -366
- package/esm/util.js +22 -17
- package/package.json +1 -1
- package/types/core.d.ts +7 -1
- package/types/index.d.ts +4 -0
- package/types/resources/AttachedItem.d.ts +1 -0
- package/types/resources/Comment.d.ts +1 -0
- package/types/resources/Coupon.d.ts +5 -16
- package/types/resources/CreditNote.d.ts +4 -3
- package/types/resources/CreditNoteEstimate.d.ts +1 -1
- package/types/resources/Customer.d.ts +0 -12
- package/types/resources/DifferentialPrice.d.ts +1 -0
- package/types/resources/Feature.d.ts +1 -0
- package/types/resources/Invoice.d.ts +7 -0
- package/types/resources/InvoiceEstimate.d.ts +6 -0
- package/types/resources/Item.d.ts +1 -0
- package/types/resources/ItemFamily.d.ts +1 -0
- package/types/resources/ItemPrice.d.ts +1 -0
- package/types/resources/Order.d.ts +1 -1
- package/types/resources/PriceVariant.d.ts +1 -0
- package/types/resources/Rule.d.ts +33 -0
- package/types/resources/Subscription.d.ts +1 -0
- package/types/resources/UsageEvent.d.ts +53 -0
package/cjs/util.js
CHANGED
|
@@ -164,47 +164,52 @@ function encodeListParams(paramObj) {
|
|
|
164
164
|
}
|
|
165
165
|
return encodeParams(paramObj);
|
|
166
166
|
}
|
|
167
|
-
function getHost(env) {
|
|
167
|
+
function getHost(env, subDomain) {
|
|
168
|
+
if (subDomain != null) {
|
|
169
|
+
return env.site + '.' + subDomain + env.hostSuffix;
|
|
170
|
+
}
|
|
168
171
|
return env.site + env.hostSuffix;
|
|
169
172
|
}
|
|
170
|
-
function encodeParams(paramObj, serialized, scope, index) {
|
|
173
|
+
function encodeParams(paramObj, serialized, scope, index, jsonKeys, level = 0) {
|
|
171
174
|
let key, value;
|
|
172
175
|
if (typeof serialized === 'undefined' || serialized === null) {
|
|
173
176
|
serialized = [];
|
|
174
177
|
}
|
|
175
178
|
for (key in paramObj) {
|
|
176
179
|
value = paramObj[key];
|
|
180
|
+
const originalKey = key;
|
|
177
181
|
if (scope) {
|
|
178
|
-
key =
|
|
182
|
+
key = `${scope}[${key}]`;
|
|
179
183
|
}
|
|
180
184
|
if (typeof index !== 'undefined' && index !== null) {
|
|
181
|
-
key = key
|
|
185
|
+
key = `${key}[${index}]`;
|
|
186
|
+
}
|
|
187
|
+
if (jsonKeys && jsonKeys[originalKey] === level) {
|
|
188
|
+
let attrVal = '';
|
|
189
|
+
if (value !== null) {
|
|
190
|
+
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]'
|
|
191
|
+
? (0, exports.trim)(value)
|
|
192
|
+
: JSON.stringify(value));
|
|
193
|
+
}
|
|
194
|
+
serialized.push(encodeURIComponent(key) + '=' + attrVal);
|
|
182
195
|
}
|
|
183
|
-
if ((0, exports.isArray)(value)
|
|
196
|
+
else if ((0, exports.isArray)(value) &&
|
|
197
|
+
!(jsonKeys && jsonKeys[originalKey] === level)) {
|
|
184
198
|
for (let arrIdx = 0; arrIdx < value.length; arrIdx++) {
|
|
185
199
|
if (typeof value[arrIdx] === 'object' || (0, exports.isArray)(value[arrIdx])) {
|
|
186
|
-
encodeParams(value[arrIdx], serialized, key, arrIdx);
|
|
200
|
+
encodeParams(value[arrIdx], serialized, key, arrIdx, jsonKeys, level + 1);
|
|
187
201
|
}
|
|
188
202
|
else {
|
|
189
203
|
if (typeof value[arrIdx] !== 'undefined') {
|
|
190
|
-
serialized.push(encodeURIComponent(key
|
|
204
|
+
serialized.push(encodeURIComponent(`${key}[${arrIdx}]`) +
|
|
191
205
|
'=' +
|
|
192
206
|
encodeURIComponent((0, exports.trim)(value[arrIdx]) !== '' ? value[arrIdx] : ''));
|
|
193
207
|
}
|
|
194
208
|
}
|
|
195
209
|
}
|
|
196
210
|
}
|
|
197
|
-
else if (key === 'meta_data' || key === 'metadata') {
|
|
198
|
-
let attrVal = '';
|
|
199
|
-
if (value !== null) {
|
|
200
|
-
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]'
|
|
201
|
-
? (0, exports.trim)(value)
|
|
202
|
-
: JSON.stringify(value));
|
|
203
|
-
}
|
|
204
|
-
serialized.push(encodeURIComponent(key) + '=' + attrVal);
|
|
205
|
-
}
|
|
206
211
|
else if (typeof value === 'object' && !(0, exports.isArray)(value)) {
|
|
207
|
-
encodeParams(value, serialized, key);
|
|
212
|
+
encodeParams(value, serialized, key, undefined, jsonKeys, level + 1);
|
|
208
213
|
}
|
|
209
214
|
else {
|
|
210
215
|
if (typeof value !== 'undefined') {
|
package/esm/RequestWrapper.js
CHANGED
|
@@ -51,21 +51,27 @@ export class RequestWrapper {
|
|
|
51
51
|
path += '?' + queryParam;
|
|
52
52
|
params = {};
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
const jsonKeys = this.apiCall.jsonKeys;
|
|
55
|
+
let data = this.apiCall.isJsonRequest
|
|
56
|
+
? JSON.stringify(params)
|
|
57
|
+
: encodeParams(params, undefined, undefined, undefined, jsonKeys);
|
|
55
58
|
if (data.length) {
|
|
56
59
|
extend(true, this.httpHeaders, {
|
|
57
60
|
'Content-Length': data.length,
|
|
58
61
|
});
|
|
59
62
|
}
|
|
63
|
+
const contentType = this.apiCall.isJsonRequest
|
|
64
|
+
? 'application/json;charset=UTF-8'
|
|
65
|
+
: 'application/x-www-form-urlencoded; charset=utf-8';
|
|
60
66
|
extend(true, this.httpHeaders, {
|
|
61
67
|
Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'),
|
|
62
68
|
Accept: 'application/json',
|
|
63
|
-
'Content-Type':
|
|
69
|
+
'Content-Type': contentType,
|
|
64
70
|
'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion,
|
|
65
71
|
'Lang-Version': typeof process === 'undefined' ? '' : process.version,
|
|
66
72
|
});
|
|
67
73
|
const resp = await this.envArg.httpClient.makeApiRequest({
|
|
68
|
-
host: getHost(env),
|
|
74
|
+
host: getHost(env, this.apiCall.subDomain),
|
|
69
75
|
port: env.port,
|
|
70
76
|
path,
|
|
71
77
|
method: this.apiCall.httpMethod,
|
package/esm/coreCommon.js
CHANGED
package/esm/createChargebee.js
CHANGED
|
@@ -75,6 +75,9 @@ export const CreateChargebee = (httpClient) => {
|
|
|
75
75
|
urlSuffix: metaArr[3],
|
|
76
76
|
hasIdInUrl: metaArr[4],
|
|
77
77
|
isListReq: metaArr[0] === 'list',
|
|
78
|
+
subDomain: metaArr[5],
|
|
79
|
+
isJsonRequest: metaArr[6],
|
|
80
|
+
jsonKeys: metaArr[7],
|
|
78
81
|
};
|
|
79
82
|
this[res][apiCall.methodName] = this._createApiFunc(apiCall, this._env);
|
|
80
83
|
}
|
package/esm/environment.js
CHANGED
|
@@ -8,7 +8,7 @@ export const Environment = {
|
|
|
8
8
|
hostSuffix: '.chargebee.com',
|
|
9
9
|
apiPath: '/api/v2',
|
|
10
10
|
timeout: DEFAULT_TIME_OUT,
|
|
11
|
-
clientVersion: 'v3.
|
|
11
|
+
clientVersion: 'v3.4.0',
|
|
12
12
|
port: DEFAULT_PORT,
|
|
13
13
|
timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
|
|
14
14
|
exportWaitInMillis: DEFAULT_EXPORT_WAIT,
|