Skip to content

Commit cfa4002

Browse files
Merge pull request #3 from PaystackOSS/feat/doc-gen
Cleanup for version 1
2 parents 96421d7 + b17425d commit cfa4002

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

README.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,51 @@ npm install @paystack/paystack-sdk --save
1313

1414
## Usage
1515
Import and initialize the library:
16+
```javascript
17+
const Paystack = require('@paystack/paystack-sdk')
18+
const paystack = new Paystack("sk_test_xxxxxx")
19+
20+
paystack.transaction.initialize({email: "test@example.com", amount: 20000})
21+
.then(response => console.log(response))
22+
.catch(error => console.log(error))
1623
```
24+
25+
Import and initialize the library using ES module with `async/await`:
26+
```javascript
1727
import Paystack from '@paystack/paystack-sdk'
1828
const paystack = new Paystack("sk_test_xxxxxx")
19-
```
2029

21-
Initiate a request and parse response:
30+
const initialize = async(email, amount) => {
31+
const response = await paystack.transaction.initialize({
32+
email,
33+
amount
34+
})
35+
36+
console.log(response)
37+
}
38+
39+
const email = 'test@example.com'
40+
const amount = 2000
41+
initialize(email, amount)
2242
```
23-
paystack.customer.fetch({code: "CUS_o9rf5kuwei3lt4vl"})
24-
.then(customer => console.log(customer))
25-
.catch(error => console.log(error))
43+
44+
### Typescript
45+
```typescript
46+
import Paystack from '@paystack/paystack-sdk';
47+
const paystack = new Paystack("sk_test_xxxxxx");
48+
49+
const initialize = async(email, amount) => {
50+
const response = await paystack.transaction.initialize({
51+
email,
52+
amount
53+
});
54+
55+
console.log(response);
56+
}
57+
58+
const email = 'test@example.com';
59+
const amount = 2000;
60+
initialize(email, amount);
2661
```
2762

2863
## Issues

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.0.0-beta.6",
3+
"version": "1.0.0",
44
"description": "Paystack API wrapper for Node",
55
"author": "Paystack <integrations@paystack.com> (https://paystack.com/docs)",
66
"keywords": [

src/apis/Customer.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface UpdateRequest {
5959
metadata?: string;
6060
}
6161

62-
export interface ValidatteRequest {
62+
export interface ValidateRequest {
6363
code: string;
6464
first_name: string;
6565
last_name: string;
@@ -282,30 +282,30 @@ export class Customer extends BaseAPI {
282282
* Validate a customer\'s identity
283283
* Validate Customer
284284
*/
285-
async validatte(requestParameters: ValidatteRequest): Promise<Accepted> {
285+
async validate(requestParameters: ValidateRequest): Promise<Accepted> {
286286
if (requestParameters.code === null || requestParameters.code === undefined) {
287-
throw new RequiredError('code','Required parameter code was null or undefined when calling validatte.');
287+
throw new RequiredError('code','Required parameter code was null or undefined when calling validate.');
288288
}
289289
if (requestParameters.first_name === null || requestParameters.first_name === undefined) {
290-
throw new RequiredError('first_name','Required parameter first_name was null or undefined when calling validatte.');
290+
throw new RequiredError('first_name','Required parameter first_name was null or undefined when calling validate.');
291291
}
292292
if (requestParameters.last_name === null || requestParameters.last_name === undefined) {
293-
throw new RequiredError('last_name','Required parameter last_name was null or undefined when calling validatte.');
293+
throw new RequiredError('last_name','Required parameter last_name was null or undefined when calling validate.');
294294
}
295295
if (requestParameters.type === null || requestParameters.type === undefined) {
296-
throw new RequiredError('type','Required parameter type was null or undefined when calling validatte.');
296+
throw new RequiredError('type','Required parameter type was null or undefined when calling validate.');
297297
}
298298
if (requestParameters.country === null || requestParameters.country === undefined) {
299-
throw new RequiredError('country','Required parameter country was null or undefined when calling validatte.');
299+
throw new RequiredError('country','Required parameter country was null or undefined when calling validate.');
300300
}
301301
if (requestParameters.bvn === null || requestParameters.bvn === undefined) {
302-
throw new RequiredError('bvn','Required parameter bvn was null or undefined when calling validatte.');
302+
throw new RequiredError('bvn','Required parameter bvn was null or undefined when calling validate.');
303303
}
304304
if (requestParameters.bank_code === null || requestParameters.bank_code === undefined) {
305-
throw new RequiredError('bank_code','Required parameter bank_code was null or undefined when calling validatte.');
305+
throw new RequiredError('bank_code','Required parameter bank_code was null or undefined when calling validate.');
306306
}
307307
if (requestParameters.account_number === null || requestParameters.account_number === undefined) {
308-
throw new RequiredError('account_number','Required parameter account_number was null or undefined when calling validatte.');
308+
throw new RequiredError('account_number','Required parameter account_number was null or undefined when calling validate.');
309309
}
310310
const queryParameters: any = {};
311311

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ class Paystack {
3030

3131
}
3232

33-
module.exports = Paystack
33+
module.exports = Paystack;
34+
module.exports.default = Paystack;

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-
"paystack-version": `@paystack/paystack-sdk - 1.0.0-beta.6`
58+
"user-agent": `@paystack/paystack-sdk - 1.0.0`
5959
}
6060
}
6161

0 commit comments

Comments
 (0)