Skip to content

Commit 83964ae

Browse files
Patch: (DX) Type export for autocomplete
1 parent 219b08a commit 83964ae

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@paystack/paystack-sdk",
3-
"version": "1.2.1-beta.1",
3+
"version": "1.2.1-beta.2",
44
"description": "Paystack API wrapper for Node",
55
"author": "Paystack <integrations@paystack.com> (https://paystack.com/docs)",
66
"keywords": [

src/index.ts

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,66 @@
1-
import * as Resources from './apis'
1+
import { Balance } from './apis/Balance';
2+
import { BulkCharge } from './apis/BulkCharge';
3+
import { Charge } from './apis/Charge';
4+
import { Customer } from './apis/Customer';
5+
import { DedicatedVirtualAccount } from './apis/DedicatedVirtualAccount';
6+
import { Dispute } from './apis/Dispute';
7+
import { Integration } from './apis/Integration';
8+
import { Page } from './apis/Page';
9+
import { PaymentRequest } from './apis/PaymentRequest';
10+
import { Plan } from './apis/Plan';
11+
import { Product } from './apis/Product';
12+
import { Refund } from './apis/Refund';
13+
import { Settlement } from './apis/Settlement';
14+
import { Split } from './apis/Split';
15+
import { Subaccount } from './apis/Subaccount';
16+
import { Subscription } from './apis/Subscription';
17+
import { Transaction } from './apis/Transaction';
18+
import { Transfer } from './apis/Transfer';
19+
import { TransferRecipient } from './apis/TransferRecipient';
20+
import { Verification } from './apis/Verification';
221

322
export class Paystack {
4-
[index: string]: any
23+
public readonly balance: Balance;
24+
public readonly bulkCharge: BulkCharge;
25+
public readonly charge: Charge;
26+
public readonly customer: Customer;
27+
public readonly dedicatedVirtualAccount: DedicatedVirtualAccount;
28+
public readonly dispute: Dispute;
29+
public readonly integration: Integration;
30+
public readonly page: Page;
31+
public readonly paymentRequest: PaymentRequest;
32+
public readonly plan: Plan;
33+
public readonly product: Product;
34+
public readonly refund: Refund;
35+
public readonly settlement: Settlement;
36+
public readonly split: Split;
37+
public readonly subaccount: Subaccount;
38+
public readonly subscription: Subscription;
39+
public readonly transaction: Transaction;
40+
public readonly transfer: Transfer;
41+
public readonly transferRecipient: TransferRecipient;
42+
public readonly verification: Verification;
543

644
constructor(apiKey: string) {
7-
this.extend(apiKey)
45+
this.balance = new Balance(apiKey);
46+
this.bulkCharge = new BulkCharge(apiKey);
47+
this.charge = new Charge(apiKey);
48+
this.customer = new Customer(apiKey);
49+
this.dedicatedVirtualAccount = new DedicatedVirtualAccount(apiKey);
50+
this.dispute = new Dispute(apiKey);
51+
this.integration = new Integration(apiKey);
52+
this.page = new Page(apiKey);
53+
this.paymentRequest = new PaymentRequest(apiKey);
54+
this.plan = new Plan(apiKey);
55+
this.product = new Product(apiKey);
56+
this.refund = new Refund(apiKey);
57+
this.settlement = new Settlement(apiKey);
58+
this.split = new Split(apiKey);
59+
this.subaccount = new Subaccount(apiKey);
60+
this.subscription = new Subscription(apiKey);
61+
this.transaction = new Transaction(apiKey);
62+
this.transfer = new Transfer(apiKey);
63+
this.transferRecipient = new TransferRecipient(apiKey);
64+
this.verification = new Verification(apiKey);
865
}
9-
10-
private extend(apiKey: string) {
11-
for (const resource in Resources) {
12-
if (Resources[resource]) {
13-
this[this.toCamelCase(resource)] = new Resources[resource][resource](
14-
apiKey
15-
);
16-
}
17-
}
18-
}
19-
20-
private toCamelCase(resource: string): string {
21-
const _resource = this.cleanResourceKey(resource)
22-
_resource.toLowerCase()
23-
.replace(/\W+(.)/g, (_, chr) => chr.toUpperCase());
24-
25-
return _resource
26-
}
27-
28-
private cleanResourceKey(resource: string): string {
29-
if(!resource) return null
30-
return resource.toLowerCase().replace("api", "")
31-
}
32-
3366
}

src/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class BaseAPI {
5555
path: tempPath,
5656
headers: {
5757
"authorization": `Bearer ${this.apiKey}`,
58-
"user-agent": `@paystack/paystack-sdk - 1.2.1-beta.1`
58+
"user-agent": `@paystack/paystack-sdk - 1.2.1-beta.2`
5959
}
6060
}
6161

0 commit comments

Comments
 (0)