@davidbolaji/termii-node
Version:
Node.js SDK for Termii API – send SMS, voice, OTP, and manage messaging with ease.
58 lines (57 loc) • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EsimService = void 0;
class EsimService {
constructor(http) {
this.http = http;
}
/**
* Authenticate with API key to get a bearer token
*/
async authenticate(payload) {
return this.http.request("/api/esim/authenticate", {
method: "POST",
data: payload,
authLocation: "body"
});
}
/**
* Fetch available data plans by country and type
*/
async fetchPlans(params) {
return this.http.request("/api/esim/data/plan/fetch", {
method: "GET",
params,
authLocation: "none"
});
}
/**
* Create (provision) a new eSIM
*/
async createEsim(payload) {
return this.http.request("/api/esim/create", {
method: "POST",
data: payload,
authLocation: "none"
});
}
/**
* Get QR code for activating an eSIM
*/
async getQrCode(iccid) {
return this.http.request(`/api/esim/activate/${iccid}/qr/code`, { method: "GET", authLocation: "none" });
}
/**
* Get usage details of an eSIM by ICCID
*/
async getUsage(iccid) {
return this.http.request(`/api/esim/subscriptions/usage/${iccid}`, { method: "GET", authLocation: "none" });
}
/**
* Fetch list of provisioned eSIMs with pagination
*/
async fetchEsims(page = 0, size = 15) {
return this.http.request(`/api/esim/fetch/esims?page=${page}&size=${size}`, { method: "GET", authLocation: "none" });
}
}
exports.EsimService = EsimService;