@nomba/node-sdk 0.1.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.
Files changed (82) hide show
  1. package/README.md +77 -16
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/interfaces/v1/accounts/IAccountsService.d.ts +46 -8
  5. package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -2
  6. package/dist/interfaces/v1/cable/ICableService.d.ts +12 -2
  7. package/dist/interfaces/v1/charge/IChargeService.d.ts +80 -19
  8. package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +64 -15
  9. package/dist/interfaces/v1/data/IDataService.d.ts +6 -1
  10. package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +37 -14
  11. package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -2
  12. package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +22 -5
  13. package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +76 -13
  14. package/dist/interfaces/v1/requery/IRequeryService.d.ts +19 -5
  15. package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +43 -10
  16. package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +71 -12
  17. package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +50 -12
  18. package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +29 -10
  19. package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +21 -2
  20. package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +21 -2
  21. package/dist/interfaces/v2/cable/ICableV2Service.d.ts +21 -2
  22. package/dist/interfaces/v2/data/IDataV2Service.d.ts +21 -2
  23. package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +22 -2
  24. package/dist/interfaces/v2/transfers/ITransfersService.d.ts +57 -6
  25. package/dist/lib/errors.d.ts +19 -0
  26. package/dist/lib/errors.js +23 -0
  27. package/dist/lib/outcome.d.ts +30 -5
  28. package/dist/lib/outcome.js +31 -6
  29. package/dist/lib/sdk-version.generated.d.ts +1 -1
  30. package/dist/lib/sdk-version.generated.js +1 -1
  31. package/dist/lib/util.d.ts +0 -1
  32. package/dist/lib/util.js +0 -6
  33. package/dist/nomba.d.ts +38 -5
  34. package/dist/nomba.js +38 -5
  35. package/dist/services/http/http-client.service.d.ts +40 -6
  36. package/dist/services/http/http-client.service.js +44 -9
  37. package/dist/services/v1/accounts/accounts.service.d.ts +46 -8
  38. package/dist/services/v1/accounts/accounts.service.js +46 -8
  39. package/dist/services/v1/betting/betting.service.d.ts +12 -2
  40. package/dist/services/v1/betting/betting.service.js +12 -2
  41. package/dist/services/v1/cable/cable.service.d.ts +13 -2
  42. package/dist/services/v1/cable/cable.service.js +13 -2
  43. package/dist/services/v1/charge/charge.service.d.ts +80 -19
  44. package/dist/services/v1/charge/charge.service.js +88 -26
  45. package/dist/services/v1/checkout/checkout.service.d.ts +63 -15
  46. package/dist/services/v1/checkout/checkout.service.js +70 -24
  47. package/dist/services/v1/data/data.service.d.ts +7 -1
  48. package/dist/services/v1/data/data.service.js +7 -1
  49. package/dist/services/v1/direct-debits/direct-debits.service.d.ts +38 -14
  50. package/dist/services/v1/direct-debits/direct-debits.service.js +39 -17
  51. package/dist/services/v1/electricity/electricity.service.d.ts +12 -2
  52. package/dist/services/v1/electricity/electricity.service.js +12 -2
  53. package/dist/services/v1/globals/collections.service.d.ts +23 -5
  54. package/dist/services/v1/globals/collections.service.js +29 -7
  55. package/dist/services/v1/globals/payout.service.d.ts +77 -13
  56. package/dist/services/v1/globals/payout.service.js +83 -17
  57. package/dist/services/v1/requery/requery.service.d.ts +23 -5
  58. package/dist/services/v1/requery/requery.service.js +23 -5
  59. package/dist/services/v1/terminals/terminals.service.d.ts +42 -14
  60. package/dist/services/v1/terminals/terminals.service.js +44 -27
  61. package/dist/services/v1/transactions/transactions.service.d.ts +70 -12
  62. package/dist/services/v1/transactions/transactions.service.js +70 -12
  63. package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +52 -12
  64. package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +55 -15
  65. package/dist/services/v1/webhooks/webhooks.service.d.ts +31 -10
  66. package/dist/services/v1/webhooks/webhooks.service.js +35 -14
  67. package/dist/services/v2/airtime/airtime.service.d.ts +26 -2
  68. package/dist/services/v2/airtime/airtime.service.js +27 -7
  69. package/dist/services/v2/betting/betting.service.d.ts +27 -3
  70. package/dist/services/v2/betting/betting.service.js +28 -8
  71. package/dist/services/v2/cable/cable.service.d.ts +27 -3
  72. package/dist/services/v2/cable/cable.service.js +28 -8
  73. package/dist/services/v2/data/data.service.d.ts +26 -2
  74. package/dist/services/v2/data/data.service.js +27 -7
  75. package/dist/services/v2/electricity/electricity.service.d.ts +28 -3
  76. package/dist/services/v2/electricity/electricity.service.js +29 -8
  77. package/dist/services/v2/transfers/transfers.service.d.ts +51 -6
  78. package/dist/services/v2/transfers/transfers.service.js +55 -25
  79. package/dist/types/common/common.types.d.ts +10 -13
  80. package/dist/types/v1/globals/collections.types.d.ts +3 -3
  81. package/dist/types/v1/globals/payout.types.d.ts +3 -3
  82. package/package.json +1 -1
@@ -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
- /** GET /v1/transactions/bank. Credit/debit transactions on the parent account. */
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
- /** Every credit/debit transaction, across all pages. Starts at `params.cursor` if given. */
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. Documented in the guide only. The response carries a `cursor`, but the
37
- * guide names no paging parameter, so only the first page is returned.
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
- /** GET /v1/transactions/accounts */
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
- /** Every transaction on the parent account, across all pages. Starts at `params.cursor` if given. */
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
- /** GET /v1/transactions/accounts/{subAccountId} */
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
- /** Every transaction on a sub account, across all pages. Starts at `params.cursor` if given. */
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
- /** POST /v1/transactions/accounts */
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
- /** Every parent transaction matching the filter, across all pages. Starts at `page.cursor` if given. */
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
- /** POST /v1/transactions/accounts/{subAccountId} */
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
- /** Every sub account transaction matching the filter, across all pages. Starts at `page.cursor` if given. */
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);
@@ -15,27 +15,67 @@
15
15
  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
- import type { RequestOptions } from "../../../types/common/common.types.js";
19
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. */
20
20
  export declare class VirtualAccountsService implements IVirtualAccountsService {
21
21
  private readonly http;
22
22
  constructor(http: IHttpClient);
23
- /** POST /v1/accounts/virtual */
24
- create(params: CreateVirtualAccountParams, options?: RequestOptions): Promise<CreatedVirtualAccount>;
25
- /** POST /v1/accounts/virtual/{subAccountId}. Funds are collected in that sub account. */
26
- createForSubAccount(subAccountId: string, params: CreateVirtualAccountParams, options?: RequestOptions): Promise<CreatedVirtualAccount>;
27
- /** GET /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the virtual account number. */
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
+ */
29
+ create(params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
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
+ */
38
+ createForSubAccount(subAccountId: string, params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
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
+ */
28
45
  get(identifier: string): Promise<VirtualAccount>;
29
- /** PUT /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the 10 digit account number. */
30
- update(identifier: string, params: UpdateVirtualAccountParams, options?: RequestOptions): Promise<{
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
+ */
53
+ update(identifier: string, params: UpdateVirtualAccountParams): Promise<{
31
54
  updated: boolean;
32
55
  }>;
33
- /** DELETE /v1/accounts/virtual/{identifier}. Stops the account accepting payments. */
34
- expire(identifier: string, options?: RequestOptions): Promise<{
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
+ */
63
+ expire(identifier: string): Promise<{
35
64
  expired: boolean;
36
65
  }>;
37
- /** POST /v1/accounts/virtual/list */
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
+ */
38
73
  list(filter?: FilterVirtualAccountsParams, page?: PageParams): Promise<VirtualAccountList>;
39
- /** Every matching virtual account, across all pages. Starts at `page.cursor` if given. */
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
+ */
40
80
  iterate(filter?: FilterVirtualAccountsParams, page?: PageParams): AsyncGenerator<VirtualAccount>;
41
81
  }
@@ -14,42 +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
- /** POST /v1/accounts/virtual */
23
- create(params, options = {}) {
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
+ */
29
+ create(params) {
24
30
  return this.http.request("POST", "/v1/accounts/virtual", {
25
31
  body: params,
26
- ...options,
27
32
  });
28
33
  }
29
- /** POST /v1/accounts/virtual/{subAccountId}. Funds are collected in that sub account. */
30
- async createForSubAccount(subAccountId, params, options = {}) {
31
- return this.http.request("POST", `/v1/accounts/virtual/${pathId(subAccountId)}`, { body: params, ...options });
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
+ */
42
+ async createForSubAccount(subAccountId, params) {
43
+ return this.http.request("POST", `/v1/accounts/virtual/${pathId(subAccountId)}`, { body: params });
32
44
  }
33
- /** GET /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the virtual account number. */
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
+ */
34
51
  async get(identifier) {
35
52
  return this.http.request("GET", `/v1/accounts/virtual/${pathId(identifier)}`);
36
53
  }
37
- /** PUT /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the 10 digit account number. */
38
- async update(identifier, params, options = {}) {
39
- return this.http.request("PUT", `/v1/accounts/virtual/${pathId(identifier)}`, { body: params, ...options });
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
+ */
61
+ async update(identifier, params) {
62
+ return this.http.request("PUT", `/v1/accounts/virtual/${pathId(identifier)}`, { body: params });
40
63
  }
41
- /** DELETE /v1/accounts/virtual/{identifier}. Stops the account accepting payments. */
42
- async expire(identifier, options = {}) {
43
- return this.http.request("DELETE", `/v1/accounts/virtual/${pathId(identifier)}`, options);
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
+ */
71
+ async expire(identifier) {
72
+ return this.http.request("DELETE", `/v1/accounts/virtual/${pathId(identifier)}`);
44
73
  }
45
- /** POST /v1/accounts/virtual/list */
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
+ */
46
81
  list(filter = {}, page = {}) {
47
82
  return this.http.request("POST", "/v1/accounts/virtual/list", {
48
83
  body: filter,
49
84
  query: pageQuery(page),
50
85
  });
51
86
  }
52
- /** Every matching virtual account, across all pages. Starts at `page.cursor` if given. */
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
+ */
53
93
  iterate(filter = {}, page = {}) {
54
94
  return paginate((cursor) => this.list(filter, cursor ? { ...page, cursor } : page));
55
95
  }
@@ -14,23 +14,44 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { IWebhooksService } from "../../../interfaces/v1/webhooks/IWebhooksService.js";
17
- import type { RequestOptions } from "../../../types/common/common.types.js";
18
17
  import type { EventLog, EventLogsParams, EventsParams, ReplayParams, WebhookList, WebhookSubscription } from "../../../types/v1/webhooks/webhooks.types.js";
18
+ /** Webhooks (v1): delivery logs, re-push, and replay for troubleshooting webhook delivery. */
19
19
  export declare class WebhooksService implements IWebhooksService {
20
20
  #private;
21
21
  private readonly http;
22
22
  constructor(http: IHttpClient);
23
- /** POST /v1/webhooks/event-logs. Webhooks sent to your system and how your server answered. */
23
+ /**
24
+ * `POST /v1/webhooks/event-logs`. Returns webhooks sent to your system and how your server answered.
25
+ * Useful for debugging missed or failed deliveries.
26
+ * @param params Filters (e.g., `startDate`, `endDate`, `eventType`).
27
+ * @returns A list of webhook event logs.
28
+ * @throws {NombaError} The call failed.
29
+ */
24
30
  eventLogs(params?: EventLogsParams): Promise<WebhookList<EventLog>>;
25
- /** POST /v1/webhooks/events. Your webhook subscriptions. */
31
+ /**
32
+ * `POST /v1/webhooks/events`. Returns your webhook subscriptions.
33
+ * @param params Filters (e.g., `eventType`).
34
+ * @returns A list of webhook subscriptions.
35
+ * @throws {NombaError} The call failed.
36
+ */
26
37
  events(params?: EventsParams): Promise<WebhookList<WebhookSubscription>>;
27
38
  /**
28
- * POST /v1/webhooks/re-push. Resends one event. Takes an event log's `hookRequestId`; the request field
29
- * is spelled `hooksRequestId`, as the guide shows.
39
+ * `POST /v1/webhooks/re-push`. Resends a single webhook event. Use the `hookRequestId` from `eventLogs`.
40
+ * @param hookRequestId The event log's ID to resend.
41
+ * @throws {NombaError} The call failed, e.g. `hookRequestId` does not exist.
42
+ */
43
+ repush(hookRequestId: string): Promise<void>;
44
+ /**
45
+ * `POST /v1/webhooks/bulk-re-push`. Resends multiple webhook events at once.
46
+ * @param hookRequestIds The event log IDs to resend.
47
+ * @throws {NombaError} The call failed.
48
+ */
49
+ bulkRepush(hookRequestIds: string[]): Promise<void>;
50
+ /**
51
+ * `POST /v1/webhooks/replay`. Resends every matching webhook event in a time window.
52
+ * Useful for recovering from webhook handler outages.
53
+ * @param params The time window (`startDate`, `endDate`) and optional filters.
54
+ * @throws {NombaError} The call failed.
30
55
  */
31
- repush(hookRequestId: string, options?: RequestOptions): Promise<void>;
32
- /** POST /v1/webhooks/bulk-re-push */
33
- bulkRepush(hookRequestIds: string[], options?: RequestOptions): Promise<void>;
34
- /** POST /v1/webhooks/replay. Resends every matching event in the time window. */
35
- replay(params: ReplayParams, options?: RequestOptions): Promise<void>;
56
+ replay(params: ReplayParams): Promise<void>;
36
57
  }
@@ -15,19 +15,31 @@
15
15
  // Documented in the guide only (no API reference page). Its examples answer code "200", not "00", and never
16
16
  // mark request fields as required, so every field is optional here.
17
17
  const OK_CODES = ["00", "200"];
18
+ /** Webhooks (v1): delivery logs, re-push, and replay for troubleshooting webhook delivery. */
18
19
  export class WebhooksService {
19
20
  http;
20
21
  constructor(http) {
21
22
  this.http = http;
22
23
  }
23
- /** POST /v1/webhooks/event-logs. Webhooks sent to your system and how your server answered. */
24
+ /**
25
+ * `POST /v1/webhooks/event-logs`. Returns webhooks sent to your system and how your server answered.
26
+ * Useful for debugging missed or failed deliveries.
27
+ * @param params Filters (e.g., `startDate`, `endDate`, `eventType`).
28
+ * @returns A list of webhook event logs.
29
+ * @throws {NombaError} The call failed.
30
+ */
24
31
  eventLogs(params = {}) {
25
32
  return this.http.request("POST", "/v1/webhooks/event-logs", {
26
33
  body: params,
27
34
  okCodes: OK_CODES,
28
35
  });
29
36
  }
30
- /** POST /v1/webhooks/events. Your webhook subscriptions. */
37
+ /**
38
+ * `POST /v1/webhooks/events`. Returns your webhook subscriptions.
39
+ * @param params Filters (e.g., `eventType`).
40
+ * @returns A list of webhook subscriptions.
41
+ * @throws {NombaError} The call failed.
42
+ */
31
43
  events(params = {}) {
32
44
  return this.http.request("POST", "/v1/webhooks/events", {
33
45
  body: params,
@@ -35,26 +47,35 @@ export class WebhooksService {
35
47
  });
36
48
  }
37
49
  /**
38
- * POST /v1/webhooks/re-push. Resends one event. Takes an event log's `hookRequestId`; the request field
39
- * is spelled `hooksRequestId`, as the guide shows.
50
+ * `POST /v1/webhooks/re-push`. Resends a single webhook event. Use the `hookRequestId` from `eventLogs`.
51
+ * @param hookRequestId The event log's ID to resend.
52
+ * @throws {NombaError} The call failed, e.g. `hookRequestId` does not exist.
40
53
  */
41
- repush(hookRequestId, options = {}) {
42
- return this.#post("re-push", { hooksRequestId: hookRequestId }, options);
54
+ repush(hookRequestId) {
55
+ return this.#post("re-push", { hooksRequestId: hookRequestId });
43
56
  }
44
- /** POST /v1/webhooks/bulk-re-push */
45
- bulkRepush(hookRequestIds, options = {}) {
46
- return this.#post("bulk-re-push", { hooksRequestIds: hookRequestIds }, options);
57
+ /**
58
+ * `POST /v1/webhooks/bulk-re-push`. Resends multiple webhook events at once.
59
+ * @param hookRequestIds The event log IDs to resend.
60
+ * @throws {NombaError} The call failed.
61
+ */
62
+ bulkRepush(hookRequestIds) {
63
+ return this.#post("bulk-re-push", { hooksRequestIds: hookRequestIds });
47
64
  }
48
- /** POST /v1/webhooks/replay. Resends every matching event in the time window. */
49
- replay(params, options = {}) {
50
- return this.#post("replay", params, options);
65
+ /**
66
+ * `POST /v1/webhooks/replay`. Resends every matching webhook event in a time window.
67
+ * Useful for recovering from webhook handler outages.
68
+ * @param params The time window (`startDate`, `endDate`) and optional filters.
69
+ * @throws {NombaError} The call failed.
70
+ */
71
+ replay(params) {
72
+ return this.#post("replay", params);
51
73
  }
52
74
  // These answer with no `data`, so the client resolves to undefined.
53
- #post(path, body, options) {
75
+ #post(path, body) {
54
76
  return this.http.request("POST", `/v1/webhooks/${path}`, {
55
77
  body,
56
78
  okCodes: OK_CODES,
57
- ...options,
58
79
  });
59
80
  }
60
81
  }
@@ -7,12 +7,36 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IAirtimeV2Service } from "../../../interfaces/v2/airtime/index.js";
8
8
  import type { CallOptions } from "../../../types/common/common.types.js";
9
9
  import type { AirtimePurchaseParams, AirtimePurchaseV2Result } from "../../../types/v2/airtime/airtime.types.js";
10
+ /**
11
+ * Airtime top-ups (v2). A call that throws a NombaError with a 4xx status was rejected and did nothing.
12
+ * Any other failure (5xx, network error, timeout) leaves the outcome unknown: keep the same
13
+ * `merchantTxRef`, wait for the webhook or requery, and never retry under a new reference.
14
+ */
10
15
  export declare class AirtimeV2Service implements IAirtimeV2Service {
11
16
  #private;
12
17
  private readonly http;
13
18
  constructor(http: IHttpClient);
14
- /** POST /v2/bill/topup, from the parent account. */
19
+ /**
20
+ * `POST /v2/bill/topup`. Buys airtime from the parent account.
21
+ * @param params The phone number, network and amount, and the `merchantTxRef` used for idempotency.
22
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
23
+ * a rejection or pending outcome throws.
24
+ * @returns The purchase result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
25
+ * @throws {NombaError} The purchase was rejected (4xx).
26
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
27
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
28
+ */
15
29
  buyAirtime<R = AirtimePurchaseV2Result>(params: AirtimePurchaseParams, options?: CallOptions<AirtimePurchaseV2Result, R>): Promise<AirtimePurchaseV2Result | R>;
16
- /** POST /v2/bill/topup/{subAccountId}. Buys airtime from a sub account. */
30
+ /**
31
+ * `POST /v2/bill/topup/{subAccountId}`. Buys airtime from a sub account.
32
+ * @param subAccountId The sub account to buy from.
33
+ * @param params The phone number, network and amount, and the `merchantTxRef` used for idempotency.
34
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
35
+ * a rejection or pending outcome throws.
36
+ * @returns The purchase result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
37
+ * @throws {NombaError} The purchase was rejected (4xx).
38
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
39
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
40
+ */
17
41
  buyAirtimeFromSubAccount<R = AirtimePurchaseV2Result>(subAccountId: string, params: AirtimePurchaseParams, options?: CallOptions<AirtimePurchaseV2Result, R>): Promise<AirtimePurchaseV2Result | R>;
18
42
  }
@@ -12,24 +12,44 @@ const OUTCOMES = {
12
12
  codes: { "00": "success", "200": "success", "201": "pending", ...REJECTED },
13
13
  statuses: { SUCCESS: "success", PENDING_BILLING: "pending" },
14
14
  };
15
+ /**
16
+ * Airtime top-ups (v2). A call that throws a NombaError with a 4xx status was rejected and did nothing.
17
+ * Any other failure (5xx, network error, timeout) leaves the outcome unknown: keep the same
18
+ * `merchantTxRef`, wait for the webhook or requery, and never retry under a new reference.
19
+ */
15
20
  export class AirtimeV2Service {
16
21
  http;
17
22
  constructor(http) {
18
23
  this.http = http;
19
24
  }
20
- /** POST /v2/bill/topup, from the parent account. */
25
+ /**
26
+ * `POST /v2/bill/topup`. Buys airtime from the parent account.
27
+ * @param params The phone number, network and amount, and the `merchantTxRef` used for idempotency.
28
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
29
+ * a rejection or pending outcome throws.
30
+ * @returns The purchase result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
31
+ * @throws {NombaError} The purchase was rejected (4xx).
32
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
33
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
34
+ */
21
35
  async buyAirtime(params, options = {}) {
22
36
  return this.#buy("/v2/bill/topup", params, options);
23
37
  }
24
- /** POST /v2/bill/topup/{subAccountId}. Buys airtime from a sub account. */
38
+ /**
39
+ * `POST /v2/bill/topup/{subAccountId}`. Buys airtime from a sub account.
40
+ * @param subAccountId The sub account to buy from.
41
+ * @param params The phone number, network and amount, and the `merchantTxRef` used for idempotency.
42
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
43
+ * a rejection or pending outcome throws.
44
+ * @returns The purchase result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
45
+ * @throws {NombaError} The purchase was rejected (4xx).
46
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
47
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
48
+ */
25
49
  async buyAirtimeFromSubAccount(subAccountId, params, options = {}) {
26
50
  return this.#buy(`/v2/bill/topup/${pathId(subAccountId)}`, params, options);
27
51
  }
28
- // merchantTxRef is the default idempotency key, as for every bill payment.
29
52
  #buy(path, params, options) {
30
- return settle(this.http, "POST", path, { body: params }, OUTCOMES, {
31
- ...options,
32
- idempotencyKey: options.idempotencyKey ?? params.merchantTxRef,
33
- });
53
+ return settle(this.http, "POST", path, { body: params }, OUTCOMES, { field: "merchantTxRef", value: params.merchantTxRef }, options);
34
54
  }
35
55
  }
@@ -7,13 +7,37 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IBettingV2Service } from "../../../interfaces/v2/betting/index.js";
8
8
  import type { CallOptions } from "../../../types/common/common.types.js";
9
9
  import type { BettingPaymentParams, BettingPaymentV2Result } from "../../../types/v2/betting/betting.types.js";
10
- /** v2 has purchase endpoints only. */
10
+ /**
11
+ * Betting wallet funding (v2 has purchase endpoints only). A call that throws a NombaError with a 4xx
12
+ * status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the outcome
13
+ * unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a new
14
+ * reference.
15
+ */
11
16
  export declare class BettingV2Service implements IBettingV2Service {
12
17
  #private;
13
18
  private readonly http;
14
19
  constructor(http: IHttpClient);
15
- /** POST /v2/bill/betting, from the parent account. */
20
+ /**
21
+ * `POST /v2/bill/betting`. Funds a betting wallet from the parent account.
22
+ * @param params The betting provider, customer id and amount, and the `merchantTxRef` used for idempotency.
23
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
24
+ * a rejection or pending outcome throws.
25
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
26
+ * @throws {NombaError} The payment was rejected (4xx).
27
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
28
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
29
+ */
16
30
  payBetting<R = BettingPaymentV2Result>(params: BettingPaymentParams, options?: CallOptions<BettingPaymentV2Result, R>): Promise<BettingPaymentV2Result | R>;
17
- /** POST /v2/bill/betting/{subAccountId}. Pays from a sub account. */
31
+ /**
32
+ * `POST /v2/bill/betting/{subAccountId}`. Pays from a sub account.
33
+ * @param subAccountId The sub account to pay from.
34
+ * @param params The betting provider, customer id and amount, and the `merchantTxRef` used for idempotency.
35
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
36
+ * a rejection or pending outcome throws.
37
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
38
+ * @throws {NombaError} The payment was rejected (4xx).
39
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
40
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
41
+ */
18
42
  payBettingFromSubAccount<R = BettingPaymentV2Result>(subAccountId: string, params: BettingPaymentParams, options?: CallOptions<BettingPaymentV2Result, R>): Promise<BettingPaymentV2Result | R>;
19
43
  }