@nomba/node-sdk 0.3.0 → 0.4.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.
- package/README.md +46 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +3 -1
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +8 -6
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.js +23 -0
- package/dist/lib/outcome.d.ts +9 -3
- package/dist/lib/outcome.js +10 -4
- package/dist/lib/sdk-version.generated.d.ts +1 -1
- package/dist/lib/sdk-version.generated.js +1 -1
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +0 -6
- package/dist/services/http/http-client.service.js +4 -3
- package/dist/services/v1/betting/betting.service.d.ts +1 -0
- package/dist/services/v1/betting/betting.service.js +1 -0
- package/dist/services/v1/cable/cable.service.d.ts +1 -0
- package/dist/services/v1/cable/cable.service.js +1 -0
- package/dist/services/v1/checkout/checkout.service.js +1 -1
- package/dist/services/v1/globals/collections.service.d.ts +3 -1
- package/dist/services/v1/globals/collections.service.js +10 -5
- package/dist/services/v1/globals/payout.service.d.ts +12 -8
- package/dist/services/v1/globals/payout.service.js +19 -12
- package/dist/services/v1/requery/requery.service.d.ts +23 -5
- package/dist/services/v1/requery/requery.service.js +23 -5
- package/dist/services/v1/terminals/terminals.service.d.ts +37 -9
- package/dist/services/v1/terminals/terminals.service.js +38 -10
- package/dist/services/v1/transactions/transactions.service.d.ts +70 -12
- package/dist/services/v1/transactions/transactions.service.js +70 -12
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +48 -7
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +48 -7
- package/dist/services/v1/webhooks/webhooks.service.d.ts +28 -6
- package/dist/services/v1/webhooks/webhooks.service.js +28 -6
- package/dist/services/v2/airtime/airtime.service.js +1 -1
- package/dist/services/v2/betting/betting.service.js +1 -1
- package/dist/services/v2/cable/cable.service.js +1 -1
- package/dist/services/v2/data/data.service.js +1 -1
- package/dist/services/v2/electricity/electricity.service.js +1 -1
- package/dist/services/v2/transfers/transfers.service.js +4 -4
- package/dist/types/common/common.types.d.ts +2 -1
- package/dist/types/v1/globals/collections.types.d.ts +3 -3
- package/dist/types/v1/globals/payout.types.d.ts +3 -3
- package/package.json +1 -1
|
@@ -13,27 +13,45 @@
|
|
|
13
13
|
* @see https://developer.nomba.com/docs/api-reference/requery
|
|
14
14
|
*/
|
|
15
15
|
import { pathId } from "../../../lib/util.js";
|
|
16
|
+
/** Requery (v1): look up a single transaction's current status. */
|
|
16
17
|
export class RequeryService {
|
|
17
18
|
http;
|
|
18
19
|
constructor(http) {
|
|
19
20
|
this.http = http;
|
|
20
21
|
}
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/transactions/accounts/single`. Looks up a transaction on the parent account by
|
|
24
|
+
* reference or ID.
|
|
25
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
26
|
+
* @returns The transaction's current details and status.
|
|
27
|
+
* @throws {NombaError} The transaction was not found, or the call failed.
|
|
28
|
+
*/
|
|
22
29
|
fetchParentTransaction(lookup) {
|
|
23
30
|
return this.http.request("GET", "/v1/transactions/accounts/single", {
|
|
24
31
|
query: lookup,
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* `GET /v1/transactions/accounts/{subAccountId}/single`. Looks up a transaction on a sub account
|
|
36
|
+
* by reference or ID.
|
|
37
|
+
* @param subAccountId The sub account's ID.
|
|
38
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
39
|
+
* @returns The transaction's current details and status.
|
|
40
|
+
* @throws {NombaError} The transaction was not found, `subAccountId` does not exist, or the call failed.
|
|
41
|
+
*/
|
|
28
42
|
async fetchSubAccountTransaction(subAccountId, lookup) {
|
|
29
43
|
return this.http.request("GET", `/v1/transactions/accounts/${pathId(subAccountId)}/single`, {
|
|
30
44
|
query: lookup,
|
|
31
45
|
});
|
|
32
46
|
}
|
|
33
47
|
/**
|
|
34
|
-
* GET /v1/transactions/requery/{sessionId}
|
|
35
|
-
*
|
|
36
|
-
*
|
|
48
|
+
* `GET /v1/transactions/requery/{sessionId}`. Looks up a bank transfer by its session ID.
|
|
49
|
+
* Use this for transfers made through both parent and sub accounts. Note: Nomba-to-Nomba
|
|
50
|
+
* wallet transfers do not return a `sessionId`; use `fetchParentTransaction` or
|
|
51
|
+
* `fetchSubAccountTransaction` for those instead.
|
|
52
|
+
* @param sessionId The transfer's session ID from the original response.
|
|
53
|
+
* @returns The transaction's current details and status.
|
|
54
|
+
* @throws {NombaError} The session was not found, or the call failed.
|
|
37
55
|
*/
|
|
38
56
|
async requeryBySession(sessionId) {
|
|
39
57
|
return this.http.request("GET", `/v1/transactions/requery/${pathId(sessionId)}`);
|
|
@@ -16,23 +16,51 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
|
16
16
|
import type { ITerminalsService } from "../../../interfaces/v1/terminals/index.js";
|
|
17
17
|
import type { CallOptions } from "../../../types/common/common.types.js";
|
|
18
18
|
import type { AssignTerminalParams, PushPaymentRequestParams, Terminal, TerminalPayment } from "../../../types/v1/terminals/terminals.types.js";
|
|
19
|
+
/** Terminals (v1): assign, unassign, and push payment requests to physical POS terminals. */
|
|
19
20
|
export declare class TerminalsService implements ITerminalsService {
|
|
20
21
|
private readonly http;
|
|
21
22
|
constructor(http: IHttpClient);
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `POST /v1/terminals/assign`. Assigns a terminal to the parent account.
|
|
25
|
+
* @param params The terminal ID to assign.
|
|
26
|
+
* @returns The assigned terminal's details.
|
|
27
|
+
* @throws {NombaError} The call failed, e.g. the terminal does not exist or is already assigned.
|
|
28
|
+
*/
|
|
23
29
|
assignToParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
24
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/terminals/assign/{subAccountId}`. Assigns a terminal to a sub account.
|
|
32
|
+
* @param subAccountId The sub account to assign the terminal to.
|
|
33
|
+
* @param params The terminal ID to assign.
|
|
34
|
+
* @returns The assigned terminal's details.
|
|
35
|
+
* @throws {NombaError} The call failed, e.g. the terminal or sub account does not exist.
|
|
36
|
+
*/
|
|
25
37
|
assignToSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
26
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* `POST /v1/terminals/unassign`. Unassigns a terminal from the parent account.
|
|
40
|
+
* @param params The terminal ID to unassign.
|
|
41
|
+
* @returns The unassigned terminal's details.
|
|
42
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this account.
|
|
43
|
+
*/
|
|
27
44
|
unassignFromParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
28
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/terminals/unassign/{subAccountId}`. Unassigns a terminal from a sub account.
|
|
47
|
+
* @param subAccountId The sub account to unassign the terminal from.
|
|
48
|
+
* @param params The terminal ID to unassign.
|
|
49
|
+
* @returns The unassigned terminal's details.
|
|
50
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this sub account.
|
|
51
|
+
*/
|
|
29
52
|
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
30
53
|
/**
|
|
31
|
-
* POST /v1/terminals/payment-request/{terminalId}
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
54
|
+
* `POST /v1/terminals/payment-request/{terminalId}`. Triggers a payment prompt on the physical terminal.
|
|
55
|
+
* The customer taps or swipes their card, and the outcome is reported via webhook or requery.
|
|
56
|
+
* @param terminalId The terminal's ID to prompt for payment.
|
|
57
|
+
* @param params The amount and `merchantTxRef` (used as idempotency key).
|
|
58
|
+
* @param options Outcome closures (`onSuccess`, `onPending`, `onFailed`); without them, success resolves
|
|
59
|
+
* the result and pending/failure throws.
|
|
60
|
+
* @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
|
|
61
|
+
* @throws {NombaError} The request was rejected (4xx).
|
|
62
|
+
* @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
|
|
63
|
+
* @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
|
|
36
64
|
*/
|
|
37
65
|
pushPaymentRequest<R = TerminalPayment>(terminalId: string, params: PushPaymentRequestParams, options?: CallOptions<TerminalPayment, R>): Promise<TerminalPayment | R>;
|
|
38
66
|
}
|
|
@@ -20,39 +20,67 @@ const PAYMENT_REQUEST_OUTCOMES = {
|
|
|
20
20
|
codes: { "00": "success", ...REJECTED },
|
|
21
21
|
statuses: { completed: "success", pending: "pending", failed: "pending" },
|
|
22
22
|
};
|
|
23
|
+
/** Terminals (v1): assign, unassign, and push payment requests to physical POS terminals. */
|
|
23
24
|
export class TerminalsService {
|
|
24
25
|
http;
|
|
25
26
|
constructor(http) {
|
|
26
27
|
this.http = http;
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* `POST /v1/terminals/assign`. Assigns a terminal to the parent account.
|
|
31
|
+
* @param params The terminal ID to assign.
|
|
32
|
+
* @returns The assigned terminal's details.
|
|
33
|
+
* @throws {NombaError} The call failed, e.g. the terminal does not exist or is already assigned.
|
|
34
|
+
*/
|
|
29
35
|
assignToParent(params) {
|
|
30
36
|
return this.http.request("POST", "/v1/terminals/assign", {
|
|
31
37
|
body: params,
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* `POST /v1/terminals/assign/{subAccountId}`. Assigns a terminal to a sub account.
|
|
42
|
+
* @param subAccountId The sub account to assign the terminal to.
|
|
43
|
+
* @param params The terminal ID to assign.
|
|
44
|
+
* @returns The assigned terminal's details.
|
|
45
|
+
* @throws {NombaError} The call failed, e.g. the terminal or sub account does not exist.
|
|
46
|
+
*/
|
|
35
47
|
async assignToSubAccount(subAccountId, params) {
|
|
36
48
|
return this.http.request("POST", `/v1/terminals/assign/${pathId(subAccountId)}`, { body: params });
|
|
37
49
|
}
|
|
38
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* `POST /v1/terminals/unassign`. Unassigns a terminal from the parent account.
|
|
52
|
+
* @param params The terminal ID to unassign.
|
|
53
|
+
* @returns The unassigned terminal's details.
|
|
54
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this account.
|
|
55
|
+
*/
|
|
39
56
|
unassignFromParent(params) {
|
|
40
57
|
return this.http.request("POST", "/v1/terminals/unassign", {
|
|
41
58
|
body: params,
|
|
42
59
|
});
|
|
43
60
|
}
|
|
44
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* `POST /v1/terminals/unassign/{subAccountId}`. Unassigns a terminal from a sub account.
|
|
63
|
+
* @param subAccountId The sub account to unassign the terminal from.
|
|
64
|
+
* @param params The terminal ID to unassign.
|
|
65
|
+
* @returns The unassigned terminal's details.
|
|
66
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this sub account.
|
|
67
|
+
*/
|
|
45
68
|
async unassignFromSubAccount(subAccountId, params) {
|
|
46
69
|
return this.http.request("POST", `/v1/terminals/unassign/${pathId(subAccountId)}`, { body: params });
|
|
47
70
|
}
|
|
48
71
|
/**
|
|
49
|
-
* POST /v1/terminals/payment-request/{terminalId}
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
72
|
+
* `POST /v1/terminals/payment-request/{terminalId}`. Triggers a payment prompt on the physical terminal.
|
|
73
|
+
* The customer taps or swipes their card, and the outcome is reported via webhook or requery.
|
|
74
|
+
* @param terminalId The terminal's ID to prompt for payment.
|
|
75
|
+
* @param params The amount and `merchantTxRef` (used as idempotency key).
|
|
76
|
+
* @param options Outcome closures (`onSuccess`, `onPending`, `onFailed`); without them, success resolves
|
|
77
|
+
* the result and pending/failure throws.
|
|
78
|
+
* @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
|
|
79
|
+
* @throws {NombaError} The request was rejected (4xx).
|
|
80
|
+
* @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
|
|
81
|
+
* @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
|
|
54
82
|
*/
|
|
55
83
|
async pushPaymentRequest(terminalId, params, options = {}) {
|
|
56
|
-
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, params.merchantTxRef, options);
|
|
84
|
+
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, { field: "merchantTxRef", value: params.merchantTxRef }, options);
|
|
57
85
|
}
|
|
58
86
|
}
|
|
@@ -17,32 +17,90 @@ import type { ITransactionsService } from "../../../interfaces/v1/transactions/I
|
|
|
17
17
|
import type { Page } from "../../../lib/util.js";
|
|
18
18
|
import type { Transaction } from "../../../types/v1/requery/requery.types.js";
|
|
19
19
|
import type { BankTransaction, BankTransactionList, FilterTransactionsParams, TransactionList, TransactionListParams, VirtualAccountTransaction, VirtualAccountTransactionParams } from "../../../types/v1/transactions/transactions.types.js";
|
|
20
|
+
/** Transactions (v1): list and filter transactions on parent, sub, and virtual accounts. */
|
|
20
21
|
export declare class TransactionsService implements ITransactionsService {
|
|
21
22
|
private readonly http;
|
|
22
23
|
constructor(http: IHttpClient);
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* `GET /v1/transactions/bank`. Lists credit and debit transactions on the parent account.
|
|
26
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
27
|
+
* @returns One page of bank transactions.
|
|
28
|
+
* @throws {NombaError} The call failed.
|
|
29
|
+
*/
|
|
24
30
|
listBankTransactions(params?: TransactionListParams): Promise<BankTransactionList>;
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Iterates over every credit/debit transaction on the parent account, across all pages.
|
|
33
|
+
* @param params Starting pagination options.
|
|
34
|
+
* @throws {NombaError} A page request failed.
|
|
35
|
+
*/
|
|
26
36
|
iterateBankTransactions(params?: TransactionListParams): AsyncGenerator<BankTransaction>;
|
|
27
37
|
/**
|
|
28
|
-
* GET /v1/transactions/virtual
|
|
29
|
-
*
|
|
38
|
+
* `GET /v1/transactions/virtual`. Lists transactions on a virtual account.
|
|
39
|
+
* Note: The response carries a cursor, but the API docs do not name a paging parameter,
|
|
40
|
+
* so only the first page is returned.
|
|
41
|
+
* @param params The virtual account number and optional date range.
|
|
42
|
+
* @returns One page of virtual account transactions.
|
|
43
|
+
* @throws {NombaError} The call failed, e.g. `accountNumber` does not exist.
|
|
30
44
|
*/
|
|
31
45
|
listVirtualAccountTransactions({ accountNumber, ...dates }: VirtualAccountTransactionParams): Promise<Page<VirtualAccountTransaction>>;
|
|
32
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* `GET /v1/transactions/accounts`. Lists transactions on the parent account.
|
|
48
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
49
|
+
* @returns One page of transactions.
|
|
50
|
+
* @throws {NombaError} The call failed.
|
|
51
|
+
*/
|
|
33
52
|
listParentTransactions(params?: TransactionListParams): Promise<TransactionList>;
|
|
34
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Iterates over every transaction on the parent account, across all pages.
|
|
55
|
+
* @param params Starting pagination options.
|
|
56
|
+
* @throws {NombaError} A page request failed.
|
|
57
|
+
*/
|
|
35
58
|
iterateParentTransactions(params?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
36
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* `GET /v1/transactions/accounts/{subAccountId}`. Lists transactions on a sub account.
|
|
61
|
+
* @param subAccountId The sub account's ID.
|
|
62
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
63
|
+
* @returns One page of transactions.
|
|
64
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
65
|
+
*/
|
|
37
66
|
listSubAccountTransactions(subAccountId: string, params?: TransactionListParams): Promise<TransactionList>;
|
|
38
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Iterates over every transaction on a sub account, across all pages.
|
|
69
|
+
* @param subAccountId The sub account's ID.
|
|
70
|
+
* @param params Starting pagination options.
|
|
71
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
72
|
+
*/
|
|
39
73
|
iterateSubAccountTransactions(subAccountId: string, params?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
40
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* `POST /v1/transactions/accounts`. Filters transactions on the parent account by criteria.
|
|
76
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
77
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
78
|
+
* @returns One page of matching transactions.
|
|
79
|
+
* @throws {NombaError} The call failed.
|
|
80
|
+
*/
|
|
41
81
|
filterParentTransactions(filter?: FilterTransactionsParams, page?: TransactionListParams): Promise<TransactionList>;
|
|
42
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Iterates over every parent account transaction matching the filter, across all pages.
|
|
84
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
85
|
+
* @param page Starting pagination options.
|
|
86
|
+
* @throws {NombaError} A page request failed.
|
|
87
|
+
*/
|
|
43
88
|
iterateFilteredParentTransactions(filter?: FilterTransactionsParams, page?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
44
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* `POST /v1/transactions/accounts/{subAccountId}`. Filters transactions on a sub account by criteria.
|
|
91
|
+
* @param subAccountId The sub account's ID.
|
|
92
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
93
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
94
|
+
* @returns One page of matching transactions.
|
|
95
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
96
|
+
*/
|
|
45
97
|
filterSubAccountTransactions(subAccountId: string, filter?: FilterTransactionsParams, page?: TransactionListParams): Promise<TransactionList>;
|
|
46
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Iterates over every sub account transaction matching the filter, across all pages.
|
|
100
|
+
* @param subAccountId The sub account's ID.
|
|
101
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
102
|
+
* @param page Starting pagination options.
|
|
103
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
104
|
+
*/
|
|
47
105
|
iterateFilteredSubAccountTransactions(subAccountId: string, filter?: FilterTransactionsParams, page?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
48
106
|
}
|
|
@@ -14,18 +14,28 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { paginate } from "../../../lib/paginate.js";
|
|
16
16
|
import { pageQuery, pathId } from "../../../lib/util.js";
|
|
17
|
+
/** Transactions (v1): list and filter transactions on parent, sub, and virtual accounts. */
|
|
17
18
|
export class TransactionsService {
|
|
18
19
|
http;
|
|
19
20
|
constructor(http) {
|
|
20
21
|
this.http = http;
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `GET /v1/transactions/bank`. Lists credit and debit transactions on the parent account.
|
|
25
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
26
|
+
* @returns One page of bank transactions.
|
|
27
|
+
* @throws {NombaError} The call failed.
|
|
28
|
+
*/
|
|
23
29
|
listBankTransactions(params = {}) {
|
|
24
30
|
return this.http.request("GET", "/v1/transactions/bank", {
|
|
25
31
|
query: pageQuery(params),
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Iterates over every credit/debit transaction on the parent account, across all pages.
|
|
36
|
+
* @param params Starting pagination options.
|
|
37
|
+
* @throws {NombaError} A page request failed.
|
|
38
|
+
*/
|
|
29
39
|
iterateBankTransactions(params = {}) {
|
|
30
40
|
return paginate(async (cursor) => {
|
|
31
41
|
const page = await this.listBankTransactions(cursor ? { ...params, cursor } : params);
|
|
@@ -33,62 +43,110 @@ export class TransactionsService {
|
|
|
33
43
|
});
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
|
-
* GET /v1/transactions/virtual
|
|
37
|
-
*
|
|
46
|
+
* `GET /v1/transactions/virtual`. Lists transactions on a virtual account.
|
|
47
|
+
* Note: The response carries a cursor, but the API docs do not name a paging parameter,
|
|
48
|
+
* so only the first page is returned.
|
|
49
|
+
* @param params The virtual account number and optional date range.
|
|
50
|
+
* @returns One page of virtual account transactions.
|
|
51
|
+
* @throws {NombaError} The call failed, e.g. `accountNumber` does not exist.
|
|
38
52
|
*/
|
|
39
53
|
listVirtualAccountTransactions({ accountNumber, ...dates }) {
|
|
40
54
|
return this.http.request("GET", "/v1/transactions/virtual", {
|
|
41
55
|
query: { virtual_account: accountNumber, ...dates },
|
|
42
56
|
});
|
|
43
57
|
}
|
|
44
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* `GET /v1/transactions/accounts`. Lists transactions on the parent account.
|
|
60
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
61
|
+
* @returns One page of transactions.
|
|
62
|
+
* @throws {NombaError} The call failed.
|
|
63
|
+
*/
|
|
45
64
|
listParentTransactions(params = {}) {
|
|
46
65
|
return this.http.request("GET", "/v1/transactions/accounts", {
|
|
47
66
|
query: pageQuery(params),
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Iterates over every transaction on the parent account, across all pages.
|
|
71
|
+
* @param params Starting pagination options.
|
|
72
|
+
* @throws {NombaError} A page request failed.
|
|
73
|
+
*/
|
|
51
74
|
iterateParentTransactions(params = {}) {
|
|
52
75
|
return paginate(async (cursor) => {
|
|
53
76
|
const page = await this.listParentTransactions(cursor ? { ...params, cursor } : params);
|
|
54
77
|
return { results: page.results ?? [], cursor: page.cursor ?? "" };
|
|
55
78
|
});
|
|
56
79
|
}
|
|
57
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* `GET /v1/transactions/accounts/{subAccountId}`. Lists transactions on a sub account.
|
|
82
|
+
* @param subAccountId The sub account's ID.
|
|
83
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
84
|
+
* @returns One page of transactions.
|
|
85
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
86
|
+
*/
|
|
58
87
|
async listSubAccountTransactions(subAccountId, params = {}) {
|
|
59
88
|
return this.http.request("GET", `/v1/transactions/accounts/${pathId(subAccountId)}`, {
|
|
60
89
|
query: pageQuery(params),
|
|
61
90
|
});
|
|
62
91
|
}
|
|
63
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Iterates over every transaction on a sub account, across all pages.
|
|
94
|
+
* @param subAccountId The sub account's ID.
|
|
95
|
+
* @param params Starting pagination options.
|
|
96
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
97
|
+
*/
|
|
64
98
|
iterateSubAccountTransactions(subAccountId, params = {}) {
|
|
65
99
|
return paginate(async (cursor) => {
|
|
66
100
|
const page = await this.listSubAccountTransactions(subAccountId, cursor ? { ...params, cursor } : params);
|
|
67
101
|
return { results: page.results ?? [], cursor: page.cursor ?? "" };
|
|
68
102
|
});
|
|
69
103
|
}
|
|
70
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* `POST /v1/transactions/accounts`. Filters transactions on the parent account by criteria.
|
|
106
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
107
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
108
|
+
* @returns One page of matching transactions.
|
|
109
|
+
* @throws {NombaError} The call failed.
|
|
110
|
+
*/
|
|
71
111
|
filterParentTransactions(filter = {}, page = {}) {
|
|
72
112
|
return this.http.request("POST", "/v1/transactions/accounts", {
|
|
73
113
|
body: filter,
|
|
74
114
|
query: pageQuery(page),
|
|
75
115
|
});
|
|
76
116
|
}
|
|
77
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Iterates over every parent account transaction matching the filter, across all pages.
|
|
119
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
120
|
+
* @param page Starting pagination options.
|
|
121
|
+
* @throws {NombaError} A page request failed.
|
|
122
|
+
*/
|
|
78
123
|
iterateFilteredParentTransactions(filter = {}, page = {}) {
|
|
79
124
|
return paginate(async (cursor) => {
|
|
80
125
|
const p = await this.filterParentTransactions(filter, cursor ? { ...page, cursor } : page);
|
|
81
126
|
return { results: p.results ?? [], cursor: p.cursor ?? "" };
|
|
82
127
|
});
|
|
83
128
|
}
|
|
84
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* `POST /v1/transactions/accounts/{subAccountId}`. Filters transactions on a sub account by criteria.
|
|
131
|
+
* @param subAccountId The sub account's ID.
|
|
132
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
133
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
134
|
+
* @returns One page of matching transactions.
|
|
135
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
136
|
+
*/
|
|
85
137
|
async filterSubAccountTransactions(subAccountId, filter = {}, page = {}) {
|
|
86
138
|
return this.http.request("POST", `/v1/transactions/accounts/${pathId(subAccountId)}`, {
|
|
87
139
|
body: filter,
|
|
88
140
|
query: pageQuery(page),
|
|
89
141
|
});
|
|
90
142
|
}
|
|
91
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Iterates over every sub account transaction matching the filter, across all pages.
|
|
145
|
+
* @param subAccountId The sub account's ID.
|
|
146
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
147
|
+
* @param page Starting pagination options.
|
|
148
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
149
|
+
*/
|
|
92
150
|
iterateFilteredSubAccountTransactions(subAccountId, filter = {}, page = {}) {
|
|
93
151
|
return paginate(async (cursor) => {
|
|
94
152
|
const p = await this.filterSubAccountTransactions(subAccountId, filter, cursor ? { ...page, cursor } : page);
|
|
@@ -16,25 +16,66 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
|
16
16
|
import type { IVirtualAccountsService } from "../../../interfaces/v1/virtual-accounts/IVirtualAccountsService.js";
|
|
17
17
|
import type { PageParams } from "../../../lib/util.js";
|
|
18
18
|
import type { CreatedVirtualAccount, CreateVirtualAccountParams, FilterVirtualAccountsParams, UpdateVirtualAccountParams, VirtualAccount, VirtualAccountList } from "../../../types/v1/virtual-accounts/virtual-accounts.types.js";
|
|
19
|
+
/** Virtual Accounts (v1): create, update, expire, and list virtual bank accounts that collect payments. */
|
|
19
20
|
export declare class VirtualAccountsService implements IVirtualAccountsService {
|
|
20
21
|
private readonly http;
|
|
21
22
|
constructor(http: IHttpClient);
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `POST /v1/accounts/virtual`. Creates a virtual account for the parent account.
|
|
25
|
+
* @param params The account details to create; `accountRef` is your unique identifier for lookups.
|
|
26
|
+
* @returns The created virtual account, including its bank account number.
|
|
27
|
+
* @throws {NombaError} The call failed, e.g. `accountRef` already exists.
|
|
28
|
+
*/
|
|
23
29
|
create(params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
|
|
24
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/accounts/virtual/{subAccountId}`. Creates a virtual account that collects funds
|
|
32
|
+
* into a specific sub account.
|
|
33
|
+
* @param subAccountId The sub account to receive collected funds.
|
|
34
|
+
* @param params The account details to create; `accountRef` is your unique identifier for lookups.
|
|
35
|
+
* @returns The created virtual account, including its bank account number.
|
|
36
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist or `accountRef` already exists.
|
|
37
|
+
*/
|
|
25
38
|
createForSubAccount(subAccountId: string, params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
|
|
26
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/accounts/virtual/{identifier}`. Looks up a virtual account by reference or account number.
|
|
41
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
42
|
+
* @returns The virtual account's details.
|
|
43
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
44
|
+
*/
|
|
27
45
|
get(identifier: string): Promise<VirtualAccount>;
|
|
28
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* `PUT /v1/accounts/virtual/{identifier}`. Updates a virtual account's mutable fields.
|
|
48
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
49
|
+
* @param params The fields to update (e.g., `accountName`, `expiryDate`).
|
|
50
|
+
* @returns Whether the update succeeded.
|
|
51
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
52
|
+
*/
|
|
29
53
|
update(identifier: string, params: UpdateVirtualAccountParams): Promise<{
|
|
30
54
|
updated: boolean;
|
|
31
55
|
}>;
|
|
32
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* `DELETE /v1/accounts/virtual/{identifier}`. Expires a virtual account so it no longer accepts
|
|
58
|
+
* payments. This action cannot be undone.
|
|
59
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
60
|
+
* @returns Whether the expiration succeeded.
|
|
61
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
62
|
+
*/
|
|
33
63
|
expire(identifier: string): Promise<{
|
|
34
64
|
expired: boolean;
|
|
35
65
|
}>;
|
|
36
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* `POST /v1/accounts/virtual/list`. Lists virtual accounts matching the given filters.
|
|
68
|
+
* @param filter Filters to apply (e.g., `accountName`, `resourceAcquired`).
|
|
69
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
70
|
+
* @returns One page of matching virtual accounts.
|
|
71
|
+
* @throws {NombaError} The call failed.
|
|
72
|
+
*/
|
|
37
73
|
list(filter?: FilterVirtualAccountsParams, page?: PageParams): Promise<VirtualAccountList>;
|
|
38
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Iterates over every matching virtual account, across all pages. Starts at `page.cursor` if given.
|
|
76
|
+
* @param filter Filters to apply (e.g., `accountName`, `resourceAcquired`).
|
|
77
|
+
* @param page Starting pagination options.
|
|
78
|
+
* @throws {NombaError} A page request failed.
|
|
79
|
+
*/
|
|
39
80
|
iterate(filter?: FilterVirtualAccountsParams, page?: PageParams): AsyncGenerator<VirtualAccount>;
|
|
40
81
|
}
|
|
@@ -14,41 +14,82 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { paginate } from "../../../lib/paginate.js";
|
|
16
16
|
import { pageQuery, pathId } from "../../../lib/util.js";
|
|
17
|
+
/** Virtual Accounts (v1): create, update, expire, and list virtual bank accounts that collect payments. */
|
|
17
18
|
export class VirtualAccountsService {
|
|
18
19
|
http;
|
|
19
20
|
constructor(http) {
|
|
20
21
|
this.http = http;
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `POST /v1/accounts/virtual`. Creates a virtual account for the parent account.
|
|
25
|
+
* @param params The account details to create; `accountRef` is your unique identifier for lookups.
|
|
26
|
+
* @returns The created virtual account, including its bank account number.
|
|
27
|
+
* @throws {NombaError} The call failed, e.g. `accountRef` already exists.
|
|
28
|
+
*/
|
|
23
29
|
create(params) {
|
|
24
30
|
return this.http.request("POST", "/v1/accounts/virtual", {
|
|
25
31
|
body: params,
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* `POST /v1/accounts/virtual/{subAccountId}`. Creates a virtual account that collects funds
|
|
36
|
+
* into a specific sub account.
|
|
37
|
+
* @param subAccountId The sub account to receive collected funds.
|
|
38
|
+
* @param params The account details to create; `accountRef` is your unique identifier for lookups.
|
|
39
|
+
* @returns The created virtual account, including its bank account number.
|
|
40
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist or `accountRef` already exists.
|
|
41
|
+
*/
|
|
29
42
|
async createForSubAccount(subAccountId, params) {
|
|
30
43
|
return this.http.request("POST", `/v1/accounts/virtual/${pathId(subAccountId)}`, { body: params });
|
|
31
44
|
}
|
|
32
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* `GET /v1/accounts/virtual/{identifier}`. Looks up a virtual account by reference or account number.
|
|
47
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
48
|
+
* @returns The virtual account's details.
|
|
49
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
50
|
+
*/
|
|
33
51
|
async get(identifier) {
|
|
34
52
|
return this.http.request("GET", `/v1/accounts/virtual/${pathId(identifier)}`);
|
|
35
53
|
}
|
|
36
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* `PUT /v1/accounts/virtual/{identifier}`. Updates a virtual account's mutable fields.
|
|
56
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
57
|
+
* @param params The fields to update (e.g., `accountName`, `expiryDate`).
|
|
58
|
+
* @returns Whether the update succeeded.
|
|
59
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
60
|
+
*/
|
|
37
61
|
async update(identifier, params) {
|
|
38
62
|
return this.http.request("PUT", `/v1/accounts/virtual/${pathId(identifier)}`, { body: params });
|
|
39
63
|
}
|
|
40
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* `DELETE /v1/accounts/virtual/{identifier}`. Expires a virtual account so it no longer accepts
|
|
66
|
+
* payments. This action cannot be undone.
|
|
67
|
+
* @param identifier The `accountRef` or the 10-digit virtual account number.
|
|
68
|
+
* @returns Whether the expiration succeeded.
|
|
69
|
+
* @throws {NombaError} The call failed, e.g. `identifier` does not match any account.
|
|
70
|
+
*/
|
|
41
71
|
async expire(identifier) {
|
|
42
72
|
return this.http.request("DELETE", `/v1/accounts/virtual/${pathId(identifier)}`);
|
|
43
73
|
}
|
|
44
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* `POST /v1/accounts/virtual/list`. Lists virtual accounts matching the given filters.
|
|
76
|
+
* @param filter Filters to apply (e.g., `accountName`, `resourceAcquired`).
|
|
77
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
78
|
+
* @returns One page of matching virtual accounts.
|
|
79
|
+
* @throws {NombaError} The call failed.
|
|
80
|
+
*/
|
|
45
81
|
list(filter = {}, page = {}) {
|
|
46
82
|
return this.http.request("POST", "/v1/accounts/virtual/list", {
|
|
47
83
|
body: filter,
|
|
48
84
|
query: pageQuery(page),
|
|
49
85
|
});
|
|
50
86
|
}
|
|
51
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Iterates over every matching virtual account, across all pages. Starts at `page.cursor` if given.
|
|
89
|
+
* @param filter Filters to apply (e.g., `accountName`, `resourceAcquired`).
|
|
90
|
+
* @param page Starting pagination options.
|
|
91
|
+
* @throws {NombaError} A page request failed.
|
|
92
|
+
*/
|
|
52
93
|
iterate(filter = {}, page = {}) {
|
|
53
94
|
return paginate((cursor) => this.list(filter, cursor ? { ...page, cursor } : page));
|
|
54
95
|
}
|