Skip to content

Commit

Permalink
feat: add download helper (PL-000) (#9)
Browse files Browse the repository at this point in the history
* feat: add download helper (PL-000)

* chore: update chargebee-typescript
  • Loading branch information
trs authored Nov 9, 2023
1 parent 88aaef0 commit c3ab1df
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"url": "https://github.com/voiceflow/nestjs-chargebee.git"
},
"scripts": {
"postinstall": "husky install",
"prepack": "pinst --disable",
"postpack": "pinst --enable",
"build": "yarn run-p build:cjs build:esm build:types",
Expand Down Expand Up @@ -46,7 +45,7 @@
]
},
"dependencies": {
"chargebee-typescript": "2.23.0"
"chargebee-typescript": "2.26.0"
},
"devDependencies": {
"@commitlint/cli": "^17.6.7",
Expand Down
2 changes: 2 additions & 0 deletions src/chargebee-resource-wrapper.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { UnbilledChargeResource } from "./resources/unbilled-charge-resource";
import { UsageResource } from "./resources/usage-resource";
import { VirtualBankAccountResource } from "./resources/virtual-bank-account-resource";
import { SubscriptionResource } from "./resources/subscription-resource";
import { DownloadResource } from "./resources/download.resource";

export class ChargebeeResourceWrapper {
constructor(private readonly client: ChargeBee) {}
Expand Down Expand Up @@ -88,4 +89,5 @@ export class ChargebeeResourceWrapper {
entitlementOverride = new EntitlementOverrideResource(this.client);
purchase = new PurchaseResource(this.client);
paymentVoucher = new PaymentVoucherResource(this.client);
download = new DownloadResource(this.client);
}
25 changes: 25 additions & 0 deletions src/resources/download.resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import https from "node:https";
import { ChargebeeResource } from "../chargebee-resource.class";

export class DownloadResource extends ChargebeeResource {
public readonly json = (url: string) =>
new Promise((resolve, reject) => {
https
.get(url, (res) => {
let body = "";

res.on("data", (chunk) => {
body += chunk;
});

res.once("end", () => {
try {
resolve(JSON.parse(body));
} catch (error) {
reject(error);
}
});
})
.once("error", (error) => reject(error));
});
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3150,12 +3150,12 @@ __metadata:
languageName: node
linkType: hard

"chargebee-typescript@npm:2.23.0":
version: 2.23.0
resolution: "chargebee-typescript@npm:2.23.0"
"chargebee-typescript@npm:2.26.0":
version: 2.26.0
resolution: "chargebee-typescript@npm:2.26.0"
dependencies:
q: ">=1.0.1"
checksum: 19f147a10dd7cfc32b9da45fce6b9b3f052f7987c3865ac24ca8e0eb0f1f540bf2a4c937c4f5ff28c407cbf5aac97dd8fc0f746ac34c772da45a4604d3069983
checksum: e9647776d864f57c2615448467249345459aeebc1e002749a7f7720d15a726ebe1f9d25804db8c5c86c79526b67ff6c56bda6b8255721f7b91e04cee5d3ebc3c
languageName: node
linkType: hard

Expand Down Expand Up @@ -7488,7 +7488,7 @@ __metadata:
"@types/supertest": ^2.0.12
"@typescript-eslint/eslint-plugin": ^6.2.1
"@typescript-eslint/parser": ^6.2.1
chargebee-typescript: 2.23.0
chargebee-typescript: 2.26.0
eslint: ^8.46.0
eslint-config-prettier: ^8.9.0
eslint-plugin-prettier: ^5.0.0
Expand Down

0 comments on commit c3ab1df

Please sign in to comment.