Skip to content

Commit b1657ae

Browse files
author
Vincent Mosoti
committed
support for Tilil Gateway
1 parent ec9a232 commit b1657ae

File tree

3 files changed

+97
-4
lines changed

3 files changed

+97
-4
lines changed

src/Config/sms.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@
6060
'password' => env('INFOBIP_PASSWORD'),
6161
'from' => env('INFOBIP_FROM'),
6262
'call_back_url' => env('INFOBIP_CALL_BACK_URL')
63+
],
64+
65+
'tilil' => [
66+
'username' => env('TILIL_USERNAME'),
67+
'password' => env('TILIL_PASSWORD'),
68+
'short_code' => env('TILIL_SHORTCODE'),
69+
'call_back_url' => env('TILIL_CALL_BACK_URL')
6370
]
6471
],
6572

@@ -82,5 +89,6 @@
8289
'africastalking' => \CraftedSystems\LaravelSMS\Gateways\AfricasTalking::class,
8390
'infosky' => \CraftedSystems\LaravelSMS\Gateways\InfoSky::class,
8491
'infobip' => \CraftedSystems\LaravelSMS\Gateways\InfoBip::class,
92+
'tilil' => \CraftedSystems\LaravelSMS\Gateways\Tilil::class,
8593
]
8694
];

src/Gateways/InfoSky.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
namespace CraftedSystems\LaravelSMS\Gateways;
1010

11-
use CraftedSystems\InfoSky\InfoSkySMS;
11+
use CraftedSystems\InfoSky\TililSMS;
1212
use CraftedSystems\LaravelSMS\Contracts\SMSContract;
1313
use Illuminate\Http\Request;
1414

1515
class InfoSky implements SMSContract
1616
{
1717
/**
18-
* @var InfoSkySMS
18+
* @var TililSMS
1919
*/
2020
protected $class;
2121

@@ -27,12 +27,12 @@ class InfoSky implements SMSContract
2727
*/
2828
public function __construct($settings)
2929
{
30-
if (!class_exists('CraftedSystems\InfoSky\InfoSkySMS')) {
30+
if (!class_exists('CraftedSystems\InfoSky\TililSMS')) {
3131

3232
throw new \Exception("Class 'CraftedSystems\InfoSky\InfoSkySMS' does not exist");
3333
}
3434

35-
$this->class = new InfoSkySMS($settings);
35+
$this->class = new TililSMS($settings);
3636
}
3737

3838
/**

src/Gateways/Tilil.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+
use CraftedSystems\Tilil\TililSMS;
12+
use CraftedSystems\LaravelSMS\Contracts\SMSContract;
13+
use Illuminate\Http\Request;
14+
15+
class Tilil implements SMSContract
16+
{
17+
/**
18+
* @var TililSMS
19+
*/
20+
protected $class;
21+
22+
23+
/**
24+
* MicroMobile constructor.
25+
* @param $settings
26+
* @throws \Exception
27+
*/
28+
public function __construct($settings)
29+
{
30+
if (!class_exists('CraftedSystems\Tilil\TililSMS')) {
31+
32+
throw new \Exception("Class 'CraftedSystems\Tilil\TililSMS' does not exist");
33+
}
34+
35+
$this->class = new TililSMS($settings);
36+
}
37+
38+
/**
39+
* @param $recipient
40+
* @param $message
41+
* @param null $params
42+
* @return mixed
43+
* @throws \Exception
44+
*/
45+
public function send($recipient, $message, $params = null)
46+
{
47+
$response = $this->class->send($recipient, $message);
48+
$d = explode(";", $response);
49+
50+
$data = [
51+
'is_success' => $d[1] === 'Success',
52+
'destination' => $d[2],
53+
'message_id' => $d[0],
54+
'network_id' => $d[3]
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)