UNPKG

@davidbolaji/termii-node

Version:

Node.js SDK for Termii API – send SMS, voice, OTP, and manage messaging with ease.

37 lines (36 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemplatesService = void 0; class TemplatesService { constructor(http) { this.http = http; } /** * Send a template-based message via WhatsApp or SMS. * * @param payload - The request payload containing recipient details, * template ID, device ID, and template data values. * @returns A promise that resolves to the API response with message details. * * @example * ```ts * const templatesService = new TemplatesService(httpClient); * const response = await templatesService.sendTemplate({ * phone_number: "+2348012345678", * device_id: "DEVICE123", * template_id: "TEMPLATE456", * data: { name: "John", amount: 5000 } * }); * * console.log(response.message_id); // e.g. "MSG7890" * ``` */ async sendTemplate(payload) { return this.http.request("/send/template", { method: "POST", data: payload, authLocation: "body" }); } } exports.TemplatesService = TemplatesService;