chargebee
Advanced tools
Comparing version 3.3.0 to 3.4.0
@@ -38,2 +38,3 @@ "use strict"; | ||
res.headers = headers; | ||
res.httpStatusCode = status; | ||
return callback(null, res); | ||
@@ -40,0 +41,0 @@ } |
@@ -81,2 +81,5 @@ "use strict"; | ||
isListReq: metaArr[0] === 'list', | ||
subDomain: metaArr[5], | ||
isJsonRequest: metaArr[6], | ||
jsonKeys: metaArr[7], | ||
}; | ||
@@ -83,0 +86,0 @@ this[res][apiCall.methodName] = this._createApiFunc(apiCall, this._env); |
@@ -14,3 +14,3 @@ "use strict"; | ||
timeout: DEFAULT_TIME_OUT, | ||
clientVersion: 'v3.3.0', | ||
clientVersion: 'v3.4.0', | ||
port: DEFAULT_PORT, | ||
@@ -17,0 +17,0 @@ timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT, |
@@ -57,3 +57,6 @@ "use strict"; | ||
} | ||
let data = (0, util_js_1.encodeParams)(params); | ||
const jsonKeys = this.apiCall.jsonKeys; | ||
let data = this.apiCall.isJsonRequest | ||
? JSON.stringify(params) | ||
: (0, util_js_1.encodeParams)(params, undefined, undefined, undefined, jsonKeys); | ||
if (data.length) { | ||
@@ -64,6 +67,9 @@ (0, util_js_1.extend)(true, this.httpHeaders, { | ||
} | ||
const contentType = this.apiCall.isJsonRequest | ||
? 'application/json;charset=UTF-8' | ||
: 'application/x-www-form-urlencoded; charset=utf-8'; | ||
(0, util_js_1.extend)(true, this.httpHeaders, { | ||
Authorization: 'Basic ' + node_buffer_1.Buffer.from(env.apiKey + ':').toString('base64'), | ||
Accept: 'application/json', | ||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', | ||
'Content-Type': contentType, | ||
'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion, | ||
@@ -73,3 +79,3 @@ 'Lang-Version': typeof process === 'undefined' ? '' : process.version, | ||
const resp = await this.envArg.httpClient.makeApiRequest({ | ||
host: (0, util_js_1.getHost)(env), | ||
host: (0, util_js_1.getHost)(env, this.apiCall.subDomain), | ||
port: env.port, | ||
@@ -76,0 +82,0 @@ path, |
@@ -167,6 +167,9 @@ "use strict"; | ||
} | ||
function getHost(env) { | ||
function getHost(env, subDomain) { | ||
if (subDomain != null) { | ||
return env.site + '.' + subDomain + env.hostSuffix; | ||
} | ||
return env.site + env.hostSuffix; | ||
} | ||
function encodeParams(paramObj, serialized, scope, index) { | ||
function encodeParams(paramObj, serialized, scope, index, jsonKeys, level = 0) { | ||
let key, value; | ||
@@ -178,16 +181,27 @@ if (typeof serialized === 'undefined' || serialized === null) { | ||
value = paramObj[key]; | ||
const originalKey = key; | ||
if (scope) { | ||
key = '' + scope + '[' + key + ']'; | ||
key = `${scope}[${key}]`; | ||
} | ||
if (typeof index !== 'undefined' && index !== null) { | ||
key = key + '[' + index + ']'; | ||
key = `${key}[${index}]`; | ||
} | ||
if ((0, exports.isArray)(value)) { | ||
if (jsonKeys && jsonKeys[originalKey] === level) { | ||
let attrVal = ''; | ||
if (value !== null) { | ||
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]' | ||
? (0, exports.trim)(value) | ||
: JSON.stringify(value)); | ||
} | ||
serialized.push(encodeURIComponent(key) + '=' + attrVal); | ||
} | ||
else if ((0, exports.isArray)(value) && | ||
!(jsonKeys && jsonKeys[originalKey] === level)) { | ||
for (let arrIdx = 0; arrIdx < value.length; arrIdx++) { | ||
if (typeof value[arrIdx] === 'object' || (0, exports.isArray)(value[arrIdx])) { | ||
encodeParams(value[arrIdx], serialized, key, arrIdx); | ||
encodeParams(value[arrIdx], serialized, key, arrIdx, jsonKeys, level + 1); | ||
} | ||
else { | ||
if (typeof value[arrIdx] !== 'undefined') { | ||
serialized.push(encodeURIComponent(key + '[' + arrIdx + ']') + | ||
serialized.push(encodeURIComponent(`${key}[${arrIdx}]`) + | ||
'=' + | ||
@@ -199,13 +213,4 @@ encodeURIComponent((0, exports.trim)(value[arrIdx]) !== '' ? value[arrIdx] : '')); | ||
} | ||
else if (key === 'meta_data' || key === 'metadata') { | ||
let attrVal = ''; | ||
if (value !== null) { | ||
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]' | ||
? (0, exports.trim)(value) | ||
: JSON.stringify(value)); | ||
} | ||
serialized.push(encodeURIComponent(key) + '=' + attrVal); | ||
} | ||
else if (typeof value === 'object' && !(0, exports.isArray)(value)) { | ||
encodeParams(value, serialized, key); | ||
encodeParams(value, serialized, key, undefined, jsonKeys, level + 1); | ||
} | ||
@@ -212,0 +217,0 @@ else { |
@@ -34,2 +34,3 @@ import { ChargebeeError } from './chargebeeError.js'; | ||
res.headers = headers; | ||
res.httpStatusCode = status; | ||
return callback(null, res); | ||
@@ -36,0 +37,0 @@ } |
@@ -78,2 +78,5 @@ import { RequestWrapper } from './RequestWrapper.js'; | ||
isListReq: metaArr[0] === 'list', | ||
subDomain: metaArr[5], | ||
isJsonRequest: metaArr[6], | ||
jsonKeys: metaArr[7], | ||
}; | ||
@@ -80,0 +83,0 @@ this[res][apiCall.methodName] = this._createApiFunc(apiCall, this._env); |
@@ -11,3 +11,3 @@ const DEFAULT_PROTOCOL = 'https'; | ||
timeout: DEFAULT_TIME_OUT, | ||
clientVersion: 'v3.3.0', | ||
clientVersion: 'v3.4.0', | ||
port: DEFAULT_PORT, | ||
@@ -14,0 +14,0 @@ timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT, |
@@ -54,3 +54,6 @@ import { extend, callbackifyPromise, getApiURL, encodeListParams, encodeParams, serialize, getHost, } from './util.js'; | ||
} | ||
let data = encodeParams(params); | ||
const jsonKeys = this.apiCall.jsonKeys; | ||
let data = this.apiCall.isJsonRequest | ||
? JSON.stringify(params) | ||
: encodeParams(params, undefined, undefined, undefined, jsonKeys); | ||
if (data.length) { | ||
@@ -61,6 +64,9 @@ extend(true, this.httpHeaders, { | ||
} | ||
const contentType = this.apiCall.isJsonRequest | ||
? 'application/json;charset=UTF-8' | ||
: 'application/x-www-form-urlencoded; charset=utf-8'; | ||
extend(true, this.httpHeaders, { | ||
Authorization: 'Basic ' + Buffer.from(env.apiKey + ':').toString('base64'), | ||
Accept: 'application/json', | ||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', | ||
'Content-Type': contentType, | ||
'User-Agent': 'Chargebee-NodeJs-Client ' + env.clientVersion, | ||
@@ -70,3 +76,3 @@ 'Lang-Version': typeof process === 'undefined' ? '' : process.version, | ||
const resp = await this.envArg.httpClient.makeApiRequest({ | ||
host: getHost(env), | ||
host: getHost(env, this.apiCall.subDomain), | ||
port: env.port, | ||
@@ -73,0 +79,0 @@ path, |
@@ -151,6 +151,9 @@ export const extend = (deep, target, copy) => { | ||
} | ||
export function getHost(env) { | ||
export function getHost(env, subDomain) { | ||
if (subDomain != null) { | ||
return env.site + '.' + subDomain + env.hostSuffix; | ||
} | ||
return env.site + env.hostSuffix; | ||
} | ||
export function encodeParams(paramObj, serialized, scope, index) { | ||
export function encodeParams(paramObj, serialized, scope, index, jsonKeys, level = 0) { | ||
let key, value; | ||
@@ -162,16 +165,27 @@ if (typeof serialized === 'undefined' || serialized === null) { | ||
value = paramObj[key]; | ||
const originalKey = key; | ||
if (scope) { | ||
key = '' + scope + '[' + key + ']'; | ||
key = `${scope}[${key}]`; | ||
} | ||
if (typeof index !== 'undefined' && index !== null) { | ||
key = key + '[' + index + ']'; | ||
key = `${key}[${index}]`; | ||
} | ||
if (isArray(value)) { | ||
if (jsonKeys && jsonKeys[originalKey] === level) { | ||
let attrVal = ''; | ||
if (value !== null) { | ||
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]' | ||
? trim(value) | ||
: JSON.stringify(value)); | ||
} | ||
serialized.push(encodeURIComponent(key) + '=' + attrVal); | ||
} | ||
else if (isArray(value) && | ||
!(jsonKeys && jsonKeys[originalKey] === level)) { | ||
for (let arrIdx = 0; arrIdx < value.length; arrIdx++) { | ||
if (typeof value[arrIdx] === 'object' || isArray(value[arrIdx])) { | ||
encodeParams(value[arrIdx], serialized, key, arrIdx); | ||
encodeParams(value[arrIdx], serialized, key, arrIdx, jsonKeys, level + 1); | ||
} | ||
else { | ||
if (typeof value[arrIdx] !== 'undefined') { | ||
serialized.push(encodeURIComponent(key + '[' + arrIdx + ']') + | ||
serialized.push(encodeURIComponent(`${key}[${arrIdx}]`) + | ||
'=' + | ||
@@ -183,13 +197,4 @@ encodeURIComponent(trim(value[arrIdx]) !== '' ? value[arrIdx] : '')); | ||
} | ||
else if (key === 'meta_data' || key === 'metadata') { | ||
let attrVal = ''; | ||
if (value !== null) { | ||
attrVal = encodeURIComponent(Object.prototype.toString.call(value) === '[object String]' | ||
? trim(value) | ||
: JSON.stringify(value)); | ||
} | ||
serialized.push(encodeURIComponent(key) + '=' + attrVal); | ||
} | ||
else if (typeof value === 'object' && !isArray(value)) { | ||
encodeParams(value, serialized, key); | ||
encodeParams(value, serialized, key, undefined, jsonKeys, level + 1); | ||
} | ||
@@ -196,0 +201,0 @@ else { |
{ | ||
"name": "chargebee", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "A library for integrating with Chargebee.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -12,2 +12,3 @@ declare module 'chargebee' { | ||
isIdempotencyReplayed?: boolean | string; | ||
httpStatusCode: number | null; | ||
}; | ||
@@ -139,3 +140,4 @@ export type ChargebeeRequestHeader = { | ||
| 'omnichannel_subscription_item' | ||
| 'omnichannel_transaction'; | ||
| 'omnichannel_transaction' | ||
| 'recorded_purchase'; | ||
type EventNameEnum = 'cancellation_page_loaded'; | ||
@@ -334,2 +336,6 @@ type EventTypeEnum = | ||
| 'omnichannel_subscription_item_dunning_expired' | ||
| 'rule_created' | ||
| 'rule_updated' | ||
| 'rule_deleted' | ||
| 'record_purchase_failed' | ||
| 'plan_created' | ||
@@ -336,0 +342,0 @@ | 'plan_updated' |
@@ -68,2 +68,3 @@ ///<reference path='./resources/Address.d.ts' /> | ||
///<reference path='./resources/ResourceMigration.d.ts' /> | ||
///<reference path='./resources/Rule.d.ts' /> | ||
///<reference path='./resources/SiteMigrationDetail.d.ts' /> | ||
@@ -80,2 +81,3 @@ ///<reference path='./resources/Subscription.d.ts' /> | ||
///<reference path='./resources/Usage.d.ts' /> | ||
///<reference path='./resources/UsageEvent.d.ts' /> | ||
///<reference path='./resources/VirtualBankAccount.d.ts' /> | ||
@@ -168,2 +170,3 @@ | ||
resourceMigration: ResourceMigration.ResourceMigrationResource; | ||
rule: Rule.RuleResource; | ||
siteMigrationDetail: SiteMigrationDetail.SiteMigrationDetailResource; | ||
@@ -176,4 +179,5 @@ subscription: Subscription.SubscriptionResource; | ||
usage: Usage.UsageResource; | ||
usageEvent: UsageEvent.UsageEventResource; | ||
virtualBankAccount: VirtualBankAccount.VirtualBankAccountResource; | ||
} | ||
} |
@@ -21,2 +21,3 @@ ///<reference path='./../core.d.ts'/> | ||
business_entity_id?: string; | ||
deleted: boolean; | ||
} | ||
@@ -23,0 +24,0 @@ |
@@ -82,2 +82,3 @@ ///<reference path='./../core.d.ts'/> | ||
| 'omnichannel_transaction' | ||
| 'recorded_purchase' | ||
| 'item_family' | ||
@@ -84,0 +85,0 @@ | 'item' |
@@ -44,2 +44,3 @@ ///<reference path='./../core.d.ts'/> | ||
coupon_constraints?: Coupon.CouponConstraint[]; | ||
deleted: boolean; | ||
} | ||
@@ -164,6 +165,3 @@ | ||
currency_code?: string; | ||
discount_percentage?: number /** | ||
* @deprecated Please refer API docs to use other attributes | ||
*/; | ||
discount_percentage?: number; | ||
discount_quantity?: number; | ||
@@ -193,6 +191,3 @@ apply_on: 'invoice_amount' | 'each_specified_item'; | ||
currency_code?: string; | ||
discount_percentage?: number /** | ||
* @deprecated Please refer API docs to use other attributes | ||
*/; | ||
discount_percentage?: number; | ||
discount_quantity?: number; | ||
@@ -222,6 +217,3 @@ apply_on: 'invoice_amount' | 'each_specified_item'; | ||
currency_code?: string; | ||
discount_percentage?: number /** | ||
* @deprecated Please refer API docs to use other attributes | ||
*/; | ||
discount_percentage?: number; | ||
discount_quantity?: number; | ||
@@ -266,6 +258,3 @@ apply_on?: 'invoice_amount' | 'each_specified_item'; | ||
currency_code?: string; | ||
discount_percentage?: number /** | ||
* @deprecated Please refer API docs to use other attributes | ||
*/; | ||
discount_percentage?: number; | ||
discount_quantity?: number; | ||
@@ -272,0 +261,0 @@ apply_on?: 'invoice_amount' | 'each_specified_item'; |
@@ -10,3 +10,3 @@ ///<reference path='./../core.d.ts'/> | ||
reference_invoice_id?: string; | ||
type: 'adjustment' | 'refundable'; | ||
type: 'adjustment' | 'refundable' | 'store'; | ||
reason_code?: | ||
@@ -364,2 +364,3 @@ | 'write_off' | ||
| 'pending'; | ||
tax_application?: 'pre_tax' | 'post_tax'; | ||
} | ||
@@ -414,3 +415,3 @@ export interface ShippingAddress { | ||
total?: number; | ||
type: 'adjustment' | 'refundable'; | ||
type: 'adjustment' | 'refundable' | 'store'; | ||
reason_code?: | ||
@@ -486,3 +487,3 @@ | 'product_unsatisfactory' | ||
reference_invoice_id: string; | ||
type: 'adjustment' | 'refundable'; | ||
type: 'adjustment' | 'refundable' | 'store'; | ||
currency_code?: string; | ||
@@ -489,0 +490,0 @@ create_reason_code: string; |
@@ -7,3 +7,3 @@ ///<reference path='./../core.d.ts'/> | ||
reference_invoice_id: string; | ||
type: 'adjustment' | 'refundable'; | ||
type: 'adjustment' | 'refundable' | 'store'; | ||
price_type: PriceTypeEnum; | ||
@@ -10,0 +10,0 @@ currency_code: string; |
@@ -611,3 +611,2 @@ ///<reference path='./../core.d.ts'/> | ||
from_site: string; | ||
tax_providers_fields?: TaxProvidersFieldsMoveInputParam[]; | ||
} | ||
@@ -631,3 +630,2 @@ export interface ChangeBillingDateInputParam { | ||
to_customer_id: string; | ||
tax_providers_fields?: TaxProvidersFieldsMergeInputParam[]; | ||
} | ||
@@ -926,12 +924,2 @@ export interface RelationshipsInputParam { | ||
} | ||
export interface TaxProvidersFieldsMoveInputParam { | ||
provider_name?: string; | ||
field_id?: string; | ||
field_value?: string; | ||
} | ||
export interface TaxProvidersFieldsMergeInputParam { | ||
provider_name?: string; | ||
field_id?: string; | ||
field_value?: string; | ||
} | ||
export interface ParentAccountAccessRelationshipsInputParam { | ||
@@ -938,0 +926,0 @@ portal_edit_child_subscriptions?: 'yes' | 'view_only' | 'no'; |
@@ -20,2 +20,3 @@ ///<reference path='./../core.d.ts'/> | ||
business_entity_id?: string; | ||
deleted: boolean; | ||
} | ||
@@ -22,0 +23,0 @@ |
@@ -6,2 +6,3 @@ ///<reference path='./../core.d.ts'/> | ||
export interface Feature { | ||
[key: string]: unknown; | ||
id: string; | ||
@@ -8,0 +9,0 @@ name: string; |
@@ -57,2 +57,3 @@ ///<reference path='./../core.d.ts'/> | ||
line_item_taxes?: Invoice.LineItemTax[]; | ||
line_item_credits?: Invoice.LineItemCredit[]; | ||
line_item_tiers?: Invoice.LineItemTier[]; | ||
@@ -570,2 +571,7 @@ linked_payments?: Invoice.LinkedPayment[]; | ||
} | ||
export interface LineItemCredit { | ||
cn_id: string; | ||
applied_amount: number; | ||
line_item_id?: string; | ||
} | ||
export interface LineItemTier { | ||
@@ -632,2 +638,3 @@ line_item_id?: string; | ||
cn_status: 'adjusted' | 'refunded' | 'refund_due' | 'voided'; | ||
tax_application?: 'pre_tax' | 'post_tax'; | ||
} | ||
@@ -634,0 +641,0 @@ export interface AdjustmentCreditNote { |
@@ -19,2 +19,3 @@ ///<reference path='./../core.d.ts'/> | ||
line_item_tiers?: InvoiceEstimate.LineItemTier[]; | ||
line_item_credits?: InvoiceEstimate.LineItemCredit[]; | ||
line_item_discounts?: InvoiceEstimate.LineItemDiscount[]; | ||
@@ -129,2 +130,7 @@ round_off_amount?: number; | ||
} | ||
export interface LineItemCredit { | ||
cn_id: string; | ||
applied_amount: number; | ||
line_item_id?: string; | ||
} | ||
export interface LineItemDiscount { | ||
@@ -131,0 +137,0 @@ line_item_id: string; |
@@ -33,2 +33,3 @@ ///<reference path='./../core.d.ts'/> | ||
metadata?: any; | ||
deleted: boolean; | ||
business_entity_id?: string; | ||
@@ -35,0 +36,0 @@ } |
@@ -15,2 +15,3 @@ ///<reference path='./../core.d.ts'/> | ||
business_entity_id?: string; | ||
deleted: boolean; | ||
} | ||
@@ -17,0 +18,0 @@ |
@@ -51,2 +51,3 @@ ///<reference path='./../core.d.ts'/> | ||
show_description_in_quotes?: boolean; | ||
deleted: boolean; | ||
business_entity_id?: string; | ||
@@ -53,0 +54,0 @@ } |
@@ -320,3 +320,3 @@ ///<reference path='./../core.d.ts'/> | ||
amount?: number; | ||
type: 'adjustment' | 'refundable'; | ||
type: 'adjustment' | 'refundable' | 'store'; | ||
id: string; | ||
@@ -323,0 +323,0 @@ status: 'adjusted' | 'refunded' | 'refund_due' | 'voided'; |
@@ -18,2 +18,3 @@ ///<reference path='./../core.d.ts'/> | ||
business_entity_id?: string; | ||
deleted: boolean; | ||
} | ||
@@ -20,0 +21,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
917324
119
24588