@nomba/node-sdk 0.1.0 → 0.3.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 (70) hide show
  1. package/README.md +31 -4
  2. package/dist/interfaces/v1/accounts/IAccountsService.d.ts +46 -8
  3. package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -2
  4. package/dist/interfaces/v1/cable/ICableService.d.ts +12 -2
  5. package/dist/interfaces/v1/charge/IChargeService.d.ts +80 -19
  6. package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +64 -15
  7. package/dist/interfaces/v1/data/IDataService.d.ts +6 -1
  8. package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +37 -14
  9. package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -2
  10. package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +20 -5
  11. package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +74 -13
  12. package/dist/interfaces/v1/requery/IRequeryService.d.ts +19 -5
  13. package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +43 -10
  14. package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +71 -12
  15. package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +50 -12
  16. package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +29 -10
  17. package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +21 -2
  18. package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +21 -2
  19. package/dist/interfaces/v2/cable/ICableV2Service.d.ts +21 -2
  20. package/dist/interfaces/v2/data/IDataV2Service.d.ts +21 -2
  21. package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +22 -2
  22. package/dist/interfaces/v2/transfers/ITransfersService.d.ts +57 -6
  23. package/dist/lib/outcome.d.ts +24 -5
  24. package/dist/lib/outcome.js +24 -5
  25. package/dist/lib/sdk-version.generated.d.ts +1 -1
  26. package/dist/lib/sdk-version.generated.js +1 -1
  27. package/dist/nomba.d.ts +38 -5
  28. package/dist/nomba.js +38 -5
  29. package/dist/services/http/http-client.service.d.ts +40 -6
  30. package/dist/services/http/http-client.service.js +40 -6
  31. package/dist/services/v1/accounts/accounts.service.d.ts +46 -8
  32. package/dist/services/v1/accounts/accounts.service.js +46 -8
  33. package/dist/services/v1/betting/betting.service.d.ts +11 -2
  34. package/dist/services/v1/betting/betting.service.js +11 -2
  35. package/dist/services/v1/cable/cable.service.d.ts +12 -2
  36. package/dist/services/v1/cable/cable.service.js +12 -2
  37. package/dist/services/v1/charge/charge.service.d.ts +80 -19
  38. package/dist/services/v1/charge/charge.service.js +88 -26
  39. package/dist/services/v1/checkout/checkout.service.d.ts +63 -15
  40. package/dist/services/v1/checkout/checkout.service.js +70 -24
  41. package/dist/services/v1/data/data.service.d.ts +7 -1
  42. package/dist/services/v1/data/data.service.js +7 -1
  43. package/dist/services/v1/direct-debits/direct-debits.service.d.ts +38 -14
  44. package/dist/services/v1/direct-debits/direct-debits.service.js +39 -17
  45. package/dist/services/v1/electricity/electricity.service.d.ts +12 -2
  46. package/dist/services/v1/electricity/electricity.service.js +12 -2
  47. package/dist/services/v1/globals/collections.service.d.ts +21 -5
  48. package/dist/services/v1/globals/collections.service.js +22 -5
  49. package/dist/services/v1/globals/payout.service.d.ts +73 -13
  50. package/dist/services/v1/globals/payout.service.js +74 -15
  51. package/dist/services/v1/terminals/terminals.service.d.ts +5 -5
  52. package/dist/services/v1/terminals/terminals.service.js +7 -18
  53. package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +4 -5
  54. package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +7 -8
  55. package/dist/services/v1/webhooks/webhooks.service.d.ts +3 -4
  56. package/dist/services/v1/webhooks/webhooks.service.js +7 -8
  57. package/dist/services/v2/airtime/airtime.service.d.ts +26 -2
  58. package/dist/services/v2/airtime/airtime.service.js +27 -7
  59. package/dist/services/v2/betting/betting.service.d.ts +27 -3
  60. package/dist/services/v2/betting/betting.service.js +28 -8
  61. package/dist/services/v2/cable/cable.service.d.ts +27 -3
  62. package/dist/services/v2/cable/cable.service.js +28 -8
  63. package/dist/services/v2/data/data.service.d.ts +26 -2
  64. package/dist/services/v2/data/data.service.js +27 -7
  65. package/dist/services/v2/electricity/electricity.service.d.ts +28 -3
  66. package/dist/services/v2/electricity/electricity.service.js +29 -8
  67. package/dist/services/v2/transfers/transfers.service.d.ts +51 -6
  68. package/dist/services/v2/transfers/transfers.service.js +55 -25
  69. package/dist/types/common/common.types.d.ts +9 -13
  70. package/package.json +1 -1
@@ -14,7 +14,6 @@
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";
19
18
  export declare class WebhooksService implements IWebhooksService {
20
19
  #private;
@@ -28,9 +27,9 @@ export declare class WebhooksService implements IWebhooksService {
28
27
  * POST /v1/webhooks/re-push. Resends one event. Takes an event log's `hookRequestId`; the request field
29
28
  * is spelled `hooksRequestId`, as the guide shows.
30
29
  */
31
- repush(hookRequestId: string, options?: RequestOptions): Promise<void>;
30
+ repush(hookRequestId: string): Promise<void>;
32
31
  /** POST /v1/webhooks/bulk-re-push */
33
- bulkRepush(hookRequestIds: string[], options?: RequestOptions): Promise<void>;
32
+ bulkRepush(hookRequestIds: string[]): Promise<void>;
34
33
  /** POST /v1/webhooks/replay. Resends every matching event in the time window. */
35
- replay(params: ReplayParams, options?: RequestOptions): Promise<void>;
34
+ replay(params: ReplayParams): Promise<void>;
36
35
  }
@@ -38,23 +38,22 @@ export class WebhooksService {
38
38
  * POST /v1/webhooks/re-push. Resends one event. Takes an event log's `hookRequestId`; the request field
39
39
  * is spelled `hooksRequestId`, as the guide shows.
40
40
  */
41
- repush(hookRequestId, options = {}) {
42
- return this.#post("re-push", { hooksRequestId: hookRequestId }, options);
41
+ repush(hookRequestId) {
42
+ return this.#post("re-push", { hooksRequestId: hookRequestId });
43
43
  }
44
44
  /** POST /v1/webhooks/bulk-re-push */
45
- bulkRepush(hookRequestIds, options = {}) {
46
- return this.#post("bulk-re-push", { hooksRequestIds: hookRequestIds }, options);
45
+ bulkRepush(hookRequestIds) {
46
+ return this.#post("bulk-re-push", { hooksRequestIds: hookRequestIds });
47
47
  }
48
48
  /** POST /v1/webhooks/replay. Resends every matching event in the time window. */
49
- replay(params, options = {}) {
50
- return this.#post("replay", params, options);
49
+ replay(params) {
50
+ return this.#post("replay", params);
51
51
  }
52
52
  // These answer with no `data`, so the client resolves to undefined.
53
- #post(path, body, options) {
53
+ #post(path, body) {
54
54
  return this.http.request("POST", `/v1/webhooks/${path}`, {
55
55
  body,
56
56
  okCodes: OK_CODES,
57
- ...options,
58
57
  });
59
58
  }
60
59
  }
@@ -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, 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
  }
@@ -12,25 +12,45 @@ const OUTCOMES = {
12
12
  codes: { "00": "success", "200": "success", "201": "pending", ...REJECTED },
13
13
  statuses: { SUCCESS: "success", PENDING_BILLING: "pending" },
14
14
  };
15
- /** v2 has purchase endpoints only. */
15
+ /**
16
+ * Betting wallet funding (v2 has purchase endpoints only). A call that throws a NombaError with a 4xx
17
+ * status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the outcome
18
+ * unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a new
19
+ * reference.
20
+ */
16
21
  export class BettingV2Service {
17
22
  http;
18
23
  constructor(http) {
19
24
  this.http = http;
20
25
  }
21
- /** POST /v2/bill/betting, from the parent account. */
26
+ /**
27
+ * `POST /v2/bill/betting`. Funds a betting wallet from the parent account.
28
+ * @param params The betting provider, customer id and amount, and the `merchantTxRef` used for idempotency.
29
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
30
+ * a rejection or pending outcome throws.
31
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
32
+ * @throws {NombaError} The payment was rejected (4xx).
33
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
34
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
35
+ */
22
36
  async payBetting(params, options = {}) {
23
37
  return this.#pay("/v2/bill/betting", params, options);
24
38
  }
25
- /** POST /v2/bill/betting/{subAccountId}. Pays from a sub account. */
39
+ /**
40
+ * `POST /v2/bill/betting/{subAccountId}`. Pays from a sub account.
41
+ * @param subAccountId The sub account to pay from.
42
+ * @param params The betting provider, customer id and amount, and the `merchantTxRef` used for idempotency.
43
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
44
+ * a rejection or pending outcome throws.
45
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
46
+ * @throws {NombaError} The payment was rejected (4xx).
47
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
48
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
49
+ */
26
50
  async payBettingFromSubAccount(subAccountId, params, options = {}) {
27
51
  return this.#pay(`/v2/bill/betting/${pathId(subAccountId)}`, params, options);
28
52
  }
29
- // merchantTxRef is the default idempotency key, as for every bill payment.
30
53
  #pay(path, params, options) {
31
- return settle(this.http, "POST", path, { body: params }, OUTCOMES, {
32
- ...options,
33
- idempotencyKey: options.idempotencyKey ?? params.merchantTxRef,
34
- });
54
+ return settle(this.http, "POST", path, { body: params }, OUTCOMES, params.merchantTxRef, options);
35
55
  }
36
56
  }
@@ -7,13 +7,37 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { ICableV2Service } from "../../../interfaces/v2/cable/index.js";
8
8
  import type { CallOptions } from "../../../types/common/common.types.js";
9
9
  import type { CablePaymentV2Result, CableTvSubscriptionParams } from "../../../types/v2/cable/cable.types.js";
10
- /** v2 has purchase endpoints only. */
10
+ /**
11
+ * Cable TV subscription payments (v2 has purchase endpoints only). A call that throws a NombaError with a
12
+ * 4xx status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the
13
+ * outcome unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a
14
+ * new reference.
15
+ */
11
16
  export declare class CableV2Service implements ICableV2Service {
12
17
  #private;
13
18
  private readonly http;
14
19
  constructor(http: IHttpClient);
15
- /** POST /v2/bill/cabletv, from the parent account. */
20
+ /**
21
+ * `POST /v2/bill/cabletv`. Pays a cable TV subscription from the parent account.
22
+ * @param params The provider, smartcard/customer id and plan, 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
  subscribeCableTv<R = CablePaymentV2Result>(params: CableTvSubscriptionParams, options?: CallOptions<CablePaymentV2Result, R>): Promise<CablePaymentV2Result | R>;
17
- /** POST /v2/bill/cabletv/{subAccountId}. Pays from a sub account. */
31
+ /**
32
+ * `POST /v2/bill/cabletv/{subAccountId}`. Pays from a sub account.
33
+ * @param subAccountId The sub account to pay from.
34
+ * @param params The provider, smartcard/customer id and plan, 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
  subscribeCableTvFromSubAccount<R = CablePaymentV2Result>(subAccountId: string, params: CableTvSubscriptionParams, options?: CallOptions<CablePaymentV2Result, R>): Promise<CablePaymentV2Result | R>;
19
43
  }
@@ -12,25 +12,45 @@ const OUTCOMES = {
12
12
  codes: { "00": "success", "200": "success", "201": "pending", ...REJECTED },
13
13
  statuses: { SUCCESS: "success", PENDING_BILLING: "pending" },
14
14
  };
15
- /** v2 has purchase endpoints only. */
15
+ /**
16
+ * Cable TV subscription payments (v2 has purchase endpoints only). A call that throws a NombaError with a
17
+ * 4xx status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the
18
+ * outcome unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a
19
+ * new reference.
20
+ */
16
21
  export class CableV2Service {
17
22
  http;
18
23
  constructor(http) {
19
24
  this.http = http;
20
25
  }
21
- /** POST /v2/bill/cabletv, from the parent account. */
26
+ /**
27
+ * `POST /v2/bill/cabletv`. Pays a cable TV subscription from the parent account.
28
+ * @param params The provider, smartcard/customer id and plan, and the `merchantTxRef` used for idempotency.
29
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
30
+ * a rejection or pending outcome throws.
31
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
32
+ * @throws {NombaError} The payment was rejected (4xx).
33
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
34
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
35
+ */
22
36
  async subscribeCableTv(params, options = {}) {
23
37
  return this.#pay("/v2/bill/cabletv", params, options);
24
38
  }
25
- /** POST /v2/bill/cabletv/{subAccountId}. Pays from a sub account. */
39
+ /**
40
+ * `POST /v2/bill/cabletv/{subAccountId}`. Pays from a sub account.
41
+ * @param subAccountId The sub account to pay from.
42
+ * @param params The provider, smartcard/customer id and plan, and the `merchantTxRef` used for idempotency.
43
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
44
+ * a rejection or pending outcome throws.
45
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
46
+ * @throws {NombaError} The payment was rejected (4xx).
47
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
48
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
49
+ */
26
50
  async subscribeCableTvFromSubAccount(subAccountId, params, options = {}) {
27
51
  return this.#pay(`/v2/bill/cabletv/${pathId(subAccountId)}`, params, options);
28
52
  }
29
- // merchantTxRef is the default idempotency key, as for every bill payment.
30
53
  #pay(path, params, options) {
31
- return settle(this.http, "POST", path, { body: params }, OUTCOMES, {
32
- ...options,
33
- idempotencyKey: options.idempotencyKey ?? params.merchantTxRef,
34
- });
54
+ return settle(this.http, "POST", path, { body: params }, OUTCOMES, params.merchantTxRef, options);
35
55
  }
36
56
  }
@@ -7,12 +7,36 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IDataV2Service } from "../../../interfaces/v2/data/index.js";
8
8
  import type { CallOptions } from "../../../types/common/common.types.js";
9
9
  import type { DataPurchaseParams, DataPurchaseV2Result } from "../../../types/v2/data/data.types.js";
10
+ /**
11
+ * Data bundle purchases (v2). A call that throws a NombaError with a 4xx status was rejected and did
12
+ * nothing. 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 DataV2Service implements IDataV2Service {
11
16
  #private;
12
17
  private readonly http;
13
18
  constructor(http: IHttpClient);
14
- /** POST /v2/bill/data, from the parent account. */
19
+ /**
20
+ * `POST /v2/bill/data`. Buys a data bundle from the parent account.
21
+ * @param params The phone number, network and data plan, 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
  buyData<R = DataPurchaseV2Result>(params: DataPurchaseParams, options?: CallOptions<DataPurchaseV2Result, R>): Promise<DataPurchaseV2Result | R>;
16
- /** POST /v2/bill/data/{subAccountId}. Buys a data bundle from a sub account. */
30
+ /**
31
+ * `POST /v2/bill/data/{subAccountId}`. Buys a data bundle from a sub account.
32
+ * @param subAccountId The sub account to buy from.
33
+ * @param params The phone number, network and data plan, 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
  buyDataFromSubAccount<R = DataPurchaseV2Result>(subAccountId: string, params: DataPurchaseParams, options?: CallOptions<DataPurchaseV2Result, R>): Promise<DataPurchaseV2Result | 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
+ * Data bundle purchases (v2). A call that throws a NombaError with a 4xx status was rejected and did
17
+ * nothing. 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 DataV2Service {
16
21
  http;
17
22
  constructor(http) {
18
23
  this.http = http;
19
24
  }
20
- /** POST /v2/bill/data, from the parent account. */
25
+ /**
26
+ * `POST /v2/bill/data`. Buys a data bundle from the parent account.
27
+ * @param params The phone number, network and data plan, 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 buyData(params, options = {}) {
22
36
  return this.#buy("/v2/bill/data", params, options);
23
37
  }
24
- /** POST /v2/bill/data/{subAccountId}. Buys a data bundle from a sub account. */
38
+ /**
39
+ * `POST /v2/bill/data/{subAccountId}`. Buys a data bundle from a sub account.
40
+ * @param subAccountId The sub account to buy from.
41
+ * @param params The phone number, network and data plan, 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 buyDataFromSubAccount(subAccountId, params, options = {}) {
26
50
  return this.#buy(`/v2/bill/data/${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, params.merchantTxRef, options);
34
54
  }
35
55
  }
@@ -7,13 +7,38 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IElectricityV2Service } from "../../../interfaces/v2/electricity/index.js";
8
8
  import type { CallOptions } from "../../../types/common/common.types.js";
9
9
  import type { ElectricityPaymentParams, ElectricityPaymentV2Result } from "../../../types/v2/electricity/electricity.types.js";
10
- /** v2 has purchase endpoints only. */
10
+ /**
11
+ * Electricity bill payments (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 ElectricityV2Service implements IElectricityV2Service {
12
17
  #private;
13
18
  private readonly http;
14
19
  constructor(http: IHttpClient);
15
- /** POST /v2/bill/electricity, from the parent account. Prepaid meters get the token in `meta.phcnToken`. */
20
+ /**
21
+ * `POST /v2/bill/electricity`. Pays an electricity bill from the parent account. Prepaid meters get the
22
+ * token in `meta.phcnToken`.
23
+ * @param params The disco, meter number and amount, and the `merchantTxRef` used for idempotency.
24
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
25
+ * a rejection or pending outcome throws.
26
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
27
+ * @throws {NombaError} The payment was rejected (4xx).
28
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
29
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
30
+ */
16
31
  payElectricity<R = ElectricityPaymentV2Result>(params: ElectricityPaymentParams, options?: CallOptions<ElectricityPaymentV2Result, R>): Promise<ElectricityPaymentV2Result | R>;
17
- /** POST /v2/bill/electricity/{subAccountId}. Pays from a sub account. */
32
+ /**
33
+ * `POST /v2/bill/electricity/{subAccountId}`. Pays from a sub account.
34
+ * @param subAccountId The sub account to pay from.
35
+ * @param params The disco, meter number and amount, and the `merchantTxRef` used for idempotency.
36
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
37
+ * a rejection or pending outcome throws.
38
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
39
+ * @throws {NombaError} The payment was rejected (4xx).
40
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
41
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
42
+ */
18
43
  payElectricityFromSubAccount<R = ElectricityPaymentV2Result>(subAccountId: string, params: ElectricityPaymentParams, options?: CallOptions<ElectricityPaymentV2Result, R>): Promise<ElectricityPaymentV2Result | R>;
19
44
  }
@@ -12,25 +12,46 @@ const OUTCOMES = {
12
12
  codes: { "00": "success", "200": "success", "201": "pending", ...REJECTED },
13
13
  statuses: { SUCCESS: "success", PENDING_BILLING: "pending" },
14
14
  };
15
- /** v2 has purchase endpoints only. */
15
+ /**
16
+ * Electricity bill payments (v2 has purchase endpoints only). A call that throws a NombaError with a 4xx
17
+ * status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the outcome
18
+ * unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a new
19
+ * reference.
20
+ */
16
21
  export class ElectricityV2Service {
17
22
  http;
18
23
  constructor(http) {
19
24
  this.http = http;
20
25
  }
21
- /** POST /v2/bill/electricity, from the parent account. Prepaid meters get the token in `meta.phcnToken`. */
26
+ /**
27
+ * `POST /v2/bill/electricity`. Pays an electricity bill from the parent account. Prepaid meters get the
28
+ * token in `meta.phcnToken`.
29
+ * @param params The disco, meter number and amount, and the `merchantTxRef` used for idempotency.
30
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
31
+ * a rejection or pending outcome throws.
32
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
33
+ * @throws {NombaError} The payment was rejected (4xx).
34
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
35
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
36
+ */
22
37
  async payElectricity(params, options = {}) {
23
38
  return this.#pay("/v2/bill/electricity", params, options);
24
39
  }
25
- /** POST /v2/bill/electricity/{subAccountId}. Pays from a sub account. */
40
+ /**
41
+ * `POST /v2/bill/electricity/{subAccountId}`. Pays from a sub account.
42
+ * @param subAccountId The sub account to pay from.
43
+ * @param params The disco, meter number and amount, and the `merchantTxRef` used for idempotency.
44
+ * @param options Outcome closures and per-call overrides; without them, success resolves the result and
45
+ * a rejection or pending outcome throws.
46
+ * @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
47
+ * @throws {NombaError} The payment was rejected (4xx).
48
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
49
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
50
+ */
26
51
  async payElectricityFromSubAccount(subAccountId, params, options = {}) {
27
52
  return this.#pay(`/v2/bill/electricity/${pathId(subAccountId)}`, params, options);
28
53
  }
29
- // merchantTxRef is the default idempotency key, as for every bill payment.
30
54
  #pay(path, params, options) {
31
- return settle(this.http, "POST", path, { body: params }, OUTCOMES, {
32
- ...options,
33
- idempotencyKey: options.idempotencyKey ?? params.merchantTxRef,
34
- });
55
+ return settle(this.http, "POST", path, { body: params }, OUTCOMES, params.merchantTxRef, options);
35
56
  }
36
57
  }
@@ -15,16 +15,61 @@ import type { Bank, BankAccountLookupParams, BankAccountLookupResult, BankTransf
15
15
  export declare class TransfersService implements ITransfersService {
16
16
  private readonly http;
17
17
  constructor(http: IHttpClient);
18
- /** GET /v1/transfers/banks */
18
+ /**
19
+ * `GET /v1/transfers/banks`. Lists the banks usable as a transfer destination.
20
+ * @returns The supported banks, each with its name and code.
21
+ * @throws {NombaError} A non-2xx response.
22
+ */
19
23
  listBanks(): Promise<Bank[]>;
20
- /** POST /v1/transfers/bank/lookup */
24
+ /**
25
+ * `POST /v1/transfers/bank/lookup`. Resolves a bank account number to its account name.
26
+ * @param params The bank code and account number to look up.
27
+ * @returns The resolved account name.
28
+ * @throws {NombaError} The lookup was rejected, e.g. an invalid account number.
29
+ */
21
30
  lookupBankAccount(params: BankAccountLookupParams): Promise<BankAccountLookupResult>;
22
- /** POST /v2/transfers/bank, from the parent account. */
31
+ /**
32
+ * `POST /v2/transfers/bank`. Sends a bank transfer from the parent account.
33
+ * @param params The destination bank, account number and amount; `merchantTxRef` is the idempotency key.
34
+ * @param options Outcome closures; without them, success resolves the result and pending/failure throws.
35
+ * @returns The transfer result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
36
+ * @throws {NombaError} The transfer was rejected (4xx) and never happened.
37
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
38
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
39
+ */
23
40
  bankTransfer<R = BankTransferResult>(params: BankTransferParams, options?: CallOptions<BankTransferResult, R>): Promise<BankTransferResult | R>;
24
- /** POST /v2/transfers/bank/{subAccountId}. You must ask Nomba to profile you for sub account transfers. */
41
+ /**
42
+ * `POST /v2/transfers/bank/{subAccountId}`. Sends a bank transfer from a sub account. You must ask
43
+ * Nomba to profile you for sub account transfers.
44
+ * @param subAccountId The sub account to transfer from.
45
+ * @param params The destination bank, account number and amount; `merchantTxRef` is the idempotency key.
46
+ * @param options Outcome closures; without them, success resolves the result and pending/failure throws.
47
+ * @returns The transfer result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
48
+ * @throws {NombaError} The transfer was rejected (4xx) and never happened.
49
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
50
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
51
+ */
25
52
  bankTransferFromSubAccount<R = BankTransferResult>(subAccountId: string, params: BankTransferParams, options?: CallOptions<BankTransferResult, R>): Promise<BankTransferResult | R>;
26
- /** POST /v2/transfers/wallet, from the parent account to another Nomba account. */
53
+ /**
54
+ * `POST /v2/transfers/wallet`. Sends a wallet-to-wallet transfer from the parent account to another
55
+ * Nomba account.
56
+ * @param params The destination wallet and amount; `merchantTxRef` is the idempotency key.
57
+ * @param options Outcome closures; without them, success resolves the result and pending/failure throws.
58
+ * @returns The transfer result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
59
+ * @throws {NombaError} The transfer was rejected (4xx) and never happened.
60
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
61
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
62
+ */
27
63
  walletTransfer<R = WalletTransferResult>(params: WalletTransferParams, options?: CallOptions<WalletTransferResult, R>): Promise<WalletTransferResult | R>;
28
- /** POST /v2/transfers/wallet/{subAccountId} */
64
+ /**
65
+ * `POST /v2/transfers/wallet/{subAccountId}`. Sends a wallet-to-wallet transfer from a sub account.
66
+ * @param subAccountId The sub account to transfer from.
67
+ * @param params The destination wallet and amount; `merchantTxRef` is the idempotency key.
68
+ * @param options Outcome closures; without them, success resolves the result and pending/failure throws.
69
+ * @returns The transfer result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
70
+ * @throws {NombaError} The transfer was rejected (4xx) and never happened.
71
+ * @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
72
+ * @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
73
+ */
29
74
  walletTransferFromSubAccount<R = WalletTransferResult>(subAccountId: string, params: WalletTransferParams, options?: CallOptions<WalletTransferResult, R>): Promise<WalletTransferResult | R>;
30
75
  }