Skip to content

Commit d82228e

Browse files
author
Vincent Mosoti
committed
Add support for Apts-SMS -Tanzania
1 parent d5042c9 commit d82228e

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

src/Config/sms.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
'password' => env('TILIL_PASSWORD'),
6868
'short_code' => env('TILIL_SHORTCODE'),
6969
'call_back_url' => env('TILIL_CALL_BACK_URL')
70+
],
71+
72+
'aptus' => [
73+
'username' => env('APTUS_USERNAME'),
74+
'password' => env('APTUS_PASSWORD'),
75+
'senderid' => env('APTUS_SENDERID')
7076
]
7177
],
7278

@@ -90,5 +96,6 @@
9096
'infosky' => \CraftedSystems\LaravelSMS\Gateways\InfoSky::class,
9197
'infobip' => \CraftedSystems\LaravelSMS\Gateways\InfoBip::class,
9298
'tilil' => \CraftedSystems\LaravelSMS\Gateways\Tilil::class,
99+
'aptus' => \CraftedSystems\LaravelSMS\Gateways\Aptus::class,
93100
]
94101
];

src/Gateways/Aptus.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: vincent
5+
* Date: 12/14/17
6+
* Time: 6:04 PM
7+
*/
8+
9+
namespace CraftedSystems\LaravelSMS\Gateways;
10+
11+
12+
use CraftedSystems\Aptus\AptusSMS;
13+
use CraftedSystems\LaravelSMS\Contracts\SMSContract;
14+
use Illuminate\Http\Request;
15+
16+
class Aptus implements SMSContract
17+
{
18+
/**
19+
* @var AptusSMS
20+
*/
21+
protected $class;
22+
23+
24+
/**
25+
* MicroMobile constructor.
26+
* @param $settings
27+
* @throws \Exception
28+
*/
29+
public function __construct($settings)
30+
{
31+
if (!class_exists('CraftedSystems\Aptus\AptusSMS')) {
32+
33+
throw new \Exception("Class 'CraftedSystems\Aptus\AptusSMS' does not exist");
34+
}
35+
36+
$this->class = new AptusSMS($settings);
37+
}
38+
39+
/**
40+
* @param $recipient
41+
* @param $message
42+
* @param null $params
43+
* @return mixed
44+
* @throws \Exception
45+
*/
46+
public function send($recipient, $message, $params = null)
47+
{
48+
$response = $this->class->send($recipient, $message);
49+
$d = explode(",", $response);
50+
51+
$data = [
52+
'is_success' => $d[0] === 'OK',
53+
'queued' => $d[1],
54+
'message_id' => $d[2]
55+
];
56+
57+
return (object)$data;
58+
}
59+
60+
/**
61+
* @return mixed
62+
*/
63+
public function getBalance()
64+
{
65+
return $this->class->getBalance();
66+
}
67+
68+
69+
/**
70+
* @param Request $request
71+
* @return mixed|object
72+
*/
73+
public function getDeliveryReports(Request $request)
74+
{
75+
$response = $this->class->getDeliveryReports($request);
76+
77+
$data = [
78+
'status' => $response->dlrDesc,
79+
'message_id' => $response->messageId,
80+
'network' => $response->network
81+
];
82+
83+
return (object)$data;
84+
}
85+
}

0 commit comments

Comments
 (0)