Termii-JS Laravel Package
Termii-JS is a Laravel package that simplifies setting up, testing, and managing your Termii integration directly in your Laravel application.
![Total Downloads](https://img.shields.io/packagist/dt/zeevx/Termii-JS.svg?style=flat-square)
Installation
You can install the package via npm:
npm install @emmsdan/termii-js
You can install the package via yarn:
yarn add @emmsdan/termii-js
Usage
Declare an Instance of the TermiiJs Class
You can create an instance of the TermiiJs class by providing your Termii API key:
import { TermiiJs } from '@emmsdan/termii-js';
const termii = new TermiiJs("YOUR-TERMII-API-KEY");
Check Your Termii Balance
You can check your Termii account balance by calling the balance method:
termii.balance()
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Reports for Messages Sent
To retrieve reports for messages sent across SMS, voice, and WhatsApp channels, use the history method:
termii.history()
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Detect If a Number Is Fake or Ported
You can check if a phone number is fake or has ported to a new network using the status method:
const phoneNumber = 1234567890;
const countryCode = 'US';
termii.status(phoneNumber, countryCode)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Verify Phone Numbers
Verify phone numbers and automatically detect their status with the search method:
const phoneNumber = 1234567890;
termii.search(phoneNumber)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Retrieve Sender ID Status
You can retrieve the status of all registered sender IDs using the allSenderId method:
termii.allSenderId()
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Request a New Sender ID
To request a new sender ID, use the submitSenderId method:
const senderId = 'NEW_SENDER_ID';
const useCase = 'SAMPLE_USE_CASE';
const company = 'YOUR_COMPANY_NAME';
termii.submitSenderId(senderId, useCase, company)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Send Messages
Send messages using the sendMessage method:
const to = 1234567890;
const from = 'SENDER_ID';
const sms = 'Hello, World!';
termii.sendMessage(to, from, sms)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Send OTP
Send one-time passwords (OTP) with the sendOTP method:
const to = 1234567890;
const from = 'SENDER_ID';
const messageType = 'TEXT';
const pinAttempts = 3;
const pinTimeToLive = 3600;
const pinLength = 6;
const pinPlaceholder = 'PIN_PLACEHOLDER';
const messageText = 'Your OTP is: PIN_PLACEHOLDER';
termii.sendOTP(to, from, messageType, pinAttempts, pinTimeToLive, pinLength, pinPlaceholder, messageText)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Send Voice OTP
Send voice OTP using the sendVoiceOTP method:
const to = 1234567890;
const pinAttempts = 3;
const pinTimeToLive = 3600;
const pinLength = 6;
termii.sendVoiceOTP(to, pinAttempts, pinTimeToLive, pinLength)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Send Voice Call
Send voice calls using the sendVoiceCall method:
const to = 1234567890;
const code = 1234;
termii.sendVoiceCall(to, code)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
OTP Validation
You can verify or validate OTP using the verifyOTP method:
const pinId = 'PIN_ID';
const pin = '123456';
termii.verifyOTP(pinId, pin)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Send In-App OTP
Send In-App OTP using the sendInAppOTP method:
const to = 1234567890;
const pinAttempts = 3;
const pinTimeToLive = 3600;
const pinLength = 6;
const pinType = 'numeric';
termii.sendInAppOTP(to, pinAttempts, pinTimeToLive, pinLength, pinType)
.then((result) => {
console.log(result);
})
.catch((error) => {
console.error(error);
});
Security
If you discover any security-related issues, please email adamsohiani@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT)