@davidbolaji/termii-node
Version:
Node.js SDK for Termii API – send SMS, voice, OTP, and manage messaging with ease.
58 lines (57 loc) • 1.99 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenService = void 0;
const EmailTokenService_1 = require("./EmailTokenService");
const InAppTokenService_1 = require("./InAppTokenService");
const VerifyTokenService_1 = require("./VerifyTokenService");
/**
* Service for sending and verifying OTP tokens (SMS, WhatsApp, or Voice)
*/
class TokenService {
constructor(http) {
this.http = http;
this.email = new EmailTokenService_1.EmailTokenService(this.http);
this.verify = new VerifyTokenService_1.VerifyTokenService(this.http);
this.inApp = new InAppTokenService_1.InAppTokenService(this.http);
}
/**
* Send a one-time password (OTP) token via SMS, WhatsApp, or Email
*
* @param payload - Request payload with OTP configuration and message
* @returns Expanded `SendTokenResponse` containing PIN details
*/
async sendToken(payload) {
return this.http.request("/sms/otp/send", {
method: "POST",
data: payload,
authLocation: "body"
});
}
/**
* Send a one-time password (OTP) token via Voice call
*
* @param payload - Request payload with phone number and OTP parameters
* @returns Expanded `VoiceTokenResponse` with OTP call details
*/
async sendVoiceToken(payload) {
return this.http.request("/sms/otp/send/voice", {
method: "POST",
data: payload,
authLocation: "body"
});
}
/**
* Initiate a direct voice call delivering a numeric code
*
* @param payload - Request containing phone number and numeric code
* @returns Expanded `VoiceCallResponse` with call status
*/
async sendVoiceCall(payload) {
return this.http.request("/sms/otp/send/call", {
method: "POST",
data: payload,
authLocation: "body"
});
}
}
exports.TokenService = TokenService;