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:

/**
 * 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(string $senderId, string $useCase, string $company);

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

/**
 * Send bulk message
 * @param string $to
 * @param string $from
 * @param string $sms
 * @param string $channel
 *
 * @return array
 */
Termii::sendBulkMessage(string $to, string $from, string $sms, string $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(string $to, string $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(string $phoneNumber, string $deviceId, string $templateId, array $data)

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