paj_ramp 1.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.
Files changed (58) hide show
  1. package/README.md +254 -0
  2. package/__tests__/getTXPoolAddress.test.ts +24 -0
  3. package/dist/index.d.ts +11 -0
  4. package/dist/index.js +16 -0
  5. package/dist/lib/addBankAccount.d.ts +21 -0
  6. package/dist/lib/addBankAccount.js +30 -0
  7. package/dist/lib/addWallet.d.ts +11 -0
  8. package/dist/lib/addWallet.js +27 -0
  9. package/dist/lib/getBankAccounts.d.ts +18 -0
  10. package/dist/lib/getBankAccounts.js +22 -0
  11. package/dist/lib/getBanks.d.ts +17 -0
  12. package/dist/lib/getBanks.js +20 -0
  13. package/dist/lib/getRate.d.ts +26 -0
  14. package/dist/lib/getRate.js +23 -0
  15. package/dist/lib/getTXPoolAddress.d.ts +13 -0
  16. package/dist/lib/getTXPoolAddress.js +20 -0
  17. package/dist/lib/getWallet.d.ts +24 -0
  18. package/dist/lib/getWallet.js +23 -0
  19. package/dist/lib/initiate.d.ts +18 -0
  20. package/dist/lib/initiate.js +23 -0
  21. package/dist/lib/resolveBankAccount.d.ts +26 -0
  22. package/dist/lib/resolveBankAccount.js +24 -0
  23. package/dist/lib/switchWalletBankAccount.d.ts +2 -0
  24. package/dist/lib/switchWalletBankAccount.js +19 -0
  25. package/dist/lib/verify.d.ts +21 -0
  26. package/dist/lib/verify.js +25 -0
  27. package/dist/utils/api.d.ts +80 -0
  28. package/dist/utils/api.js +122 -0
  29. package/dist/utils/axios.d.ts +2 -0
  30. package/dist/utils/axios.js +8 -0
  31. package/dist/utils/generateSignature.d.ts +12 -0
  32. package/dist/utils/generateSignature.js +17 -0
  33. package/dist/utils/getWalletBody.d.ts +15 -0
  34. package/dist/utils/getWalletBody.js +36 -0
  35. package/dist/utils/verifySignature.d.ts +17 -0
  36. package/dist/utils/verifySignature.js +18 -0
  37. package/generateWallet.js +8 -0
  38. package/index.ts +20 -0
  39. package/jest.config.js +8 -0
  40. package/lib/addBankAccount.ts +39 -0
  41. package/lib/addWallet.ts +33 -0
  42. package/lib/getBankAccounts.ts +33 -0
  43. package/lib/getBanks.ts +25 -0
  44. package/lib/getRate.ts +35 -0
  45. package/lib/getTXPoolAddress.ts +22 -0
  46. package/lib/getWallet.ts +34 -0
  47. package/lib/initiate.ts +31 -0
  48. package/lib/resolveBankAccount.ts +40 -0
  49. package/lib/switchWalletBankAccount.ts +26 -0
  50. package/lib/verify.ts +39 -0
  51. package/package.json +40 -0
  52. package/tsconfig.json +15 -0
  53. package/utils/api.ts +139 -0
  54. package/utils/axios.ts +10 -0
  55. package/utils/generateSignature.ts +25 -0
  56. package/utils/getWalletBody.ts +39 -0
  57. package/utils/verifySignature.ts +30 -0
  58. package/wallet.json +1 -0
package/README.md ADDED
@@ -0,0 +1,254 @@
1
+ # paj_ramp
2
+
3
+ Paj Ramp is a crypto offramp API designed to allow users to convert Solana-based digital assets to fiat and transfer the resulting funds to traditional bank accounts. This backend service acts as a bridge between the Solana blockchain and the traditional banking system, enabling secure, authenticated, and user-friendly offboarding of funds from Web3 to Web2.
4
+
5
+ > _A simple wrapper for communicating with paj_ramp's backend endpoints β€” no manual API calls required._
6
+
7
+ ### _β€œSend SOL. Get Naira.”_
8
+
9
+ > _The goal is to let users withdraw their crypto holdings from a Solana wallet and receive fiat currency in their linked bank accounts β€” all through a simple, authenticated API integration._
10
+
11
+ ---
12
+
13
+ ## πŸš€ Features
14
+
15
+ - βœ… Easy-to-use functions for all backend endpoints
16
+ - πŸ” Handles Session Management
17
+ - 🧱 Clean, modular API
18
+ - πŸ•ŠοΈ No need to write `fetch()` or `axios` manually
19
+ - πŸ•ΈοΈ Handles Bank Operations like getting banks, adding banks, resolving banks and getting banks linked to the account
20
+
21
+ ---
22
+
23
+ ## πŸ“¦ Installation
24
+
25
+ ```bash
26
+ # With npm
27
+ npm install paj_ramp
28
+
29
+ # With yarn
30
+ yarn add paj_ramp
31
+ ```
32
+
33
+ ---
34
+
35
+ ## πŸ“˜ Usage Examples
36
+
37
+ ### Get tx pool address
38
+
39
+ ```bash
40
+ import { getTXPoolAddress } from 'paj_ramp';
41
+
42
+ const txpooladdress = await getTXPoolAddress();
43
+
44
+ # Response
45
+ {
46
+ address: string,
47
+ }
48
+ ```
49
+
50
+ ### Get rate
51
+
52
+ ```bash
53
+ import { getRate } from 'paj_ramp';
54
+
55
+ const rate = await getRate();
56
+
57
+ # Response
58
+ {
59
+ baseCurrency: string,
60
+ targetCurrency: string,
61
+ rate: number
62
+ }
63
+ ```
64
+
65
+ ### Get rate with amount
66
+
67
+ ```bash
68
+ import { getRate } from 'paj_ramp';
69
+
70
+ const rate = await getRate(50000);
71
+
72
+ # Response
73
+ {
74
+ rate: {
75
+ baseCurrency: string,
76
+ targetCurrency: string,
77
+ rate: number
78
+ },
79
+ amounts: {
80
+ userTax: number,
81
+ merchantTax": number,
82
+ amountUSD": number,
83
+ userAmountFiat": number
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Initiate Session
89
+
90
+ ```bash
91
+ import { initiate } from 'paj_ramp';
92
+
93
+ const initialized = await initiate('your_email@gmail.com');
94
+
95
+ # Response
96
+ {
97
+ email: string
98
+ }
99
+ ```
100
+
101
+ ### Verify Session
102
+
103
+ ```bash
104
+ import { verify } from 'paj_ramp';
105
+
106
+ const verified = await verify('your_email@gmail.com', '1234', 'device signature');
107
+
108
+ # Response
109
+ {
110
+ email: string,
111
+ isActive: string,
112
+ expiresAt: string,
113
+ token: string
114
+ }
115
+ ```
116
+
117
+ ### Get Banks: Get list of banks
118
+
119
+ ```bash
120
+ import { getBanks } from 'paj_ramp';
121
+
122
+ const banks = await getBanks();
123
+
124
+ # Response
125
+ [
126
+ {
127
+ id: string,
128
+ name: string,
129
+ country: string
130
+ }
131
+ ]
132
+ ```
133
+
134
+ ### Resolve Bank Account
135
+
136
+ ```bash
137
+ import { resolveBankAccount } from 'paj_ramp';
138
+
139
+ const resolvedBankAccount = await resolveBankAccount('bank id', 'account number');
140
+
141
+ # Response
142
+ {
143
+ accountName: string,
144
+ accountNumber: string,
145
+ bank: {
146
+ id: string,
147
+ name: string,
148
+ code: string,
149
+ country: string,
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### Add Bank Account
155
+
156
+ ```bash
157
+ import { addBankAccount } from 'paj_ramp';
158
+
159
+ const addedBankAccount = await addBankAccount('token', 'bank id', 'account number');
160
+
161
+ # Response
162
+ {
163
+ id: string,
164
+ accountName: string,
165
+ accountNumber: string,
166
+ bank: string
167
+ }
168
+ ```
169
+
170
+ ### Get Bank Accounts
171
+
172
+ ```bash
173
+ import { getBankAccounts } from 'paj_ramp';
174
+
175
+ const addedBankAccount = await getBankAccounts('token');
176
+
177
+ # Response
178
+ [
179
+ {
180
+ id: string,
181
+ accountName: string,
182
+ accountNumber: string,
183
+ bank: string
184
+ }
185
+ ]
186
+ ```
187
+
188
+ ### Get Wallet Info
189
+
190
+ ```bash
191
+ import { getWallet } from 'paj_ramp';
192
+
193
+ const wallet = await getWallet('wallet public key');
194
+
195
+ # Response
196
+ {
197
+ id: string,
198
+ publicKey: string,
199
+ bankAccount: {
200
+ id: string,
201
+ accountName: string,
202
+ accountNumber: string,
203
+ bank: string
204
+ }
205
+ }
206
+ ```
207
+
208
+ ### Add Wallet
209
+
210
+ ```bash
211
+ import { addWallet } from 'paj_ramp';
212
+
213
+ const addedWallet = await addWallet('token', 'bank account id', 'secret key');
214
+
215
+ # Response
216
+ {
217
+ id: string,
218
+ publicKey: string,
219
+ bankAccount: {
220
+ id: string,
221
+ accountName: string,
222
+ accountNumber: string,
223
+ bank: string
224
+ }
225
+ }
226
+ ```
227
+
228
+ ### Switch Bank Account on Wallet
229
+
230
+ ```bash
231
+ import { switchWalletBankAccount } from 'paj_ramp';
232
+
233
+ const switchedWallet = await switchWalletBankAccount('token','bank account id to switch to', 'wallet id', 'secret key');
234
+
235
+ # Response
236
+ {
237
+ id: string,
238
+ publicKey: string,
239
+ bankAccount: {
240
+ id: string,
241
+ accountName: string,
242
+ accountNumber: string,
243
+ bank: string
244
+ }
245
+ }
246
+ ```
247
+
248
+ ---
249
+
250
+ ## πŸ§‘β€πŸ’» Author
251
+
252
+ Your Name β€” Gospel Chidiebube Chukwu
253
+
254
+
@@ -0,0 +1,24 @@
1
+ import { getTXPoolAddress } from '../lib/getTXPoolAddress';
2
+ import * as api from '../utils/api';
3
+
4
+ describe('getTXPoolAddress', () => {
5
+ const mockAddress = 'FakeSolanaAddress123';
6
+
7
+ afterEach(() => {
8
+ jest.restoreAllMocks();
9
+ });
10
+
11
+ it('should return tx pool address when API call succeeds', async () => {
12
+ jest.spyOn(api, 'get').mockResolvedValue({ address: mockAddress });
13
+
14
+ const result = await getTXPoolAddress();
15
+ expect(result).toEqual({ address: mockAddress });
16
+ });
17
+
18
+ it('should throw an error when API call fails', async () => {
19
+ const error = new Error('API Failure');
20
+ jest.spyOn(api, 'get').mockRejectedValue(error);
21
+
22
+ await expect(getTXPoolAddress()).rejects.toThrow('API Failure');
23
+ });
24
+ });
@@ -0,0 +1,11 @@
1
+ export { getTXPoolAddress } from './lib/getTXPoolAddress.js';
2
+ export { getRate } from './lib/getRate.js';
3
+ export { initiate } from './lib/initiate.js';
4
+ export { verify } from './lib/verify.js';
5
+ export { getBanks } from './lib/getBanks.js';
6
+ export { resolveBankAccount } from './lib/resolveBankAccount.js';
7
+ export { addBankAccount } from './lib/addBankAccount.js';
8
+ export { getBankAccounts } from './lib/getBankAccounts.js';
9
+ export { getWallet } from './lib/getWallet.js';
10
+ export { addWallet } from './lib/addWallet.js';
11
+ export { switchWalletBankAccount } from './lib/switchWalletBankAccount.js';
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ //Web3.js - A JavaScript library for interacting with the Web3 ecosystem.
2
+ //Wallet Info
3
+ export { getTXPoolAddress } from './lib/getTXPoolAddress.js';
4
+ export { getRate } from './lib/getRate.js';
5
+ //Session Management
6
+ export { initiate } from './lib/initiate.js';
7
+ export { verify } from './lib/verify.js';
8
+ //Banking Operations
9
+ export { getBanks } from './lib/getBanks.js';
10
+ export { resolveBankAccount } from './lib/resolveBankAccount.js';
11
+ export { addBankAccount } from './lib/addBankAccount.js';
12
+ export { getBankAccounts } from './lib/getBankAccounts.js';
13
+ //Wallet Operations
14
+ export { getWallet } from './lib/getWallet.js';
15
+ export { addWallet } from './lib/addWallet.js';
16
+ export { switchWalletBankAccount } from './lib/switchWalletBankAccount.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
3
+ * Returns the added bank account details or throws an error if the request fails.
4
+ *
5
+ * Args:
6
+ * token: The authentication token for the request.
7
+ * bankId: The ID of the bank.
8
+ * accountNumber: The bank account number to add.
9
+ *
10
+ * Returns:
11
+ * An object containing the new bank account's id, accountName, accountNumber, and bank.
12
+ *
13
+ * Raises:
14
+ * Throws an error if the request fails.
15
+ */
16
+ export declare const addBankAccount: (token: string, bankId: string, accountNumber: string) => Promise<{
17
+ id: string;
18
+ accountName: string;
19
+ accountNumber: string;
20
+ bank: string;
21
+ }>;
@@ -0,0 +1,30 @@
1
+ import { post } from '../utils/api.js';
2
+ /**
3
+ * Adds a new bank account by sending the provided token, bank ID, and account number to the public API.
4
+ * Returns the added bank account details or throws an error if the request fails.
5
+ *
6
+ * Args:
7
+ * token: The authentication token for the request.
8
+ * bankId: The ID of the bank.
9
+ * accountNumber: The bank account number to add.
10
+ *
11
+ * Returns:
12
+ * An object containing the new bank account's id, accountName, accountNumber, and bank.
13
+ *
14
+ * Raises:
15
+ * Throws an error if the request fails.
16
+ */
17
+ export const addBankAccount = async (token, bankId, accountNumber) => {
18
+ try {
19
+ return await post('/pub/bankAccount', {
20
+ bankId,
21
+ accountNumber,
22
+ }, {
23
+ Authorization: `Bearer ${token}`,
24
+ });
25
+ }
26
+ catch (err) {
27
+ console.error('Error adding bank account:', err);
28
+ throw err;
29
+ }
30
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Adds a new wallet for the user.
3
+ * Returns the added wallet object or throws an error if the request fails.
4
+ *
5
+ * Returns:
6
+ * An object containing id, accountName, accountNumber, and bank of the bank account.
7
+ *
8
+ * Raises:
9
+ * Throws an error if the wallet file is not found or if the secret key is invalid.
10
+ */
11
+ export declare const addWallet: (apiKey: string, accountId: string, secretKey: Uint8Array) => Promise<void>;
@@ -0,0 +1,27 @@
1
+ import { post } from "../utils/api.js";
2
+ import { getWalletBody } from "../utils/getWalletBody.js";
3
+ /**
4
+ * Adds a new wallet for the user.
5
+ * Returns the added wallet object or throws an error if the request fails.
6
+ *
7
+ * Returns:
8
+ * An object containing id, accountName, accountNumber, and bank of the bank account.
9
+ *
10
+ * Raises:
11
+ * Throws an error if the wallet file is not found or if the secret key is invalid.
12
+ */
13
+ export const addWallet = async (apiKey, accountId, secretKey) => {
14
+ try {
15
+ const body = await getWalletBody(accountId, secretKey);
16
+ if (!body) {
17
+ throw new Error("Failed to get wallet body");
18
+ }
19
+ const response = await post("/pub/wallet", body, {
20
+ Authorization: `Bearer ${apiKey}`,
21
+ });
22
+ }
23
+ catch (err) {
24
+ console.error("Error adding wallet:", err);
25
+ throw err;
26
+ }
27
+ };
@@ -0,0 +1,18 @@
1
+ type GetBankAccountsType = {
2
+ id: string;
3
+ accountName: string;
4
+ accountNumber: string;
5
+ bank: string;
6
+ };
7
+ /**
8
+ * Fetches a list of added bank accounts from the public API endpoint.
9
+ * Returns an array of bank account objects or throws an error if the request fails.
10
+ *
11
+ * Returns:
12
+ * An array of objects, each containing id, accountName, accountNumber, and bank of a bank account.
13
+ *
14
+ * Raises:
15
+ * Throws an error if the request fails.
16
+ */
17
+ export declare const getBankAccounts: (apiKey: string) => Promise<GetBankAccountsType[]>;
18
+ export {};
@@ -0,0 +1,22 @@
1
+ import { get } from "../utils/api.js";
2
+ /**
3
+ * Fetches a list of added bank accounts from the public API endpoint.
4
+ * Returns an array of bank account objects or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * An array of objects, each containing id, accountName, accountNumber, and bank of a bank account.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getBankAccounts = async (apiKey) => {
13
+ try {
14
+ return await get(`/pub/bankaccount`, {}, {
15
+ Authorization: `Bearer ${apiKey}`,
16
+ });
17
+ }
18
+ catch (err) {
19
+ console.error("Error fetching bank accounts:", err);
20
+ throw err;
21
+ }
22
+ };
@@ -0,0 +1,17 @@
1
+ type BankType = {
2
+ id: string;
3
+ name: string;
4
+ country: string;
5
+ };
6
+ /**
7
+ * Fetches a list of banks from the public API endpoint.
8
+ * Returns an array of bank objects or throws an error if the request fails.
9
+ *
10
+ * Returns:
11
+ * An array of objects, each containing id, name, and country of a bank.
12
+ *
13
+ * Raises:
14
+ * Throws an error if the request fails.
15
+ */
16
+ export declare const getBanks: () => Promise<BankType[]>;
17
+ export {};
@@ -0,0 +1,20 @@
1
+ import { get } from '../utils/api.js';
2
+ /**
3
+ * Fetches a list of banks from the public API endpoint.
4
+ * Returns an array of bank objects or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * An array of objects, each containing id, name, and country of a bank.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getBanks = async () => {
13
+ try {
14
+ return await get(`/pub/bank`);
15
+ }
16
+ catch (err) {
17
+ console.error('Error fetching Banks:', err);
18
+ throw err;
19
+ }
20
+ };
@@ -0,0 +1,26 @@
1
+ type RateType = {
2
+ baseCurrency: string;
3
+ targetCurrency: string;
4
+ rate: number;
5
+ amounts: {
6
+ userTax: number;
7
+ merchantTax: number;
8
+ amountUSD: number;
9
+ userAmountFiat: number;
10
+ };
11
+ };
12
+ /**
13
+ * Fetches the exchange rate and related amounts for a given amount from the public API.
14
+ * Returns an object containing currency information, rate, and detailed amounts, or throws an error if the request fails.
15
+ *
16
+ * Args:
17
+ * amount: The amount for which to fetch the rate. If not provided or falsy, fetches the default rate.
18
+ *
19
+ * Returns:
20
+ * An object with baseCurrency, targetCurrency, rate, and amounts (userTax, merchantTax, amountUSD, userAmountFiat).
21
+ *
22
+ * Raises:
23
+ * Throws an error if the request fails.
24
+ */
25
+ export declare const getRate: (amount: number) => Promise<RateType>;
26
+ export {};
@@ -0,0 +1,23 @@
1
+ import { get } from '../utils/api.js';
2
+ /**
3
+ * Fetches the exchange rate and related amounts for a given amount from the public API.
4
+ * Returns an object containing currency information, rate, and detailed amounts, or throws an error if the request fails.
5
+ *
6
+ * Args:
7
+ * amount: The amount for which to fetch the rate. If not provided or falsy, fetches the default rate.
8
+ *
9
+ * Returns:
10
+ * An object with baseCurrency, targetCurrency, rate, and amounts (userTax, merchantTax, amountUSD, userAmountFiat).
11
+ *
12
+ * Raises:
13
+ * Throws an error if the request fails.
14
+ */
15
+ export const getRate = async (amount) => {
16
+ try {
17
+ return await get(amount ? `/pub/rate/${amount}` : '/pub/rate');
18
+ }
19
+ catch (err) {
20
+ console.error('Error fetching Rate:', err);
21
+ throw err;
22
+ }
23
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Fetches the transaction pool address from the public API endpoint.
3
+ * Returns the address as a string or throws an error if the request fails.
4
+ *
5
+ * Returns:
6
+ * The transaction pool address as a string.
7
+ *
8
+ * Raises:
9
+ * Throws an error if the request fails.
10
+ */
11
+ export declare const getTXPoolAddress: () => Promise<{
12
+ address: string;
13
+ }>;
@@ -0,0 +1,20 @@
1
+ import { get } from '../utils/api.js';
2
+ /**
3
+ * Fetches the transaction pool address from the public API endpoint.
4
+ * Returns the address as a string or throws an error if the request fails.
5
+ *
6
+ * Returns:
7
+ * The transaction pool address as a string.
8
+ *
9
+ * Raises:
10
+ * Throws an error if the request fails.
11
+ */
12
+ export const getTXPoolAddress = async () => {
13
+ try {
14
+ return await get('/pub/txpool-address');
15
+ }
16
+ catch (err) {
17
+ console.error('Error fetching TX Pool Address:', err);
18
+ throw err;
19
+ }
20
+ };
@@ -0,0 +1,24 @@
1
+ export type WalletType = {
2
+ id: string;
3
+ publicKey: string;
4
+ bankAccount: {
5
+ id: string;
6
+ accountName: string;
7
+ accountNumber: string;
8
+ bank: string;
9
+ };
10
+ };
11
+ /**
12
+ * Fetches wallet details for a given public key from the public API endpoint.
13
+ * Returns the wallet information including bank account details or throws an error if the request fails.
14
+ *
15
+ * Args:
16
+ * publicKey: The public key of the wallet to fetch.
17
+ *
18
+ * Returns:
19
+ * An object containing wallet id, publicKey, and associated bank account details.
20
+ *
21
+ * Raises:
22
+ * Throws an error if the request fails.
23
+ */
24
+ export declare const getWallet: (publicKey: string) => Promise<WalletType>;
@@ -0,0 +1,23 @@
1
+ import { get } from '../utils/api.js';
2
+ /**
3
+ * Fetches wallet details for a given public key from the public API endpoint.
4
+ * Returns the wallet information including bank account details or throws an error if the request fails.
5
+ *
6
+ * Args:
7
+ * publicKey: The public key of the wallet to fetch.
8
+ *
9
+ * Returns:
10
+ * An object containing wallet id, publicKey, and associated bank account details.
11
+ *
12
+ * Raises:
13
+ * Throws an error if the request fails.
14
+ */
15
+ export const getWallet = async (publicKey) => {
16
+ try {
17
+ return await get(`/pub/wallet/${publicKey}`);
18
+ }
19
+ catch (err) {
20
+ console.error('Error fetching wallet:', err);
21
+ throw err;
22
+ }
23
+ };
@@ -0,0 +1,18 @@
1
+ type InitiateResponse = {
2
+ email: string;
3
+ };
4
+ /**
5
+ * Initiates a process by sending the provided email to the public API endpoint.
6
+ * Returns the response from the API or throws an error if the request fails.
7
+ *
8
+ * Args:
9
+ * email: The email address to send in the initiation request.
10
+ *
11
+ * Returns:
12
+ * The response data from the API.
13
+ *
14
+ * Raises:
15
+ * Throws an error if the request fails.
16
+ */
17
+ export declare const initiate: (email: string) => Promise<InitiateResponse>;
18
+ export {};
@@ -0,0 +1,23 @@
1
+ import { post } from '../utils/api.js';
2
+ /**
3
+ * Initiates a process by sending the provided email to the public API endpoint.
4
+ * Returns the response from the API or throws an error if the request fails.
5
+ *
6
+ * Args:
7
+ * email: The email address to send in the initiation request.
8
+ *
9
+ * Returns:
10
+ * The response data from the API.
11
+ *
12
+ * Raises:
13
+ * Throws an error if the request fails.
14
+ */
15
+ export const initiate = async (email) => {
16
+ try {
17
+ return await post('/pub/initiate', { email }, { 'x-api-key': '3ada687e-78d1-45f3-933d-c992adcc2bbb' });
18
+ }
19
+ catch (err) {
20
+ console.error('Error initiating:', err);
21
+ throw err;
22
+ }
23
+ };
@@ -0,0 +1,26 @@
1
+ type ResolveBankAccountType = {
2
+ accountName: string;
3
+ accountNumber: string;
4
+ bank: {
5
+ id: string;
6
+ name: string;
7
+ code: string;
8
+ country: string;
9
+ };
10
+ };
11
+ /**
12
+ * Resolves and fetches bank account details for a given bank ID and account number from the public API.
13
+ * Returns the account name, account number, and bank details or throws an error if the request fails.
14
+ *
15
+ * Args:
16
+ * bankId: The ID of the bank.
17
+ * accountNumber: The bank account number to resolve.
18
+ *
19
+ * Returns:
20
+ * An object containing accountName, accountNumber, and bank details (id, name, code, country).
21
+ *
22
+ * Raises:
23
+ * Throws an error if the request fails.
24
+ */
25
+ export declare const resolveBankAccount: (bankId: string, accountNumber: string) => Promise<ResolveBankAccountType>;
26
+ export {};