Skip to content

Commit

Permalink
* * *
Browse files Browse the repository at this point in the history
* Added return types to all api requests.
* Fixed validation logic for IDparam.
* Included typescript related packages to devDependencies.
* Exposed function chargebee#updateRequestTimeoutInMillis to set custom time out.
* Updated default request timeout to 80000ms.

* payment_sources#update_bank_account have been added in payment_sources resource.
* item_price#item_price_find_applicable_items and item_price#item_price_find_applicable_item_prices have been added in item_price resource.

* hsn_code have been added to the resource addon, item_price and plan.
* first_name, last_name and email have been added to the resource payment_sources.

* TaxWithheld has been added.Applicable only for API V2.

* hsn_code have been added to addons#create_an_addon, addons#update_an_addon, plan#create_an_plan and plan#update_an_plan  apis.
* bank_account[first_name],bank_account[last_name] and bank_account[email] have been added to payment_sources#update_bank_account api.
* charges[hsn_code] have been added in estimate#Create_Invoice, estimate#Create_Invoice_For_Items, hosted_pages#Checkout_One_Time, hosted_pages#Checkout_One_Time_For_Items, invoice#create_an_invoice, invoice#Create_For_Charge_Items_And_Charges and unbilledCharge#create_an_unbilledCharge apis.
* tax_detail[hsn_code] have been added in item_price#create_an_itemPrice and item_price#update_an_itemPrice apis.
* include_deleted have been added in plan#plan_list and addon#addon_list apis.Applicable only for Product Catalog V1.

* subscription_activated_with_backdating, tax_withheld_recorded, tax_withheld_deleted and tax_withheld_refunded has been added to event_type enum.
  • Loading branch information
cb-khushbubibay committed Dec 8, 2021
1 parent bfbb272 commit 24c3398
Show file tree
Hide file tree
Showing 43 changed files with 500 additions and 328 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
### v2.4.0 (2021-12-08)
* * *

#### Fixes:
* Added return types to all api requests.
* Fixed validation logic for IDparam.
* Included typescript related packages to devDependencies.
* Exposed function chargebee#updateRequestTimeoutInMillis to set custom time out.
* Updated default request timeout to 80000ms.

#### New endpoints:
* payment_sources#update_bank_account have been added in payment_sources resource.
* item_price#item_price_find_applicable_items and item_price#item_price_find_applicable_item_prices have been added in item_price resource.

#### New Attributes:
* hsn_code have been added to the resource addon, item_price and plan.
* first_name, last_name and email have been added to the resource payment_sources.

#### New Resource:
* TaxWithheld has been added.Applicable only for API V2.

#### New Input parameters:
* hsn_code have been added to addons#create_an_addon, addons#update_an_addon, plan#create_an_plan and plan#update_an_plan apis.
* bank_account[first_name],bank_account[last_name] and bank_account[email] have been added to payment_sources#update_bank_account api.
* charges[hsn_code] have been added in estimate#Create_Invoice, estimate#Create_Invoice_For_Items, hosted_pages#Checkout_One_Time, hosted_pages#Checkout_One_Time_For_Items, invoice#create_an_invoice, invoice#Create_For_Charge_Items_And_Charges and unbilledCharge#create_an_unbilledCharge apis.
* tax_detail[hsn_code] have been added in item_price#create_an_itemPrice and item_price#update_an_itemPrice apis.
* include_deleted have been added in plan#plan_list and addon#addon_list apis.Applicable only for Product Catalog V1.

#### New Enum values:
* subscription_activated_with_backdating, tax_withheld_recorded, tax_withheld_deleted and tax_withheld_refunded has been added to event_type enum.

### v2.3.0 (2021-10-14)
* * *

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chargebee-typescript",
"version": "2.3.0",
"version": "2.4.0",
"description": "A library in typescript for integrating with Chargebee.",
"keywords": [
"payments",
Expand All @@ -17,12 +17,12 @@
"lib/**/*"
],
"dependencies": {
"q": ">=1.0.1",
"typescript": "^3.9.3"
"q": ">=1.0.1"
},
"devDependencies": {
"@types/node": "^13.13.4",
"@types/q": "^1.5.2"
"@types/node": "^13.13.52",
"@types/q": "^1.5.2",
"typescript": "^3.9.3"
},
"directories": {
"lib": "./lib"
Expand Down
8 changes: 8 additions & 0 deletions src/chargebee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {_virtual_bank_account} from "./resources/virtual_bank_account";
export {_card} from "./resources/card";
export {_promotional_credit} from "./resources/promotional_credit";
export {_invoice} from "./resources/invoice";
export {_tax_withheld} from "./resources/tax_withheld";
export {_credit_note} from "./resources/credit_note";
export {_unbilled_charge} from "./resources/unbilled_charge";
export {_order} from "./resources/order";
Expand Down Expand Up @@ -53,6 +54,10 @@ export class ChargeBee {
Util.extend(true, ChargeBee._env, conf)
}

public updateRequestTimeoutInMillis(timeout){
ChargeBee._env.timeout = timeout;
}

get subscription() {
return resources.Subscription;
}
Expand Down Expand Up @@ -92,6 +97,9 @@ export class ChargeBee {
get invoice() {
return resources.Invoice;
}
get tax_withheld() {
return resources.TaxWithheld;
}
get credit_note() {
return resources.CreditNote;
}
Expand Down
4 changes: 2 additions & 2 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ let environment = {
protocol: 'https',
hostSuffix: '.chargebee.com',
apiPath: '/api/v2',
timeout: 40000,
clientVersion: 'v2.3.0',
timeout: 80000,
clientVersion: 'v2.4.0',
port: 443,
timemachineWaitInMillis: 3000,
exportWaitInMillis: 3000
Expand Down
4 changes: 2 additions & 2 deletions src/request_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class RequestWrapper {
}
}

private static validateIdParam(idParam: any) {
if (idParam.toString().trim() < 1 || typeof idParam === 'undefined' || typeof idParam !== 'string') {
private static validateIdParam(idParam: string) {
if (!idParam || idParam.trim().length < 1) {
throw new Error('the required id parameter missing or wrong');
}
return idParam;
Expand Down
18 changes: 11 additions & 7 deletions src/resources/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Addon extends Model {
public archived_at?: number;
public enabled_in_portal: boolean;
public tax_code?: string;
public hsn_code?: string;
public taxjar_product_code?: string;
public avalara_sale_type?: string;
public avalara_transaction_type?: number;
Expand Down Expand Up @@ -51,7 +52,7 @@ export class Addon extends Model {
// OPERATIONS
//-----------

public static create(params?: _addon.create_params) {
public static create(params?: _addon.create_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'create',
'httpMethod': 'POST',
Expand All @@ -62,7 +63,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static update(addon_id: string, params?: _addon.update_params) {
public static update(addon_id: string, params?: _addon.update_params):RequestWrapper {
return new RequestWrapper([addon_id, params], {
'methodName': 'update',
'httpMethod': 'POST',
Expand All @@ -73,7 +74,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static list(params?: _addon.addon_list_params) {
public static list(params?: _addon.addon_list_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'list',
'httpMethod': 'GET',
Expand All @@ -84,7 +85,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static retrieve(addon_id: string, params?: any) {
public static retrieve(addon_id: string, params?: any):RequestWrapper {
return new RequestWrapper([addon_id, params], {
'methodName': 'retrieve',
'httpMethod': 'GET',
Expand All @@ -95,7 +96,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static delete(addon_id: string, params?: any) {
public static delete(addon_id: string, params?: any):RequestWrapper {
return new RequestWrapper([addon_id, params], {
'methodName': 'delete',
'httpMethod': 'POST',
Expand All @@ -106,7 +107,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static copy(params?: _addon.copy_params) {
public static copy(params?: _addon.copy_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'copy',
'httpMethod': 'POST',
Expand All @@ -117,7 +118,7 @@ export class Addon extends Model {
}, ChargeBee._env)
}

public static unarchive(addon_id: string, params?: any) {
public static unarchive(addon_id: string, params?: any):RequestWrapper {
return new RequestWrapper([addon_id, params], {
'methodName': 'unarchive',
'httpMethod': 'POST',
Expand Down Expand Up @@ -168,6 +169,7 @@ export namespace _addon {
avalara_transaction_type?: number;
avalara_service_type?: number;
tax_code?: string;
hsn_code?: string;
taxjar_product_code?: string;
invoice_notes?: string;
meta_data?: any;
Expand Down Expand Up @@ -209,6 +211,7 @@ export namespace _addon {
avalara_transaction_type?: number;
avalara_service_type?: number;
tax_code?: string;
hsn_code?: string;
taxjar_product_code?: string;
invoice_notes?: string;
meta_data?: any;
Expand Down Expand Up @@ -244,6 +247,7 @@ export namespace _addon {
status?: filter._enum;
updated_at?: filter._timestamp;
currency_code?: filter._string;
include_deleted?: boolean;
}
export interface copy_params {
from_site: string;
Expand Down
4 changes: 2 additions & 2 deletions src/resources/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Address extends Model {
// OPERATIONS
//-----------

public static retrieve(params?: _address.retrieve_params) {
public static retrieve(params?: _address.retrieve_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'retrieve',
'httpMethod': 'GET',
Expand All @@ -38,7 +38,7 @@ export class Address extends Model {
}, ChargeBee._env)
}

public static update(params?: _address.update_params) {
public static update(params?: _address.update_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'update',
'httpMethod': 'POST',
Expand Down
10 changes: 5 additions & 5 deletions src/resources/attached_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class AttachedItem extends Model {
// OPERATIONS
//-----------

public static create(item_id: string, params?: _attached_item.create_params) {
public static create(item_id: string, params?: _attached_item.create_params):RequestWrapper {
return new RequestWrapper([item_id, params], {
'methodName': 'create',
'httpMethod': 'POST',
Expand All @@ -35,7 +35,7 @@ export class AttachedItem extends Model {
}, ChargeBee._env)
}

public static update(attached_item_id: string, params?: _attached_item.update_params) {
public static update(attached_item_id: string, params?: _attached_item.update_params):RequestWrapper {
return new RequestWrapper([attached_item_id, params], {
'methodName': 'update',
'httpMethod': 'POST',
Expand All @@ -46,7 +46,7 @@ export class AttachedItem extends Model {
}, ChargeBee._env)
}

public static retrieve(attached_item_id: string, params?: _attached_item.retrieve_params) {
public static retrieve(attached_item_id: string, params?: _attached_item.retrieve_params):RequestWrapper {
return new RequestWrapper([attached_item_id, params], {
'methodName': 'retrieve',
'httpMethod': 'GET',
Expand All @@ -57,7 +57,7 @@ export class AttachedItem extends Model {
}, ChargeBee._env)
}

public static delete(attached_item_id: string, params?: _attached_item.delete_params) {
public static delete(attached_item_id: string, params?: _attached_item.delete_params):RequestWrapper {
return new RequestWrapper([attached_item_id, params], {
'methodName': 'delete',
'httpMethod': 'POST',
Expand All @@ -68,7 +68,7 @@ export class AttachedItem extends Model {
}, ChargeBee._env)
}

public static list(item_id: string, params?: _attached_item.attached_item_list_params) {
public static list(item_id: string, params?: _attached_item.attached_item_list_params):RequestWrapper {
return new RequestWrapper([item_id, params], {
'methodName': 'list',
'httpMethod': 'GET',
Expand Down
10 changes: 5 additions & 5 deletions src/resources/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Card extends Model {
// OPERATIONS
//-----------

public static retrieve(card_id: string, params?: any) {
public static retrieve(card_id: string, params?: any):RequestWrapper {
return new RequestWrapper([card_id, params], {
'methodName': 'retrieve',
'httpMethod': 'GET',
Expand All @@ -50,7 +50,7 @@ export class Card extends Model {
}, ChargeBee._env)
}

public static update_card_for_customer(customer_id: string, params?: _card.update_card_for_customer_params) {
public static update_card_for_customer(customer_id: string, params?: _card.update_card_for_customer_params):RequestWrapper {
return new RequestWrapper([customer_id, params], {
'methodName': 'update_card_for_customer',
'httpMethod': 'POST',
Expand All @@ -61,7 +61,7 @@ export class Card extends Model {
}, ChargeBee._env)
}

public static switch_gateway_for_customer(customer_id: string, params?: _card.switch_gateway_for_customer_params) {
public static switch_gateway_for_customer(customer_id: string, params?: _card.switch_gateway_for_customer_params):RequestWrapper {
return new RequestWrapper([customer_id, params], {
'methodName': 'switch_gateway_for_customer',
'httpMethod': 'POST',
Expand All @@ -72,7 +72,7 @@ export class Card extends Model {
}, ChargeBee._env)
}

public static copy_card_for_customer(customer_id: string, params?: _card.copy_card_for_customer_params) {
public static copy_card_for_customer(customer_id: string, params?: _card.copy_card_for_customer_params):RequestWrapper {
return new RequestWrapper([customer_id, params], {
'methodName': 'copy_card_for_customer',
'httpMethod': 'POST',
Expand All @@ -83,7 +83,7 @@ export class Card extends Model {
}, ChargeBee._env)
}

public static delete_card_for_customer(customer_id: string, params?: any) {
public static delete_card_for_customer(customer_id: string, params?: any):RequestWrapper {
return new RequestWrapper([customer_id, params], {
'methodName': 'delete_card_for_customer',
'httpMethod': 'POST',
Expand Down
8 changes: 4 additions & 4 deletions src/resources/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Comment extends Model {
// OPERATIONS
//-----------

public static create(params?: _comment.create_params) {
public static create(params?: _comment.create_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'create',
'httpMethod': 'POST',
Expand All @@ -29,7 +29,7 @@ export class Comment extends Model {
}, ChargeBee._env)
}

public static retrieve(comment_id: string, params?: any) {
public static retrieve(comment_id: string, params?: any):RequestWrapper {
return new RequestWrapper([comment_id, params], {
'methodName': 'retrieve',
'httpMethod': 'GET',
Expand All @@ -40,7 +40,7 @@ export class Comment extends Model {
}, ChargeBee._env)
}

public static list(params?: _comment.comment_list_params) {
public static list(params?: _comment.comment_list_params):RequestWrapper {
return new RequestWrapper([params], {
'methodName': 'list',
'httpMethod': 'GET',
Expand All @@ -51,7 +51,7 @@ export class Comment extends Model {
}, ChargeBee._env)
}

public static delete(comment_id: string, params?: any) {
public static delete(comment_id: string, params?: any):RequestWrapper {
return new RequestWrapper([comment_id, params], {
'methodName': 'delete',
'httpMethod': 'POST',
Expand Down
Loading

0 comments on commit 24c3398

Please sign in to comment.