paystack-sdk 2.3.1 → 2.4.1

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.
@@ -6,6 +6,7 @@ import { Invoice } from './invoice/invoice';
6
6
  import { PaymentPage } from './payment/payment';
7
7
  import { Plan } from './plan';
8
8
  import { Product } from './product/product';
9
+ import { Recipient } from './recipient/recipient';
9
10
  import { Settlement } from './settlement/settlement';
10
11
  import { TransactionSplit } from './split/split';
11
12
  import { SubAccount } from './subaccounts/subaccount';
@@ -33,5 +34,6 @@ export declare class Paystack {
33
34
  page: PaymentPage;
34
35
  invoice: Invoice;
35
36
  settlement: Settlement;
37
+ recipient: Recipient;
36
38
  constructor(key: string);
37
39
  }
package/dist/paystack.js CHANGED
@@ -10,6 +10,7 @@ const invoice_1 = require("./invoice/invoice");
10
10
  const payment_1 = require("./payment/payment");
11
11
  const plan_1 = require("./plan");
12
12
  const product_1 = require("./product/product");
13
+ const recipient_1 = require("./recipient/recipient");
13
14
  const settlement_1 = require("./settlement/settlement");
14
15
  const split_1 = require("./split/split");
15
16
  const subaccount_1 = require("./subaccounts/subaccount");
@@ -45,6 +46,7 @@ class Paystack {
45
46
  this.page = new payment_1.PaymentPage(this.http);
46
47
  this.invoice = new invoice_1.Invoice(this.http);
47
48
  this.settlement = new settlement_1.Settlement(this.http);
49
+ this.recipient = new recipient_1.Recipient(this.http);
48
50
  }
49
51
  }
50
52
  exports.Paystack = Paystack;
@@ -0,0 +1,73 @@
1
+ import { Meta, Response } from '../interface';
2
+ export interface CreateRecipient {
3
+ /**
4
+ * Recipient Type.
5
+ * It could be one of: `nuban`, `mobile_money` or `basa`
6
+ */
7
+ type: string;
8
+ /** A name for the recipient */
9
+ name: string;
10
+ /** Required if type is `nuban` or `basa` */
11
+ account_number: string;
12
+ /**
13
+ * Required if type is nuban or basa.
14
+ * You can get the list of Bank Codes by calling the List Banks endpoint.
15
+ */
16
+ bank_code: string;
17
+ /** A description for this recipient */
18
+ description?: string;
19
+ /** Currency for the account receiving the transfer */
20
+ currency?: string;
21
+ /** An authorization code from a previous transaction */
22
+ authorization_code?: string;
23
+ /**
24
+ * Store additional information about your
25
+ * recipient in a structured format, JSON
26
+ */
27
+ metadata?: Record<string, unknown>;
28
+ }
29
+ export interface UpdateRecipient {
30
+ name: string;
31
+ email?: string;
32
+ }
33
+ export interface Recipient {
34
+ id: number;
35
+ active: boolean;
36
+ createdAt: Date;
37
+ currency: string;
38
+ description?: string;
39
+ domain: string;
40
+ email?: string;
41
+ integration: number;
42
+ metadata?: Record<string, unknown>;
43
+ name: string;
44
+ recipient_code: string;
45
+ type: string;
46
+ updatedAt: Date;
47
+ is_deleted: boolean;
48
+ isDeleted: boolean;
49
+ details: RecipientDetails;
50
+ }
51
+ export interface RecipientDetails {
52
+ authorization_code?: string;
53
+ account_number: string;
54
+ account_name: string;
55
+ bank_code: string;
56
+ bank_name: string;
57
+ }
58
+ export interface ViewRecipientResponse extends Response {
59
+ data: Recipient;
60
+ }
61
+ export interface RecipientCreatedResponse extends Response {
62
+ data: Recipient;
63
+ }
64
+ export interface BulkRecipientsCreatedResponse extends Response {
65
+ data: {
66
+ success: Recipient[];
67
+ errors: Record<string, unknown>[];
68
+ };
69
+ }
70
+ export interface ListRecipientResponse extends Response {
71
+ data: Recipient[];
72
+ meta: Meta;
73
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { Axios } from 'axios';
2
+ import { BadRequest, QueryParams, Response } from '../interface';
3
+ import { CreateRecipient, ListRecipientResponse, RecipientCreatedResponse, UpdateRecipient, ViewRecipientResponse } from './interface';
4
+ export declare class Recipient {
5
+ private http;
6
+ constructor(http: Axios);
7
+ create(data: CreateRecipient | CreateRecipient[], isBulk?: boolean): Promise<RecipientCreatedResponse | BadRequest>;
8
+ list(queryParams?: QueryParams): Promise<ListRecipientResponse | BadRequest>;
9
+ fetch(id: string): Promise<ViewRecipientResponse | BadRequest>;
10
+ update(id: string, data: UpdateRecipient): Promise<ViewRecipientResponse | BadRequest>;
11
+ delete(id: string): Promise<Response | BadRequest>;
12
+ }
@@ -0,0 +1,52 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Recipient = void 0;
13
+ class Recipient {
14
+ constructor(http) {
15
+ this.http = http;
16
+ }
17
+ create(data, isBulk) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ let body;
20
+ let url = '/transferrecipient';
21
+ body = data;
22
+ if (isBulk)
23
+ url += '/bulk';
24
+ if (isBulk)
25
+ body = { batch: data };
26
+ return yield this.http.post(url, JSON.stringify(body));
27
+ });
28
+ }
29
+ list(queryParams) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return yield this.http.get('/transferrecipient', {
32
+ params: Object.assign({}, queryParams),
33
+ });
34
+ });
35
+ }
36
+ fetch(id) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return yield this.http.get(`/transferrecipient/${id}`);
39
+ });
40
+ }
41
+ update(id, data) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ return yield this.http.put(`/transferrecipient/${id}`, JSON.stringify(data));
44
+ });
45
+ }
46
+ delete(id) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ return yield this.http.delete(`/transferrecipient/${id}`);
49
+ });
50
+ }
51
+ }
52
+ exports.Recipient = Recipient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paystack-sdk",
3
- "version": "2.3.1",
3
+ "version": "2.4.1",
4
4
  "description": "Paystack SDK written in Typescript",
5
5
  "main": "dist/index.js",
6
6
  "author": "Tech Priest",