Skip to content
Ayomide Olakulehin edited this page Mar 31, 2022 · 6 revisions

Available Methods

You either use this package's facade Corbancode\TermiiLaravel\Facades\Termii or helper function termii() to access the available methods. Available methods for use are:

use Corbancode\TermiiLaravel\Facades\Termii;

/**
 * Retrieve the status of all registered sender ID.
 *
 * @return array
 */
Termii::fetchSenderId();

/**
 * Request registration of Sender ID
 * @param string $senderId
 * @param string $useCase
 * @param string $company
 *
 * @return array
 */
Termii::requestSenderId($senderId, $useCase, $company);

/**
 * Send a message
 * @param string $to
 * @param string $from
 * @param string $sms
 * @param string $channel
 * @param string|null $media
 *
 * @return array
 */
Termii::sendMessage($to, $from, $sms, $channel = "generic", $media = null);

/**
 * Send bulk message
 * @param string $to
 * @param string $from
 * @param string $sms
 * @param string $channel
 *
 * @return array
 */
Termii::sendBulkMessage($to, $from, $sms, $channel = "generic");

/**
 * Send number message
 * This API allows businesses send messages to customers using
 * Termii's auto-generated messaging numbers that adapt to customers location.
 * @param string $to
 * @param string $sms
 *
 * @return array
 */
Termii::sendNumberMessage($to, $sms);

/**
 * Device Template
 * Templates API helps businesses set a template for the one-time-passwords (pins) sent
 * to their customers via whatsapp or sms.
 * @param string $phoneNumber
 * @param string $deviceId
 * @param string $templateId
 * @param array $data
 *
 * @return array
 */
Termii::deviceTemplate($phoneNumber, $deviceId, $templateId, $data);

 /**
  * Trigger one-time-passwords (OTP) across any available messaging channel.
  * @param array $data
  *
  * @return array
  */
Termii::sendToken($data);

/**
 * Trigger one-time-passwords (OTP) through the voice channel to a phone number.
 * @param array $data
 *
 * @return array
 */
Termii::voiceToken($data);

/**
 * Send messages through voice channel to a phone number.
 * @param string $phoneNumber
 * @param string $code
 *
 * @return array
 */
Termii::voiceCall($phoneNumber, $code);

/**
 * Checks tokens sent to customers and returns a response confirming the status of the token.
 * @param string $pinId
 * @param string $pin
 *
 * @return array
 */
Termii::verifyToken($pinId, $pin);

/**
 * This API returns OTP codes in JSON format which can be used within any web or mobile app.
 * @param array $data
 *
 * @return array
 */
Termii::inAppToken($data)

/**
 * Returns your total balance and balance information from your wallet, such as currency.
 *
 * @return array
 */
Termii::getBalance();

/**
 * Verify phone numbers and automatically detect their status as well as current network
 * @param $phoneNumber
 *
 * @return array
 */
public function search($phoneNumber);

/**
 * Detect if a number is fake or has ported to a new network.
 * @param $countryCode
 * @param $phoneNumber
 *
 * @return array
 */
Termii::status($countryCode, $phoneNumber)

/**
 * Returns reports for messages sent across the sms, voice & whatsapp channels.
 *
 * @return array
 */
Termii::history()

Notifications Channel

You can also use Termii channel in your via() method inside the notification:

use Corbancode\TermiiLaravel\Notifications\TermiiChannel;
use Corbancode\TermiiLaravel\Notifications\TermiiMessage;
use Illuminate\Notifications\Notification;

class UserPhoneVerification extends Notification
{
    public function via($notifiable)
    {
        return [TermiiChannel::class];
    }

    public function toTermii($notifiable)
    {
        return (new TermiiMessage())
            ->content("[Your App] confirmation code is 548434. It expires in 5 minutes.");
    }
}

In order to let your Notification know which phone number you are sending to, add the routeNotificationForTermii method to your Notifiable model

public function routeNotificationForTermii()
{
    return $this->phone; // where `phone` is a field in your users table;
}

Available Message methods

TermiiMessage
  • from(''): Accepts a sender ID to use as the notification sender. TERMII_SMS_FROM .env value would be used as default incase this method is not used.
  • content(''): Accepts a string value for the notification body.
  • channel(''): Accepts a string value for the sms channel. Defaults to "generic" incase this method is not used.
  • media(): Accepts an array value for the media.
Clone this wiki locally