Files
sf-sim/test_api.ts

37 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2026-04-27 11:05:09 +02:00
import { NosHttpClient } from "./packages/sim-consumidor-nos/infrastructure/NosHttpClient.js";
import { env } from "./packages/sim-consumidor-nos/config/env/env.js";
async function main() {
console.log("NOS_BASE_URL", env.NOS_BASE_URL);
const client = new NosHttpClient(env.NOS_BASE_URL);
2026-05-11 15:52:40 +02:00
2026-04-27 11:05:09 +02:00
// Try to get a subscriber
const res = await client.get("/subscribers", { params: { limit: 1 } });
console.log("SUBSCRIBER:", res.data.content[0].physicalId);
2026-05-11 15:52:40 +02:00
2026-04-27 11:05:09 +02:00
const iccid = res.data.content[0].physicalId;
2026-05-11 15:52:40 +02:00
2026-04-27 11:05:09 +02:00
try {
const history = await client.get(`/subscribers/${iccid}/history`);
console.log("HISTORY:", history.data);
2026-05-11 15:52:40 +02:00
} catch (e) {
2026-04-27 11:05:09 +02:00
console.error("HISTORY ERROR");
}
try {
const audit = await client.get(`/subscribers/${iccid}/audit`);
console.log("AUDIT:", audit.data);
2026-05-11 15:52:40 +02:00
} catch (e) {
2026-04-27 11:05:09 +02:00
console.error("AUDIT ERROR");
}
try {
const actions = await client.get(`/subscribers/${iccid}/actions`);
console.log("ACTIONS:", actions.data);
2026-05-11 15:52:40 +02:00
} catch (e) {
2026-04-27 11:05:09 +02:00
console.error("ACTIONS ERROR");
}
}
main().catch(console.error);