diff --git a/package.json b/package.json index c1ca4d4..f86d7c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paystack/paystack-sdk", - "version": "1.2.1-beta.1", + "version": "1.2.1-beta.2", "description": "Paystack API wrapper for Node", "author": "Paystack (https://paystack.com/docs)", "keywords": [ diff --git a/src/index.ts b/src/index.ts index 96aec52..b6be4d6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,33 +1,66 @@ -import * as Resources from './apis' +import { Balance } from './apis/Balance'; +import { BulkCharge } from './apis/BulkCharge'; +import { Charge } from './apis/Charge'; +import { Customer } from './apis/Customer'; +import { DedicatedVirtualAccount } from './apis/DedicatedVirtualAccount'; +import { Dispute } from './apis/Dispute'; +import { Integration } from './apis/Integration'; +import { Page } from './apis/Page'; +import { PaymentRequest } from './apis/PaymentRequest'; +import { Plan } from './apis/Plan'; +import { Product } from './apis/Product'; +import { Refund } from './apis/Refund'; +import { Settlement } from './apis/Settlement'; +import { Split } from './apis/Split'; +import { Subaccount } from './apis/Subaccount'; +import { Subscription } from './apis/Subscription'; +import { Transaction } from './apis/Transaction'; +import { Transfer } from './apis/Transfer'; +import { TransferRecipient } from './apis/TransferRecipient'; +import { Verification } from './apis/Verification'; export class Paystack { - [index: string]: any + public readonly balance: Balance; + public readonly bulkCharge: BulkCharge; + public readonly charge: Charge; + public readonly customer: Customer; + public readonly dedicatedVirtualAccount: DedicatedVirtualAccount; + public readonly dispute: Dispute; + public readonly integration: Integration; + public readonly page: Page; + public readonly paymentRequest: PaymentRequest; + public readonly plan: Plan; + public readonly product: Product; + public readonly refund: Refund; + public readonly settlement: Settlement; + public readonly split: Split; + public readonly subaccount: Subaccount; + public readonly subscription: Subscription; + public readonly transaction: Transaction; + public readonly transfer: Transfer; + public readonly transferRecipient: TransferRecipient; + public readonly verification: Verification; constructor(apiKey: string) { - this.extend(apiKey) + this.balance = new Balance(apiKey); + this.bulkCharge = new BulkCharge(apiKey); + this.charge = new Charge(apiKey); + this.customer = new Customer(apiKey); + this.dedicatedVirtualAccount = new DedicatedVirtualAccount(apiKey); + this.dispute = new Dispute(apiKey); + this.integration = new Integration(apiKey); + this.page = new Page(apiKey); + this.paymentRequest = new PaymentRequest(apiKey); + this.plan = new Plan(apiKey); + this.product = new Product(apiKey); + this.refund = new Refund(apiKey); + this.settlement = new Settlement(apiKey); + this.split = new Split(apiKey); + this.subaccount = new Subaccount(apiKey); + this.subscription = new Subscription(apiKey); + this.transaction = new Transaction(apiKey); + this.transfer = new Transfer(apiKey); + this.transferRecipient = new TransferRecipient(apiKey); + this.verification = new Verification(apiKey); } - - private extend(apiKey: string) { - for (const resource in Resources) { - if (Resources[resource]) { - this[this.toCamelCase(resource)] = new Resources[resource][resource]( - apiKey - ); - } - } - } - - private toCamelCase(resource: string): string { - const _resource = this.cleanResourceKey(resource) - _resource.toLowerCase() - .replace(/\W+(.)/g, (_, chr) => chr.toUpperCase()); - - return _resource - } - - private cleanResourceKey(resource: string): string { - if(!resource) return null - return resource.toLowerCase().replace("api", "") - } - } \ No newline at end of file diff --git a/src/runtime.ts b/src/runtime.ts index 9b441a7..3f204fb 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -55,7 +55,7 @@ export class BaseAPI { path: tempPath, headers: { "authorization": `Bearer ${this.apiKey}`, - "user-agent": `@paystack/paystack-sdk - 1.2.1-beta.1` + "user-agent": `@paystack/paystack-sdk - 1.2.1-beta.2` } }