@nomba/node-sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/interfaces/v1/electricity/IElectricityService.d.ts +1 -8
- package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +9 -2
- package/dist/interfaces/v2/electricity/IElectricityV2Service.js +1 -1
- package/dist/lib/sdk-version.generated.d.ts +1 -1
- package/dist/lib/sdk-version.generated.js +1 -1
- package/dist/services/http/http-client.service.js +1 -0
- package/dist/services/v1/electricity/electricity.service.d.ts +3 -10
- package/dist/services/v1/electricity/electricity.service.js +2 -13
- package/dist/services/v2/electricity/electricity.service.d.ts +10 -3
- package/dist/services/v2/electricity/electricity.service.js +13 -2
- package/dist/types/v1/electricity/electricity.types.d.ts +0 -9
- package/dist/types/v2/electricity/electricity.types.d.ts +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -231,8 +231,7 @@ Provider lists, meter/customer lookups and data plans — no money moves here. P
|
|
|
231
231
|
|
|
232
232
|
| Method | Endpoint | Notes |
|
|
233
233
|
|---|---|---|
|
|
234
|
-
| `getElectricityProviders()` | `GET /v1/bill/electricity/discos` | |
|
|
235
|
-
| `lookupMeter(params)` | `GET /v1/bill/electricity/lookup` | |
|
|
234
|
+
| `getElectricityProviders()` | `GET /v1/bill/electricity/discos` | Meter lookup moved to `nomba.electricity.lookupMeter` (v2) |
|
|
236
235
|
|
|
237
236
|
#### Cable TV: `nomba.billCable` (`CableService`)
|
|
238
237
|
|
|
@@ -256,12 +255,13 @@ Provider lists, meter/customer lookups and data plans — no money moves here. P
|
|
|
256
255
|
|
|
257
256
|
### Electricity, cable TV and betting
|
|
258
257
|
|
|
259
|
-
Each is its own product using **version 2** endpoints (
|
|
258
|
+
Each is its own product using **version 2** endpoints. Electricity also has a meter lookup; cable and betting lookups stay on version 1 (above).
|
|
260
259
|
|
|
261
260
|
#### Electricity: `nomba.electricity` (`ElectricityV2Service`)
|
|
262
261
|
|
|
263
262
|
| Method | Endpoint | Notes |
|
|
264
263
|
|---|---|---|
|
|
264
|
+
| `lookupMeter(params)` | `GET /v2/bill/electricity/lookup` | `address` is `"unknown"` if the provider supplies none |
|
|
265
265
|
| `payElectricity(params)` | `POST /v2/bill/electricity` | Prepaid meters get the token in `meta.phcnToken` |
|
|
266
266
|
| `payElectricityFromSubAccount(subAccountId, params)` | `POST /v2/bill/electricity/{subAccountId}` | |
|
|
267
267
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module nomba/interfaces/v1/electricity
|
|
3
3
|
* @description Electricity v1 service contract for validation endpoints
|
|
4
4
|
*/
|
|
5
|
-
import type { ElectricityProvidersResult
|
|
5
|
+
import type { ElectricityProvidersResult } from "../../../types/v1/electricity/electricity.types.js";
|
|
6
6
|
export interface IElectricityService {
|
|
7
7
|
/**
|
|
8
8
|
* `GET /v1/bill/electricity/discos`.
|
|
@@ -10,11 +10,4 @@ export interface IElectricityService {
|
|
|
10
10
|
* @throws {NombaError} The request failed.
|
|
11
11
|
*/
|
|
12
12
|
getElectricityProviders(): Promise<ElectricityProvidersResult>;
|
|
13
|
-
/**
|
|
14
|
-
* `GET /v1/bill/electricity/lookup`.
|
|
15
|
-
* @param params The disco and meter number to look up.
|
|
16
|
-
* @returns The meter's customer details.
|
|
17
|
-
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
18
|
-
*/
|
|
19
|
-
lookupMeter(params: MeterLookupParams): Promise<MeterLookupResult>;
|
|
20
13
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module nomba/interfaces/v2/electricity
|
|
3
|
-
* @description Electricity v2 service contract.
|
|
3
|
+
* @description Electricity v2 service contract.
|
|
4
4
|
*/
|
|
5
5
|
import type { CallOptions } from "../../../types/common/common.types.js";
|
|
6
|
-
import type { ElectricityPaymentParams, ElectricityPaymentV2Result } from "../../../types/v2/electricity/electricity.types.js";
|
|
6
|
+
import type { ElectricityPaymentParams, ElectricityPaymentV2Result, MeterLookupV2Params, MeterLookupV2Result } from "../../../types/v2/electricity/electricity.types.js";
|
|
7
7
|
export interface IElectricityV2Service {
|
|
8
|
+
/**
|
|
9
|
+
* `GET /v2/bill/electricity/lookup`.
|
|
10
|
+
* @param params The disco and meter/customer id to look up.
|
|
11
|
+
* @returns The customer's name and address.
|
|
12
|
+
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
13
|
+
*/
|
|
14
|
+
lookupMeter(params: MeterLookupV2Params): Promise<MeterLookupV2Result>;
|
|
8
15
|
/**
|
|
9
16
|
* `POST /v2/bill/electricity`. Pays an electricity bill from the parent account. Prepaid meters get the
|
|
10
17
|
* token in `meta.phcnToken`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.5.0";
|
|
@@ -288,6 +288,7 @@ export class HttpClient {
|
|
|
288
288
|
headers: {
|
|
289
289
|
accountId: this.#options.accountId,
|
|
290
290
|
"X-Nomba-Sdk-Version": SDK_VERSION,
|
|
291
|
+
"User-Agent": `nomba_node_sdk:v${SDK_VERSION}`,
|
|
291
292
|
...(payload === undefined
|
|
292
293
|
? {}
|
|
293
294
|
: { "Content-Type": "application/json" }),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module nomba/services/v1/electricity
|
|
3
|
-
* @description Electricity (v1): GET /v1/bill/electricity/discos
|
|
3
|
+
* @description Electricity (v1): GET /v1/bill/electricity/discos
|
|
4
4
|
* @see https://developer.nomba.com/docs/api-reference/bills
|
|
5
5
|
*/
|
|
6
6
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
7
7
|
import type { IElectricityService } from "../../../interfaces/v1/electricity/index.js";
|
|
8
|
-
import type { ElectricityProvidersResult
|
|
9
|
-
/** Electricity bill
|
|
8
|
+
import type { ElectricityProvidersResult } from "../../../types/v1/electricity/electricity.types.js";
|
|
9
|
+
/** Electricity bill disco listing (v1). Meter lookup moved to v2, see ElectricityV2Service. */
|
|
10
10
|
export declare class ElectricityService implements IElectricityService {
|
|
11
11
|
private readonly http;
|
|
12
12
|
constructor(http: IHttpClient);
|
|
@@ -16,11 +16,4 @@ export declare class ElectricityService implements IElectricityService {
|
|
|
16
16
|
* @throws {NombaError} The request failed.
|
|
17
17
|
*/
|
|
18
18
|
getElectricityProviders(): Promise<ElectricityProvidersResult>;
|
|
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
|
-
*/
|
|
25
|
-
lookupMeter(params: MeterLookupParams): Promise<MeterLookupResult>;
|
|
26
19
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module nomba/services/v1/electricity
|
|
3
|
-
* @description Electricity (v1): GET /v1/bill/electricity/discos
|
|
3
|
+
* @description Electricity (v1): GET /v1/bill/electricity/discos
|
|
4
4
|
* @see https://developer.nomba.com/docs/api-reference/bills
|
|
5
5
|
*/
|
|
6
|
-
/** Electricity bill
|
|
6
|
+
/** Electricity bill disco listing (v1). Meter lookup moved to v2, see ElectricityV2Service. */
|
|
7
7
|
export class ElectricityService {
|
|
8
8
|
http;
|
|
9
9
|
constructor(http) {
|
|
@@ -17,15 +17,4 @@ export class ElectricityService {
|
|
|
17
17
|
getElectricityProviders() {
|
|
18
18
|
return this.http.request("GET", "/v1/bill/electricity/discos");
|
|
19
19
|
}
|
|
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
|
-
*/
|
|
26
|
-
lookupMeter(params) {
|
|
27
|
-
return this.http.request("GET", "/v1/bill/electricity/lookup", {
|
|
28
|
-
query: params,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
20
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module nomba/services/v2/electricity
|
|
3
|
-
* @description ElectricityV2 (v2): POST /v2/bill/electricity[/{subAccountId}]
|
|
3
|
+
* @description ElectricityV2 (v2): GET /v2/bill/electricity/lookup, POST /v2/bill/electricity[/{subAccountId}]
|
|
4
4
|
* @see https://developer.nomba.com/docs/api-reference/bills
|
|
5
5
|
*/
|
|
6
6
|
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
|
-
import type { ElectricityPaymentParams, ElectricityPaymentV2Result } from "../../../types/v2/electricity/electricity.types.js";
|
|
9
|
+
import type { ElectricityPaymentParams, ElectricityPaymentV2Result, MeterLookupV2Params, MeterLookupV2Result } from "../../../types/v2/electricity/electricity.types.js";
|
|
10
10
|
/**
|
|
11
|
-
* Electricity
|
|
11
|
+
* Electricity meter lookup and bill payments. A call that throws a NombaError with a 4xx
|
|
12
12
|
* status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the outcome
|
|
13
13
|
* unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a new
|
|
14
14
|
* reference.
|
|
@@ -17,6 +17,13 @@ export declare class ElectricityV2Service implements IElectricityV2Service {
|
|
|
17
17
|
#private;
|
|
18
18
|
private readonly http;
|
|
19
19
|
constructor(http: IHttpClient);
|
|
20
|
+
/**
|
|
21
|
+
* `GET /v2/bill/electricity/lookup`.
|
|
22
|
+
* @param params The disco and meter/customer id to look up.
|
|
23
|
+
* @returns The customer's name and address.
|
|
24
|
+
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
25
|
+
*/
|
|
26
|
+
lookupMeter(params: MeterLookupV2Params): Promise<MeterLookupV2Result>;
|
|
20
27
|
/**
|
|
21
28
|
* `POST /v2/bill/electricity`. Pays an electricity bill from the parent account. Prepaid meters get the
|
|
22
29
|
* token in `meta.phcnToken`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module nomba/services/v2/electricity
|
|
3
|
-
* @description ElectricityV2 (v2): POST /v2/bill/electricity[/{subAccountId}]
|
|
3
|
+
* @description ElectricityV2 (v2): GET /v2/bill/electricity/lookup, POST /v2/bill/electricity[/{subAccountId}]
|
|
4
4
|
* @see https://developer.nomba.com/docs/api-reference/bills
|
|
5
5
|
*/
|
|
6
6
|
import { REJECTED, settle } from "../../../lib/outcome.js";
|
|
@@ -13,7 +13,7 @@ const OUTCOMES = {
|
|
|
13
13
|
statuses: { SUCCESS: "success", PENDING_BILLING: "pending" },
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* Electricity
|
|
16
|
+
* Electricity meter lookup and bill payments. A call that throws a NombaError with a 4xx
|
|
17
17
|
* status was rejected and did nothing. Any other failure (5xx, network error, timeout) leaves the outcome
|
|
18
18
|
* unknown: keep the same `merchantTxRef`, wait for the webhook or requery, and never retry under a new
|
|
19
19
|
* reference.
|
|
@@ -23,6 +23,17 @@ export class ElectricityV2Service {
|
|
|
23
23
|
constructor(http) {
|
|
24
24
|
this.http = http;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* `GET /v2/bill/electricity/lookup`.
|
|
28
|
+
* @param params The disco and meter/customer id to look up.
|
|
29
|
+
* @returns The customer's name and address.
|
|
30
|
+
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
31
|
+
*/
|
|
32
|
+
lookupMeter(params) {
|
|
33
|
+
return this.http.request("GET", "/v2/bill/electricity/lookup", {
|
|
34
|
+
query: params,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
26
37
|
/**
|
|
27
38
|
* `POST /v2/bill/electricity`. Pays an electricity bill from the parent account. Prepaid meters get the
|
|
28
39
|
* token in `meta.phcnToken`.
|
|
@@ -10,12 +10,3 @@ export type ElectricityProvidersResult = {
|
|
|
10
10
|
code: string;
|
|
11
11
|
data: ElectricityProvider[];
|
|
12
12
|
};
|
|
13
|
-
export type MeterLookupParams = {
|
|
14
|
-
disco: string;
|
|
15
|
-
customerId: string;
|
|
16
|
-
};
|
|
17
|
-
export type MeterLookupResult = {
|
|
18
|
-
code: string;
|
|
19
|
-
/** Customer name associated with the meter */
|
|
20
|
-
data: string;
|
|
21
|
-
};
|
|
@@ -13,6 +13,15 @@ export type ElectricityPaymentParams = {
|
|
|
13
13
|
/** Usually PREPAID or POSTPAID. */
|
|
14
14
|
meterType: string;
|
|
15
15
|
};
|
|
16
|
+
export type MeterLookupV2Params = {
|
|
17
|
+
disco: string;
|
|
18
|
+
customerId: string;
|
|
19
|
+
};
|
|
20
|
+
export type MeterLookupV2Result = {
|
|
21
|
+
name: string;
|
|
22
|
+
/** `"unknown"` if the provider supplies no address. */
|
|
23
|
+
address: string;
|
|
24
|
+
};
|
|
16
25
|
export type ElectricityPaymentV2Result = {
|
|
17
26
|
/** Pass to requery to confirm the final status. */
|
|
18
27
|
id: string;
|