1 | <?php |
||
2 | namespace Sender; |
||
3 | |||
4 | use Sender\Sms\SmsBulk; |
||
5 | use Sender\Sms\SmsNormal; |
||
6 | use Sender\Config\Config as ConfigClass; |
||
7 | use Sender\ExceptionClass\ParameterException; |
||
8 | |||
9 | /** |
||
10 | * This Class provide Promotional SMS APIs |
||
11 | * |
||
12 | * @package Sender\PromotionalSms |
||
13 | * @author VenkatS <[email protected]> |
||
14 | * @link https://github.com/tesark/msg91-php |
||
15 | * @license MIT |
||
16 | */ |
||
17 | |||
18 | class PromotionalSms |
||
19 | { |
||
20 | /** |
||
21 | * @var string $promoAuthKey |
||
22 | */ |
||
23 | protected $promoAuthKey; |
||
24 | 40 | public function __construct($authkey = null) |
|
25 | { |
||
26 | 40 | $this->promoAuthKey = $authkey; |
|
27 | 40 | } |
|
28 | /** |
||
29 | * Send promotional SMS MSG91 Service |
||
30 | * @param string $mobileNumber |
||
31 | * @param array $data |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | 40 | public function sendPromotional($mobileNumber, $data) |
|
36 | { |
||
37 | 40 | $sms = new SmsNormal(); |
|
38 | 40 | $promoAuthKey = $this->promoAuthKey; |
|
39 | 40 | $data['mobile'] = $mobileNumber; |
|
40 | 40 | $response = $sms->smsCategory($data, 0, $promoAuthKey); |
|
41 | return $response; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Send Bulk promotional SMS MSG91 Service |
||
46 | * @param array $data |
||
47 | * |
||
48 | * @throws ParameterException missing parameters or return empty |
||
49 | * @return string |
||
50 | */ |
||
51 | public function sendBulkSms($data) |
||
52 | { |
||
53 | if (is_array($data)) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
54 | $response = null; |
||
55 | $arrayLength = sizeof($data); |
||
56 | if (isset($arrayLength) && $arrayLength == 1) { |
||
57 | $currentArray = $data[0]; |
||
58 | $sms = new SmsBulk(); |
||
59 | $response = $sms->buildAndSendXmlSms($currentArray); |
||
60 | } else { |
||
61 | for ($i = 0; $i < $arrayLength; $i++) { |
||
62 | $currentArray = $data[$i]; |
||
63 | $sms = new SmsBulk(); |
||
64 | $response = $sms->buildAndSendXmlSms($currentArray); |
||
65 | } |
||
66 | } |
||
67 | return $response; |
||
68 | } else { |
||
69 | throw ParameterException::missinglogic("Check parameter is must be array."); |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 |