Skip to content

Commit

Permalink
Add support for Apts-SMS -Tanzania
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Mosoti committed Jun 19, 2018
1 parent d5042c9 commit d82228e
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
'password' => env('TILIL_PASSWORD'),
'short_code' => env('TILIL_SHORTCODE'),
'call_back_url' => env('TILIL_CALL_BACK_URL')
],

'aptus' => [
'username' => env('APTUS_USERNAME'),
'password' => env('APTUS_PASSWORD'),
'senderid' => env('APTUS_SENDERID')
]
],

Expand All @@ -90,5 +96,6 @@
'infosky' => \CraftedSystems\LaravelSMS\Gateways\InfoSky::class,
'infobip' => \CraftedSystems\LaravelSMS\Gateways\InfoBip::class,
'tilil' => \CraftedSystems\LaravelSMS\Gateways\Tilil::class,
'aptus' => \CraftedSystems\LaravelSMS\Gateways\Aptus::class,
]
];
85 changes: 85 additions & 0 deletions src/Gateways/Aptus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Created by PhpStorm.
* User: vincent
* Date: 12/14/17
* Time: 6:04 PM
*/

namespace CraftedSystems\LaravelSMS\Gateways;


use CraftedSystems\Aptus\AptusSMS;
use CraftedSystems\LaravelSMS\Contracts\SMSContract;
use Illuminate\Http\Request;

class Aptus implements SMSContract
{
/**
* @var AptusSMS
*/
protected $class;


/**
* MicroMobile constructor.
* @param $settings
* @throws \Exception
*/
public function __construct($settings)
{
if (!class_exists('CraftedSystems\Aptus\AptusSMS')) {

throw new \Exception("Class 'CraftedSystems\Aptus\AptusSMS' does not exist");
}

$this->class = new AptusSMS($settings);
}

/**
* @param $recipient
* @param $message
* @param null $params
* @return mixed
* @throws \Exception
*/
public function send($recipient, $message, $params = null)
{
$response = $this->class->send($recipient, $message);
$d = explode(",", $response);

$data = [
'is_success' => $d[0] === 'OK',
'queued' => $d[1],
'message_id' => $d[2]
];

return (object)$data;
}

/**
* @return mixed
*/
public function getBalance()
{
return $this->class->getBalance();
}


/**
* @param Request $request
* @return mixed|object
*/
public function getDeliveryReports(Request $request)
{
$response = $this->class->getDeliveryReports($request);

$data = [
'status' => $response->dlrDesc,
'message_id' => $response->messageId,
'network' => $response->network
];

return (object)$data;
}
}

0 comments on commit d82228e

Please sign in to comment.