paystack-sdk 2.5.26 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +1,30 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Subscription = void 0;
13
4
  class Subscription {
14
5
  constructor(http) {
15
6
  this.http = http;
16
7
  }
17
- create(data) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- return yield this.http.post('/subscription', JSON.stringify(data));
20
- });
21
- }
22
- list(queryParams) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- return yield this.http.get('/subscription', { params: Object.assign({}, queryParams) });
25
- });
26
- }
27
- fetch(idOrCode) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return yield this.http.get(`/subscription/${idOrCode}`);
30
- });
31
- }
32
- enable(data) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return yield this.http.post('/subscription/enable', JSON.stringify(data));
35
- });
36
- }
37
- disable(data) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return yield this.http.post('/subscription/disable', JSON.stringify(data));
40
- });
41
- }
42
- generateSubscriptionLink(code) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return yield this.http.get(`/subscription/${code}/manage/link`);
45
- });
46
- }
47
- sendUpdateSubscriptionLink(code) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return yield this.http.post(`/subscription/${code}/manage/email`);
50
- });
8
+ async create(data) {
9
+ return await this.http.post('/subscription', JSON.stringify(data));
10
+ }
11
+ async list(queryParams) {
12
+ return await this.http.get('/subscription', { params: { ...queryParams } });
13
+ }
14
+ async fetch(idOrCode) {
15
+ return await this.http.get(`/subscription/${idOrCode}`);
16
+ }
17
+ async enable(data) {
18
+ return await this.http.post('/subscription/enable', JSON.stringify(data));
19
+ }
20
+ async disable(data) {
21
+ return await this.http.post('/subscription/disable', JSON.stringify(data));
22
+ }
23
+ async generateSubscriptionLink(code) {
24
+ return await this.http.get(`/subscription/${code}/manage/link`);
25
+ }
26
+ async sendUpdateSubscriptionLink(code) {
27
+ return await this.http.post(`/subscription/${code}/manage/email`);
51
28
  }
52
29
  }
53
30
  exports.Subscription = Subscription;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Transaction = void 0;
13
4
  /**
@@ -23,61 +14,41 @@ class Transaction {
23
14
  * Initialize a transaction
24
15
  * @param {InitializeTransaction} data **Body Param**
25
16
  */
26
- initialize(data) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return yield this.http.post('/transaction/initialize', JSON.stringify(data));
29
- });
17
+ async initialize(data) {
18
+ return await this.http.post('/transaction/initialize', JSON.stringify(data));
30
19
  }
31
- verify(reference) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return yield this.http.get(`/transaction/verify/${reference}`);
34
- });
20
+ async verify(reference) {
21
+ return await this.http.get(`/transaction/verify/${reference}`);
35
22
  }
36
- list(queryParams) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return yield this.http.get('/transaction', {
39
- params: Object.assign({}, queryParams),
40
- });
23
+ async list(queryParams) {
24
+ return await this.http.get('/transaction', {
25
+ params: { ...queryParams },
41
26
  });
42
27
  }
43
- fetch(id) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- return yield this.http.get(`/transaction/:${id}`);
46
- });
28
+ async fetch(id) {
29
+ return await this.http.get(`/transaction/:${id}`);
47
30
  }
48
- chargeAuthorization(data) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return yield this.http.post('/transaction/charge_authorization', JSON.stringify(data));
51
- });
31
+ async chargeAuthorization(data) {
32
+ return await this.http.post('/transaction/charge_authorization', JSON.stringify(data));
52
33
  }
53
- checkAuthorization(data) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return yield this.http.post('/transaction/check_authorization', JSON.stringify(data));
56
- });
34
+ async checkAuthorization(data) {
35
+ return await this.http.post('/transaction/check_authorization', JSON.stringify(data));
57
36
  }
58
- viewTimeline(id) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- return yield this.http.get(`/transaction/timeline/${id}`);
61
- });
37
+ async viewTimeline(id) {
38
+ return await this.http.get(`/transaction/timeline/${id}`);
62
39
  }
63
- total(queryParams) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- return yield this.http.get('/transaction/totals', {
66
- params: Object.assign({}, queryParams),
67
- });
40
+ async total(queryParams) {
41
+ return await this.http.get('/transaction/totals', {
42
+ params: { ...queryParams },
68
43
  });
69
44
  }
70
- export(queryParams) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- return yield this.http.get('/transaction/export', {
73
- params: Object.assign({}, queryParams),
74
- });
45
+ async export(queryParams) {
46
+ return await this.http.get('/transaction/export', {
47
+ params: { ...queryParams },
75
48
  });
76
49
  }
77
- partialDebit(data) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- return yield this.http.post('/transaction/partial_debit', JSON.stringify(data));
80
- });
50
+ async partialDebit(data) {
51
+ return await this.http.post('/transaction/partial_debit', JSON.stringify(data));
81
52
  }
82
53
  }
83
54
  exports.Transaction = Transaction;
@@ -1,48 +1,27 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Control = void 0;
13
4
  class Control {
14
5
  constructor(http) {
15
6
  this.http = http;
16
7
  }
17
- balance() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- return yield this.http.get('/balance');
20
- });
8
+ async balance() {
9
+ return await this.http.get('/balance');
21
10
  }
22
- ledgerBalance() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- return yield this.http.get('/balance/ledger');
25
- });
11
+ async ledgerBalance() {
12
+ return await this.http.get('/balance/ledger');
26
13
  }
27
- resendOTP(data) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return yield this.http.post('/transfer/resend_otp', JSON.stringify(data));
30
- });
14
+ async resendOTP(data) {
15
+ return await this.http.post('/transfer/resend_otp', JSON.stringify(data));
31
16
  }
32
- disableOTP() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return yield this.http.post('/transfer/disable_otp');
35
- });
17
+ async disableOTP() {
18
+ return await this.http.post('/transfer/disable_otp');
36
19
  }
37
- finalizeDisableOTP(otp) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return yield this.http.post('/transfer/disable_otp_finalize', JSON.stringify({ otp }));
40
- });
20
+ async finalizeDisableOTP(otp) {
21
+ return await this.http.post('/transfer/disable_otp_finalize', JSON.stringify({ otp }));
41
22
  }
42
- enableOTP() {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return yield this.http.post('/transfer/enable_otp');
45
- });
23
+ async enableOTP() {
24
+ return await this.http.post('/transfer/enable_otp');
46
25
  }
47
26
  }
48
27
  exports.Control = Control;
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Transfer = void 0;
13
4
  const control_1 = require("./control");
@@ -21,41 +12,29 @@ class Transfer {
21
12
  * Status of transfer object returned will be `pending` if OTP is disabled.
22
13
  * In the event that an OTP is required, status will read `otp`.
23
14
  */
24
- initiate(data) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return yield this.http.post('/transfer', JSON.stringify(data));
27
- });
15
+ async initiate(data) {
16
+ return await this.http.post('/transfer', JSON.stringify(data));
28
17
  }
29
18
  /**
30
19
  * # Finalize Transfer
31
20
  * Finalize an initiated transfer
32
21
  */
33
- finalize(transferCode, otp) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- return yield this.http.post('/transfer/finalize_transfer', JSON.stringify({ transfer_code: transferCode, otp }));
36
- });
22
+ async finalize(transferCode, otp) {
23
+ return await this.http.post('/transfer/finalize_transfer', JSON.stringify({ transfer_code: transferCode, otp }));
37
24
  }
38
- bulk(data) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return yield this.http.post('/transfer/bulk', JSON.stringify(data));
41
- });
25
+ async bulk(data) {
26
+ return await this.http.post('/transfer/bulk', JSON.stringify(data));
42
27
  }
43
- list(queryParams) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- return yield this.http.get('/transfer', {
46
- params: Object.assign({}, queryParams),
47
- });
28
+ async list(queryParams) {
29
+ return await this.http.get('/transfer', {
30
+ params: { ...queryParams },
48
31
  });
49
32
  }
50
- fetch(idOrCode) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- return yield this.http.get(`/transfer/${idOrCode}`);
53
- });
33
+ async fetch(idOrCode) {
34
+ return await this.http.get(`/transfer/${idOrCode}`);
54
35
  }
55
- verify(reference) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- return yield this.http.get(`transfer/verify/${reference}`);
58
- });
36
+ async verify(reference) {
37
+ return await this.http.get(`transfer/verify/${reference}`);
59
38
  }
60
39
  }
61
40
  exports.Transfer = Transfer;
@@ -10,8 +10,8 @@ export interface ResolveAccount {
10
10
  */
11
11
  bank_code: string;
12
12
  }
13
- export declare type AccountType = 'personal' | 'business';
14
- export declare type DocumentType = 'identityNumber' | 'passportNumber' | 'businessRegistrationNumber';
13
+ export type AccountType = 'personal' | 'business';
14
+ export type DocumentType = 'identityNumber' | 'passportNumber' | 'businessRegistrationNumber';
15
15
  export interface AccountResolved extends Response {
16
16
  data: {
17
17
  /**
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Verification = void 0;
13
4
  /**
@@ -23,10 +14,8 @@ class Verification {
23
14
  * Confirm an account belongs to the right customer
24
15
  * @param {ResolveAccount} data **Query Param**
25
16
  */
26
- resolveAccount(data) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return yield this.http.get('/bank/resolve', { params: Object.assign({}, data) });
29
- });
17
+ async resolveAccount(data) {
18
+ return await this.http.get('/bank/resolve', { params: { ...data } });
30
19
  }
31
20
  /**
32
21
  * #### Validate Account
@@ -34,10 +23,8 @@ class Verification {
34
23
  * before sending money
35
24
  * @param {ValidateAccount} data **Data Param**
36
25
  */
37
- validateAccount(data) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return yield this.http.post('/bank/validate', JSON.stringify(data));
40
- });
26
+ async validateAccount(data) {
27
+ return await this.http.post('/bank/validate', JSON.stringify(data));
41
28
  }
42
29
  /**
43
30
  * #### Resolve Card BIN
@@ -45,10 +32,8 @@ class Verification {
45
32
  * using the first 6 characters of the card
46
33
  * @param {string} bin **Path Param**
47
34
  */
48
- resolveCard(bin) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- return yield this.http.get(`/decision/bin/${bin}`);
51
- });
35
+ async resolveCard(bin) {
36
+ return await this.http.get(`/decision/bin/${bin}`);
52
37
  }
53
38
  }
54
39
  exports.Verification = Verification;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "2.5.26",
3
+ "version": "3.0.0",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "author": "Tech Priest",
@@ -9,23 +9,26 @@
9
9
  "scripts": {
10
10
  "build": "tsc",
11
11
  "format": "prettier --write \"src/**/*.ts\"",
12
- "lint": "tslint -p tsconfig.json",
12
+ "lint": "eslint . --ext .ts",
13
13
  "prepare": "npm run build",
14
14
  "prepublishOnly": "npm run lint",
15
15
  "preversion": "npm run lint",
16
16
  "version": "npm run format && git add -A src",
17
- "postversion": "git push && git push --tags"
17
+ "postversion": "git push && git push --tags",
18
+ "test": "jest"
18
19
  },
19
20
  "devDependencies": {
21
+ "@types/jest": "^30.0.0",
22
+ "@types/mocha": "^10.0.10",
20
23
  "@types/node": "16.11.11",
21
24
  "@typescript-eslint/eslint-plugin": "5.36.2",
22
25
  "@typescript-eslint/parser": "5.36.2",
23
26
  "eslint": "8.6.0",
27
+ "jest": "^30.0.5",
24
28
  "prettier": "2.5.1",
29
+ "ts-jest": "^29.4.1",
25
30
  "ts-node": "10.4.0",
26
- "tslint": "6.1.3",
27
- "tslint-config-prettier": "1.18.0",
28
- "typescript": "4.5.2",
31
+ "typescript": "5.5",
29
32
  "typescript-eslint": "0.0.1-alpha.0"
30
33
  },
31
34
  "dependencies": {