@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,31 +14,79 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { ICheckoutService } from "../../../interfaces/v1/checkout/ICheckoutService.js";
17
- import type { CallOptions, RequestOptions } from "../../../types/common/common.types.js";
17
+ import type { CallOptions } from "../../../types/common/common.types.js";
18
18
  import type { ChargeTokenizedCardParams, CheckoutOrderCreated, CheckoutResult, CheckoutTransaction, CreateCheckoutOrderParams, FetchCheckoutTransactionParams, ListTokenizedCardsParams, RefundCheckoutTransactionParams, TokenizedCardData, TokenizedCardList, TokenizedCardResult, UpdatedTokenizedCard, UpdateTokenizedCardParams } from "../../../types/v1/checkout/checkout.types.js";
19
19
  export declare class CheckoutService implements ICheckoutService {
20
20
  private readonly http;
21
21
  constructor(http: IHttpClient);
22
22
  /**
23
- * POST /v1/checkout/order. Send the customer to `checkoutLink` to pay.
23
+ * `POST /v1/checkout/order`. Send the customer to `checkoutLink` to pay.
24
24
  * Verified against a real sandbox call to use /v1/checkout/order, not /sandbox/checkout/order as the
25
25
  * sandbox-testing guide claims (that path 404s); sandbox and production share this path.
26
+ * @param params The order to create; `order.orderReference` is the idempotency key when provided.
27
+ * @returns The created order, including `checkoutLink`.
28
+ * @throws {NombaError} The call failed.
29
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
30
+ */
31
+ createOrder(params: CreateCheckoutOrderParams): Promise<CheckoutOrderCreated>;
32
+ /**
33
+ * `GET /v1/checkout/transaction`. Verified in sandbox; see the note on `createOrder`.
34
+ * @param params Which transaction to fetch, e.g. by `orderReference`.
35
+ * @returns The matching transaction.
36
+ * @throws {NombaError} The call failed, e.g. no transaction matches.
26
37
  */
27
- createOrder(params: CreateCheckoutOrderParams, options?: RequestOptions): Promise<CheckoutOrderCreated>;
28
- /** GET /v1/checkout/transaction. Verified in sandbox; see the note on createOrder. */
29
38
  fetchTransaction(params?: FetchCheckoutTransactionParams): Promise<CheckoutTransaction>;
30
- /** POST /v1/checkout/order/cancel. Only for orders not yet paid; use `refund` after payment. */
31
- cancelOrder(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
32
- /** POST /v1/checkout/refund. Verified in sandbox; see the note on createOrder. */
39
+ /**
40
+ * `POST /v1/checkout/order/cancel`. Only for orders not yet paid; use `refund` after payment.
41
+ * @param orderReference The order's reference (used as idempotency key).
42
+ * @throws {NombaError} The call failed, e.g. the order was already paid.
43
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
44
+ */
45
+ cancelOrder(orderReference: string): Promise<CheckoutResult>;
46
+ /**
47
+ * `POST /v1/checkout/refund`. Verified in sandbox; see the note on `createOrder`.
48
+ * @param params The transaction to refund; `transactionId` is the idempotency key.
49
+ * @param options Outcome polling/mapping and other per-call overrides.
50
+ * @returns The refund result, or the outcome `options` maps it to.
51
+ * @throws {NombaError} The call failed and is not retryable.
52
+ * @throws {UnconfirmedOutcomeError} The outcome stayed pending after polling ran out.
53
+ */
33
54
  refund<R = CheckoutResult>(params: RefundCheckoutTransactionParams, options?: CallOptions<CheckoutResult, R>): Promise<CheckoutResult | R>;
34
- /** POST /v1/checkout/tokenized-card-payment. Check `status` on the result: it says whether the charge went through. */
35
- chargeTokenizedCard(params: ChargeTokenizedCardParams, options?: RequestOptions): Promise<TokenizedCardResult>;
36
- /** GET /v1/checkout/tokenized-card-data */
55
+ /**
56
+ * `POST /v1/checkout/tokenized-card-payment`. Check `status` on the result: it says whether the charge
57
+ * went through.
58
+ * @param params The tokenized card and amount to charge; `order.orderReference` is the idempotency key when provided.
59
+ * @returns The charge result.
60
+ * @throws {NombaError} The call failed, e.g. the token is invalid or expired.
61
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
62
+ */
63
+ chargeTokenizedCard(params: ChargeTokenizedCardParams): Promise<TokenizedCardResult>;
64
+ /**
65
+ * `GET /v1/checkout/tokenized-card-data`.
66
+ * @param params Pagination (`page`) and other list filters.
67
+ * @returns One page of the customer's saved, tokenized cards.
68
+ * @throws {NombaError} The call failed.
69
+ */
37
70
  listTokenizedCards(params?: ListTokenizedCardsParams): Promise<TokenizedCardList>;
38
- /** Every tokenized card matching the filters, across all pages. Starts at `params.page` if given. */
71
+ /**
72
+ * Every tokenized card matching the filters, across all pages. Starts at `params.page` if given.
73
+ * @param params Starting page and other list filters.
74
+ * @throws {NombaError} A page request failed.
75
+ */
39
76
  iterateTokenizedCards(params?: ListTokenizedCardsParams): AsyncGenerator<TokenizedCardData>;
40
- /** POST /v1/checkout/tokenized-card-data */
41
- updateTokenizedCard(params: UpdateTokenizedCardParams, options?: RequestOptions): Promise<UpdatedTokenizedCard>;
42
- /** DELETE /v1/checkout/tokenized-card-data */
43
- deleteTokenizedCard(tokenKey: string, options?: RequestOptions): Promise<TokenizedCardResult>;
77
+ /**
78
+ * `POST /v1/checkout/tokenized-card-data`.
79
+ * @param params The tokenized card's key and the fields to update; `tokenKey` is the idempotency key.
80
+ * @returns The updated tokenized card.
81
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
82
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
83
+ */
84
+ updateTokenizedCard(params: UpdateTokenizedCardParams): Promise<UpdatedTokenizedCard>;
85
+ /**
86
+ * `DELETE /v1/checkout/tokenized-card-data`.
87
+ * @param tokenKey The tokenized card's key (used as idempotency key).
88
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
89
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
90
+ */
91
+ deleteTokenizedCard(tokenKey: string): Promise<TokenizedCardResult>;
44
92
  }
@@ -30,51 +30,86 @@ export class CheckoutService {
30
30
  this.http = http;
31
31
  }
32
32
  /**
33
- * POST /v1/checkout/order. Send the customer to `checkoutLink` to pay.
33
+ * `POST /v1/checkout/order`. Send the customer to `checkoutLink` to pay.
34
34
  * Verified against a real sandbox call to use /v1/checkout/order, not /sandbox/checkout/order as the
35
35
  * sandbox-testing guide claims (that path 404s); sandbox and production share this path.
36
+ * @param params The order to create; `order.orderReference` is the idempotency key when provided.
37
+ * @returns The created order, including `checkoutLink`.
38
+ * @throws {NombaError} The call failed.
39
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
36
40
  */
37
- createOrder(params, options = {}) {
38
- // Your own orderReference is the natural idempotency key for an order; if neither it nor an
39
- // explicit option is set, the client falls back to a generated UUID.
40
- const idempotencyKey = options.idempotencyKey ?? params.order.orderReference;
41
+ createOrder(params) {
42
+ const ref = params.order.orderReference;
41
43
  return this.http.request("POST", "/v1/checkout/order", {
42
44
  body: params,
43
- ...options,
44
- ...(idempotencyKey !== undefined && { idempotencyKey }),
45
+ ...(ref ? { idempotencyKey: ref } : {}),
45
46
  });
46
47
  }
47
- /** GET /v1/checkout/transaction. Verified in sandbox; see the note on createOrder. */
48
+ /**
49
+ * `GET /v1/checkout/transaction`. Verified in sandbox; see the note on `createOrder`.
50
+ * @param params Which transaction to fetch, e.g. by `orderReference`.
51
+ * @returns The matching transaction.
52
+ * @throws {NombaError} The call failed, e.g. no transaction matches.
53
+ */
48
54
  fetchTransaction(params = {}) {
49
55
  return this.http.request("GET", "/v1/checkout/transaction", {
50
56
  query: params,
51
57
  });
52
58
  }
53
- /** POST /v1/checkout/order/cancel. Only for orders not yet paid; use `refund` after payment. */
54
- cancelOrder(orderReference, options = {}) {
59
+ /**
60
+ * `POST /v1/checkout/order/cancel`. Only for orders not yet paid; use `refund` after payment.
61
+ * @param orderReference The order's reference (used as idempotency key).
62
+ * @throws {NombaError} The call failed, e.g. the order was already paid.
63
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
64
+ */
65
+ cancelOrder(orderReference) {
55
66
  return this.http.request("POST", "/v1/checkout/order/cancel", {
56
67
  body: { orderReference },
57
- ...options,
68
+ idempotencyKey: orderReference,
58
69
  });
59
70
  }
60
- /** POST /v1/checkout/refund. Verified in sandbox; see the note on createOrder. */
71
+ /**
72
+ * `POST /v1/checkout/refund`. Verified in sandbox; see the note on `createOrder`.
73
+ * @param params The transaction to refund; `transactionId` is the idempotency key.
74
+ * @param options Outcome polling/mapping and other per-call overrides.
75
+ * @returns The refund result, or the outcome `options` maps it to.
76
+ * @throws {NombaError} The call failed and is not retryable.
77
+ * @throws {UnconfirmedOutcomeError} The outcome stayed pending after polling ran out.
78
+ */
61
79
  async refund(params, options = {}) {
62
- return settle(this.http, "POST", "/v1/checkout/refund", { body: params }, REFUND_OUTCOMES, options);
80
+ return settle(this.http, "POST", "/v1/checkout/refund", { body: params }, REFUND_OUTCOMES, { field: "transactionId", value: params.transactionId }, options);
63
81
  }
64
- /** POST /v1/checkout/tokenized-card-payment. Check `status` on the result: it says whether the charge went through. */
65
- chargeTokenizedCard(params, options = {}) {
82
+ /**
83
+ * `POST /v1/checkout/tokenized-card-payment`. Check `status` on the result: it says whether the charge
84
+ * went through.
85
+ * @param params The tokenized card and amount to charge; `order.orderReference` is the idempotency key when provided.
86
+ * @returns The charge result.
87
+ * @throws {NombaError} The call failed, e.g. the token is invalid or expired.
88
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
89
+ */
90
+ chargeTokenizedCard(params) {
91
+ const ref = params.order?.orderReference;
66
92
  return this.http.request("POST", "/v1/checkout/tokenized-card-payment", {
67
93
  body: params,
68
- ...options,
94
+ ...(ref ? { idempotencyKey: ref } : {}),
69
95
  });
70
96
  }
71
- /** GET /v1/checkout/tokenized-card-data */
97
+ /**
98
+ * `GET /v1/checkout/tokenized-card-data`.
99
+ * @param params Pagination (`page`) and other list filters.
100
+ * @returns One page of the customer's saved, tokenized cards.
101
+ * @throws {NombaError} The call failed.
102
+ */
72
103
  listTokenizedCards(params = {}) {
73
104
  return this.http.request("GET", "/v1/checkout/tokenized-card-data", {
74
105
  query: params,
75
106
  });
76
107
  }
77
- /** Every tokenized card matching the filters, across all pages. Starts at `params.page` if given. */
108
+ /**
109
+ * Every tokenized card matching the filters, across all pages. Starts at `params.page` if given.
110
+ * @param params Starting page and other list filters.
111
+ * @throws {NombaError} A page request failed.
112
+ */
78
113
  iterateTokenizedCards(params = {}) {
79
114
  return paginate(async (cursor) => {
80
115
  const r = await this.listTokenizedCards(cursor ? { ...params, page: Number(cursor) } : params);
@@ -83,18 +118,29 @@ export class CheckoutService {
83
118
  return { results: r.tokenizedCardDataList ?? [], cursor: next };
84
119
  });
85
120
  }
86
- /** POST /v1/checkout/tokenized-card-data */
87
- updateTokenizedCard(params, options = {}) {
121
+ /**
122
+ * `POST /v1/checkout/tokenized-card-data`.
123
+ * @param params The tokenized card's key and the fields to update; `tokenKey` is the idempotency key.
124
+ * @returns The updated tokenized card.
125
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
126
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
127
+ */
128
+ updateTokenizedCard(params) {
88
129
  return this.http.request("POST", "/v1/checkout/tokenized-card-data", {
89
130
  body: params,
90
- ...options,
131
+ idempotencyKey: params.tokenKey,
91
132
  });
92
133
  }
93
- /** DELETE /v1/checkout/tokenized-card-data */
94
- deleteTokenizedCard(tokenKey, options = {}) {
134
+ /**
135
+ * `DELETE /v1/checkout/tokenized-card-data`.
136
+ * @param tokenKey The tokenized card's key (used as idempotency key).
137
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
138
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
139
+ */
140
+ deleteTokenizedCard(tokenKey) {
95
141
  return this.http.request("DELETE", "/v1/checkout/tokenized-card-data", {
96
142
  body: { tokenKey },
97
- ...options,
143
+ idempotencyKey: tokenKey,
98
144
  });
99
145
  }
100
146
  }
@@ -6,9 +6,15 @@
6
6
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IDataService } from "../../../interfaces/v1/data/index.js";
8
8
  import type { DataPlansResult } from "../../../types/v1/data/data.types.js";
9
+ /** Data bundle plans (v1): lookup only, no purchase endpoint. */
9
10
  export declare class DataService implements IDataService {
10
11
  private readonly http;
11
12
  constructor(http: IHttpClient);
12
- /** GET /v1/bill/data-plan/{telco} */
13
+ /**
14
+ * `GET /v1/bill/data-plan/{telco}`.
15
+ * @param telco The telco network to list data plans for.
16
+ * @returns The available data plans for that telco.
17
+ * @throws {NombaError} `telco` is not a recognized network, or the request failed.
18
+ */
13
19
  getDataPlans(telco: string): Promise<DataPlansResult>;
14
20
  }
@@ -4,12 +4,18 @@
4
4
  * @see https://developer.nomba.com/docs/api-reference/bills
5
5
  */
6
6
  import { pathId } from "../../../lib/util.js";
7
+ /** Data bundle plans (v1): lookup only, no purchase endpoint. */
7
8
  export class DataService {
8
9
  http;
9
10
  constructor(http) {
10
11
  this.http = http;
11
12
  }
12
- /** GET /v1/bill/data-plan/{telco} */
13
+ /**
14
+ * `GET /v1/bill/data-plan/{telco}`.
15
+ * @param telco The telco network to list data plans for.
16
+ * @returns The available data plans for that telco.
17
+ * @throws {NombaError} `telco` is not a recognized network, or the request failed.
18
+ */
13
19
  getDataPlans(telco) {
14
20
  return this.http.request("GET", `/v1/bill/data-plan/${pathId(telco)}`);
15
21
  }
@@ -14,32 +14,56 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { IDirectDebitsService } from "../../../interfaces/v1/direct-debits/IDirectDebitsService.js";
17
- import type { RequestOptions } from "../../../types/common/common.types.js";
18
17
  import type { CreatedMandate, CreateMandateParams, DebitMandateParams, ListMandatesParams, MandateDebitResult, MandatePage, MandateStatus, UpdatedMandateStatus, UpdateMandateStatusParams } from "../../../types/v1/direct-debits/direct-debits.types.js";
18
+ /** Direct debit mandates (v1): create, inspect, debit, and update recurring mandates. */
19
19
  export declare class DirectDebitsService implements IDirectDebitsService {
20
20
  private readonly http;
21
21
  constructor(http: IHttpClient);
22
22
  /**
23
- * POST /v1/direct-debits.
23
+ * `POST /v1/direct-debits`.
24
24
  * ponytail: this endpoint's response envelope is `{ responseCode, responseMessage, data }`, unlike every
25
25
  * other endpoint's `{ code, description, data }` — confirmed from the spec's own example, not guessed.
26
+ * @param params The mandate to create; `merchantReference` is the idempotency key.
27
+ * @returns The created mandate.
28
+ * @throws {NombaError} The mandate params were rejected.
29
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
30
+ * check the mandate status before retrying.
31
+ */
32
+ createMandate(params: CreateMandateParams): Promise<CreatedMandate>;
33
+ /**
34
+ * `GET /v1/direct-debits/status?mandateId={mandateId}`.
35
+ * @param mandateId The mandate to look up.
36
+ * @returns The mandate's current status.
37
+ * @throws {NombaError} `mandateId` is not found, or the request failed.
26
38
  */
27
- createMandate(params: CreateMandateParams, options?: RequestOptions): Promise<CreatedMandate>;
28
- /** GET /v1/direct-debits/status?mandateId={mandateId} */
29
39
  getMandateStatus(mandateId: string): Promise<MandateStatus>;
30
40
  /**
31
- * POST /v1/direct-debits/debit-mandate. Unlike createMandate, there is no per-transaction reference
32
- * field to default the idempotency key to (mandateId is stable across every debit on that mandate, so
33
- * defaulting to it would give every recurring debit the same key). Pass your own idempotencyKey if you
34
- * need retries deduplicated; otherwise the client generates a fresh one per call.
41
+ * `POST /v1/direct-debits/debit-mandate`. No per-transaction reference field exists in params, so a
42
+ * random idempotency key is generated for error tracking. If the outcome is unknown, requery the mandate
43
+ * before retrying.
44
+ * @param params The mandate to debit and the amount.
45
+ * @returns The debit result.
46
+ * @throws {NombaError} The mandate is not active, or the debit was rejected.
47
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
48
+ * check the mandate status before retrying.
49
+ */
50
+ debitMandate(params: DebitMandateParams): Promise<MandateDebitResult>;
51
+ /**
52
+ * `GET /v1/direct-debits/mandates`.
53
+ * @param params Pagination and filter params.
54
+ * @returns A page of mandates.
55
+ * @throws {NombaError} The request failed.
35
56
  */
36
- debitMandate(params: DebitMandateParams, options?: RequestOptions): Promise<MandateDebitResult>;
37
- /** GET /v1/direct-debits/mandates */
38
57
  listMandates(params: ListMandatesParams): Promise<MandatePage>;
39
58
  /**
40
- * PUT /v1/direct-debits/update-status. Same reasoning as debitMandate: mandateId is stable across every
41
- * status change on that mandate (SUSPEND, then ACTIVE, then SUSPEND again), so it is not a safe default
42
- * idempotency key. Pass your own if you need a retry deduplicated.
59
+ * `PUT /v1/direct-debits/update-status`. No per-change reference field exists in params, so a random
60
+ * idempotency key is generated for error tracking. If the outcome is unknown, check the mandate status
61
+ * before retrying.
62
+ * @param params The mandate and the new status.
63
+ * @returns The mandate's updated status.
64
+ * @throws {NombaError} The status transition is invalid, or the request failed.
65
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
66
+ * check the mandate status before retrying.
43
67
  */
44
- updateMandateStatus(params: UpdateMandateStatusParams, options?: RequestOptions): Promise<UpdatedMandateStatus>;
68
+ updateMandateStatus(params: UpdateMandateStatusParams): Promise<UpdatedMandateStatus>;
45
69
  }
@@ -12,58 +12,80 @@
12
12
  * @docs https://developer.nomba.com
13
13
  * @see https://developer.nomba.com/docs/api-reference/direct-debits
14
14
  */
15
+ /** Direct debit mandates (v1): create, inspect, debit, and update recurring mandates. */
15
16
  export class DirectDebitsService {
16
17
  http;
17
18
  constructor(http) {
18
19
  this.http = http;
19
20
  }
20
21
  /**
21
- * POST /v1/direct-debits.
22
+ * `POST /v1/direct-debits`.
22
23
  * ponytail: this endpoint's response envelope is `{ responseCode, responseMessage, data }`, unlike every
23
24
  * other endpoint's `{ code, description, data }` — confirmed from the spec's own example, not guessed.
25
+ * @param params The mandate to create; `merchantReference` is the idempotency key.
26
+ * @returns The created mandate.
27
+ * @throws {NombaError} The mandate params were rejected.
28
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
29
+ * check the mandate status before retrying.
24
30
  */
25
- createMandate(params, options = {}) {
31
+ createMandate(params) {
26
32
  return this.http.request("POST", "/v1/direct-debits", {
27
33
  body: params,
28
34
  codeField: "responseCode",
29
35
  descriptionField: "responseMessage",
30
- ...options,
31
- idempotencyKey: options.idempotencyKey ?? params.merchantReference,
36
+ idempotencyKey: params.merchantReference,
32
37
  });
33
38
  }
34
- /** GET /v1/direct-debits/status?mandateId={mandateId} */
39
+ /**
40
+ * `GET /v1/direct-debits/status?mandateId={mandateId}`.
41
+ * @param mandateId The mandate to look up.
42
+ * @returns The mandate's current status.
43
+ * @throws {NombaError} `mandateId` is not found, or the request failed.
44
+ */
35
45
  getMandateStatus(mandateId) {
36
46
  return this.http.request("GET", "/v1/direct-debits/status", {
37
47
  query: { mandateId },
38
48
  });
39
49
  }
40
50
  /**
41
- * POST /v1/direct-debits/debit-mandate. Unlike createMandate, there is no per-transaction reference
42
- * field to default the idempotency key to (mandateId is stable across every debit on that mandate, so
43
- * defaulting to it would give every recurring debit the same key). Pass your own idempotencyKey if you
44
- * need retries deduplicated; otherwise the client generates a fresh one per call.
51
+ * `POST /v1/direct-debits/debit-mandate`. No per-transaction reference field exists in params, so a
52
+ * random idempotency key is generated for error tracking. If the outcome is unknown, requery the mandate
53
+ * before retrying.
54
+ * @param params The mandate to debit and the amount.
55
+ * @returns The debit result.
56
+ * @throws {NombaError} The mandate is not active, or the debit was rejected.
57
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
58
+ * check the mandate status before retrying.
45
59
  */
46
- debitMandate(params, options = {}) {
60
+ debitMandate(params) {
47
61
  return this.http.request("POST", "/v1/direct-debits/debit-mandate", {
48
62
  body: params,
49
- ...options,
50
63
  });
51
64
  }
52
- /** GET /v1/direct-debits/mandates */
65
+ /**
66
+ * `GET /v1/direct-debits/mandates`.
67
+ * @param params Pagination and filter params.
68
+ * @returns A page of mandates.
69
+ * @throws {NombaError} The request failed.
70
+ */
53
71
  listMandates(params) {
54
72
  return this.http.request("GET", "/v1/direct-debits/mandates", {
55
73
  query: params,
56
74
  });
57
75
  }
58
76
  /**
59
- * PUT /v1/direct-debits/update-status. Same reasoning as debitMandate: mandateId is stable across every
60
- * status change on that mandate (SUSPEND, then ACTIVE, then SUSPEND again), so it is not a safe default
61
- * idempotency key. Pass your own if you need a retry deduplicated.
77
+ * `PUT /v1/direct-debits/update-status`. No per-change reference field exists in params, so a random
78
+ * idempotency key is generated for error tracking. If the outcome is unknown, check the mandate status
79
+ * before retrying.
80
+ * @param params The mandate and the new status.
81
+ * @returns The mandate's updated status.
82
+ * @throws {NombaError} The status transition is invalid, or the request failed.
83
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
84
+ * check the mandate status before retrying.
62
85
  */
63
- updateMandateStatus(params, options = {}) {
86
+ updateMandateStatus(params) {
64
87
  return this.http.request("PUT", "/v1/direct-debits/update-status", {
65
88
  body: params,
66
- ...options,
67
89
  });
68
90
  }
69
91
  }
@@ -6,11 +6,21 @@
6
6
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
7
7
  import type { IElectricityService } from "../../../interfaces/v1/electricity/index.js";
8
8
  import type { ElectricityProvidersResult, MeterLookupParams, MeterLookupResult } from "../../../types/v1/electricity/electricity.types.js";
9
+ /** Electricity bill lookup (v1): disco listing and meter lookup, no payment endpoint. */
9
10
  export declare class ElectricityService implements IElectricityService {
10
11
  private readonly http;
11
12
  constructor(http: IHttpClient);
12
- /** GET /v1/bill/electricity/discos */
13
+ /**
14
+ * `GET /v1/bill/electricity/discos`.
15
+ * @returns The electricity distribution companies (discos) available for meter lookup.
16
+ * @throws {NombaError} The request failed.
17
+ */
13
18
  getElectricityProviders(): Promise<ElectricityProvidersResult>;
14
- /** GET /v1/bill/electricity/lookup */
19
+ /**
20
+ * `GET /v1/bill/electricity/lookup`.
21
+ * @param params The disco and meter number to look up.
22
+ * @returns The meter's customer details.
23
+ * @throws {NombaError} The meter number is invalid or not found, or the request failed.
24
+ */
15
25
  lookupMeter(params: MeterLookupParams): Promise<MeterLookupResult>;
16
26
  }
@@ -3,16 +3,26 @@
3
3
  * @description Electricity (v1): GET /v1/bill/electricity/discos, GET /v1/bill/electricity/lookup
4
4
  * @see https://developer.nomba.com/docs/api-reference/bills
5
5
  */
6
+ /** Electricity bill lookup (v1): disco listing and meter lookup, no payment endpoint. */
6
7
  export class ElectricityService {
7
8
  http;
8
9
  constructor(http) {
9
10
  this.http = http;
10
11
  }
11
- /** GET /v1/bill/electricity/discos */
12
+ /**
13
+ * `GET /v1/bill/electricity/discos`.
14
+ * @returns The electricity distribution companies (discos) available for meter lookup.
15
+ * @throws {NombaError} The request failed.
16
+ */
12
17
  getElectricityProviders() {
13
18
  return this.http.request("GET", "/v1/bill/electricity/discos");
14
19
  }
15
- /** GET /v1/bill/electricity/lookup */
20
+ /**
21
+ * `GET /v1/bill/electricity/lookup`.
22
+ * @param params The disco and meter number to look up.
23
+ * @returns The meter's customer details.
24
+ * @throws {NombaError} The meter number is invalid or not found, or the request failed.
25
+ */
16
26
  lookupMeter(params) {
17
27
  return this.http.request("GET", "/v1/bill/electricity/lookup", {
18
28
  query: params,
@@ -14,15 +14,33 @@
14
14
  */
15
15
  import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
16
16
  import type { IGlobalCollectionsService } from "../../../interfaces/v1/globals/collections/IGlobalCollectionsService.js";
17
- import type { RequestOptions } from "../../../types/common/common.types.js";
18
17
  import type { CollectionTransaction, InflowProvider, InflowResult, InitiateInflowParams } from "../../../types/v1/globals/collections.types.js";
18
+ /** Global Collections (v1): DRC mobile money inflows. */
19
19
  export declare class GlobalCollectionsService implements IGlobalCollectionsService {
20
20
  private readonly http;
21
21
  constructor(http: IHttpClient);
22
- /** GET /v1/global-collection/drc/inflow/providers */
22
+ /**
23
+ * `GET /v1/global-collection/drc/inflow/providers`.
24
+ * @returns The mobile money providers available for DRC inflows.
25
+ * @throws {NombaError} The request failed.
26
+ */
23
27
  inflowProviders(): Promise<InflowProvider[]>;
24
- /** POST /v1/global-collection/inflow/initiate. Prompts the customer to approve the charge on their phone. */
25
- initiateInflow(params: InitiateInflowParams, options?: RequestOptions): Promise<InflowResult>;
26
- /** GET /v1/global-collection/transactions/{transactionId}, with the `transactionReference` from `initiateInflow`. */
28
+ /**
29
+ * `POST /v1/global-collection/inflow/initiate`. Prompts the customer to approve the charge on their phone.
30
+ * @param params The inflow to initiate. Must include `idempotencyKey` — the SDK never generates
31
+ * one for you to prevent double collection.
32
+ * @returns The initiated inflow, including its `transactionReference`.
33
+ * @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
34
+ * @throws {NombaError} The inflow params were rejected.
35
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
36
+ * check the transaction status before retrying.
37
+ */
38
+ initiateInflow(params: InitiateInflowParams): Promise<InflowResult>;
39
+ /**
40
+ * `GET /v1/global-collection/transactions/{transactionId}`, with the `transactionReference` from `initiateInflow`.
41
+ * @param transactionId The transaction reference to look up.
42
+ * @returns The transaction's current state.
43
+ * @throws {NombaError} `transactionId` is not found, or the request failed.
44
+ */
27
45
  getTransaction(transactionId: string): Promise<CollectionTransaction>;
28
46
  }
@@ -12,26 +12,48 @@
12
12
  * @docs https://developer.nomba.com
13
13
  * @see https://developer.nomba.com/docs/products/global-collections/introduction
14
14
  */
15
- import { randomUUID } from "node:crypto";
15
+ import { IdempotencyKeyAbsentError } from "../../../lib/errors.js";
16
16
  import { pathId } from "../../../lib/util.js";
17
+ /** Global Collections (v1): DRC mobile money inflows. */
17
18
  export class GlobalCollectionsService {
18
19
  http;
19
20
  constructor(http) {
20
21
  this.http = http;
21
22
  }
22
- /** GET /v1/global-collection/drc/inflow/providers */
23
+ /**
24
+ * `GET /v1/global-collection/drc/inflow/providers`.
25
+ * @returns The mobile money providers available for DRC inflows.
26
+ * @throws {NombaError} The request failed.
27
+ */
23
28
  inflowProviders() {
24
29
  return this.http.request("GET", "/v1/global-collection/drc/inflow/providers");
25
30
  }
26
- /** POST /v1/global-collection/inflow/initiate. Prompts the customer to approve the charge on their phone. */
27
- initiateInflow(params, options = {}) {
28
- const idempotencyKey = params.idempotencyKey || options.idempotencyKey || randomUUID();
31
+ /**
32
+ * `POST /v1/global-collection/inflow/initiate`. Prompts the customer to approve the charge on their phone.
33
+ * @param params The inflow to initiate. Must include `idempotencyKey` — the SDK never generates
34
+ * one for you to prevent double collection.
35
+ * @returns The initiated inflow, including its `transactionReference`.
36
+ * @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
37
+ * @throws {NombaError} The inflow params were rejected.
38
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
39
+ * check the transaction status before retrying.
40
+ */
41
+ async initiateInflow(params) {
42
+ const { idempotencyKey } = params;
43
+ if (!idempotencyKey?.trim()) {
44
+ throw new IdempotencyKeyAbsentError("idempotencyKey", "/v1/global-collection/inflow/initiate");
45
+ }
29
46
  return this.http.request("POST", "/v1/global-collection/inflow/initiate", {
30
- body: { ...params, idempotencyKey },
47
+ body: params,
31
48
  idempotencyKey,
32
49
  });
33
50
  }
34
- /** GET /v1/global-collection/transactions/{transactionId}, with the `transactionReference` from `initiateInflow`. */
51
+ /**
52
+ * `GET /v1/global-collection/transactions/{transactionId}`, with the `transactionReference` from `initiateInflow`.
53
+ * @param transactionId The transaction reference to look up.
54
+ * @returns The transaction's current state.
55
+ * @throws {NombaError} `transactionId` is not found, or the request failed.
56
+ */
35
57
  async getTransaction(transactionId) {
36
58
  return this.http.request("GET", `/v1/global-collection/transactions/${pathId(transactionId)}`);
37
59
  }