Skip to content

Commit f210a7d

Browse files
committed
1.0.1
1 parent 23c0e41 commit f210a7d

File tree

6 files changed

+72
-76
lines changed

6 files changed

+72
-76
lines changed

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
],
1212
"require": {
1313
"php": ">=7.0.28",
14-
"guzzlehttp/guzzle": "^6.3@dev",
15-
"monolog/monolog": "^2.0@dev",
16-
"brick/phonenumber": "dev-master"
14+
"guzzlehttp/guzzle": "^6.3.0",
15+
"monolog/monolog": "^1.23.0",
16+
"brick/phonenumber": "^0.2.0"
1717
},
1818
"autoload": {
1919
"psr-4": {
2020
"Tecdiary\\Sms\\": "src/"
2121
}
22-
},
23-
"minimum-stability": "dev"
22+
}
2423
}

composer.lock

Lines changed: 46 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
$sms = new \Tecdiary\Sms\Sms($config);
1515

16-
$result = $sms->send(['+919090909090', '009190909090901'], 'This is test message for Log gateway.');
16+
$result = $sms->send(['+919090909090', '009190909090901'], 'This is test message for Log gateway.')->response();
1717
?><html>
1818
<head>
1919
<meta charset="UTF-8">
@@ -23,6 +23,6 @@
2323
<pre/>
2424

2525
TECDIARY/SMS DEMO
26-
<?php var_dump($result->status, $result->response); ?>
26+
<?php var_dump($result); ?>
2727
</body>
2828
</html>

src/Gateways/MVaayooGateway.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,25 @@ class MVaayooGateway implements SmsGatewayInterface
88
public $logger;
99
public $response = '';
1010

11-
protected $gwvars = [];
11+
protected $params = [];
1212
protected $request = '';
13-
protected $status = false;
1413
protected $url = 'http://api.mVaayoo.com/mvaayooapi/MessageCompose?';
1514

1615
public function __construct($config, $logger)
1716
{
1817
$this->config = $config;
1918
$this->logger = $logger;
20-
$this->gwvars['receipientno'] = '';
21-
$this->gwvars['msgtxt'] = '';
22-
$this->gwvars['senderID'] = $this->config[$this->config['gateway']]['senderID'];
23-
$this->gwvars['user'] = $this->config[$this->config['gateway']]['user'];
24-
$this->gwvars['msgtype'] = 0;
25-
$this->gwvars['state'] = 4;
19+
$this->params['receipientno'] = '';
20+
$this->params['msgtxt'] = '';
21+
$this->params['senderID'] = $this->config[$this->config['gateway']]['senderID'];
22+
$this->params['user'] = $this->config[$this->config['gateway']]['user'];
23+
$this->params['msgtype'] = 0;
24+
$this->params['state'] = 4;
2625
}
2726

2827
public function getUrl()
2928
{
30-
foreach ($this->gwvars as $key => $val) {
29+
foreach ($this->params as $key => $val) {
3130
$this->request.= $key."=".urlencode($val);
3231
$this->request.= "&";
3332
}
@@ -37,8 +36,8 @@ public function getUrl()
3736

3837
public function sendSms($mobile, $message)
3938
{
40-
$this->gwvars['receipientno'] = $mobile;
41-
$this->gwvars['msgtxt'] = $message;
39+
$this->params['receipientno'] = $mobile;
40+
$this->params['msgtxt'] = $message;
4241
$client = new \GuzzleHttp\Client();
4342
$this->response = $client->get($this->getUrl())->getBody()->getContents();
4443
$this->logger->info('MVaayoo Response: '.$this->response);
@@ -47,10 +46,6 @@ public function sendSms($mobile, $message)
4746

4847
public function response()
4948
{
50-
$status = explode(',', $this->response);
51-
if (trim($status[0]) == 'Status=0') {
52-
$this->status = true;
53-
}
54-
return ['status' => $this->status, 'response' => $this->response];
49+
return $this->response;
5550
}
5651
}

src/Gateways/NexmoGateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function getUrl()
3333
return $this->url;
3434
}
3535

36-
public function sendSms($mobiles, $message)
36+
public function sendSms($mobile, $message)
3737
{
38-
$mobiles = explode(',', $mobiles);
38+
$mobiles = explode(',', $mobile);
3939
$this->composeBulkMobile($mobiles, $message);
4040
return $this;
4141
}

src/Sms.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Sms
66
{
77
public $logger;
88
public $gateway;
9+
public $status = false;
910

1011
public function __construct($config)
1112
{
@@ -19,7 +20,7 @@ public function send($phone_numbers, $message)
1920
if ($phone_numbers = $this->composeBulkNumbers($phone_numbers)) {
2021
return $this->gateway->sendSms($phone_numbers, $message);
2122
}
22-
return (object) ['status' => false, 'response' => 'The provided phone number(s) were not valid.'];
23+
return $this;
2324
}
2425

2526
public function composeBulkNumbers($phone_numbers)
@@ -44,4 +45,9 @@ public function composeBulkNumbers($phone_numbers)
4445
$numbers = implode(',', $new_phone_numbers);
4546
return $numbers;
4647
}
48+
49+
public function response()
50+
{
51+
return $this->status;
52+
}
4753
}

0 commit comments

Comments
 (0)