diff --git a/readme.md b/readme.md index 3c8f6d8..e9952ce 100644 --- a/readme.md +++ b/readme.md @@ -226,6 +226,7 @@ echo $status = $sender->send(); | TwentyFourBulkSmsBD | customer_id, api_key | - | Done | - | - | | Trubosms | api_token, sender_id | - | Done | - | - | | Viatech | api_key, mask | - | Done | - | - | +| WinText | token, messagetype, ismasking, masking | - | Done | - | - | | ZamanIT | api_key, senderid,type | - | Done | - | - | diff --git a/src/Config/sms.php b/src/Config/sms.php index 824d3dd..41d87e8 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -59,6 +59,7 @@ use Xenon\LaravelBDSms\Provider\Twenty4BulkSms; use Xenon\LaravelBDSms\Provider\TwentyFourBulkSmsBD; use Xenon\LaravelBDSms\Provider\Viatech; +use Xenon\LaravelBDSms\Provider\WinText; use Xenon\LaravelBDSms\Provider\ZamanIt; return [ @@ -309,6 +310,12 @@ 'user_email' => env('SMS_TWENTYFOUR_BULKSMS_USER_EMAIL', ''), 'api_key' => env('SMS_TWENTYFOUR_BULKSMS_APP_KEY', ''), ], + WinText::class => [ + 'token' => env('SMS_WINTEXT_TOKEN', ''), + 'messagetype' => env('SMS_WINTEXT_MESSAGE_TYPE', ''), + 'ismasking' => env('SMS_WINTEXT_IS_MASKING', ''), + 'masking' => env('SMS_WINTEXT_MASKING',''), + ], ZamanIt::class => [ 'api_key' => env('SMS_ZAMANIT_API_KEY', ''), 'type' => env('SMS_ZAMANIT_TYPE', ''), diff --git a/src/Provider/WinText.php b/src/Provider/WinText.php new file mode 100644 index 0000000..ca0293d --- /dev/null +++ b/src/Provider/WinText.php @@ -0,0 +1,88 @@ +senderObject = $sender; + } + + /** + * @return false|string + * @throws RenderException + * @version v1.0.32 + * @since v1.0.31 + */ + public function sendRequest() + { + $mobile = $this->senderObject->getMobile(); + $text = $this->senderObject->getMessage(); + $config = $this->senderObject->getConfig(); + $queue = $this->senderObject->getQueue(); + $queueName = $this->senderObject->getQueueName(); + $tries = $this->senderObject->getTries(); + $backoff = $this->senderObject->getBackoff(); + + $formParams = [ + "token" => $config['token'], + "messagetype" => $config['messagetype'] ?? 1, + "ismasking" => $config['ismasking'] ?? 'false', + "masking" => $config['masking'] ?? 'null', + "SMSText" => $text, + ]; + + if (!is_array($mobile)) { + $formParams['mobileno'] = Helper::ensureNumberStartsWith88($mobile); + } else { + /*foreach ($mobile as $element) { + $tempMobile[] = Helper::ensureNumberStartsWith88($element); + } + $formParams['mobileno'] = implode(',', $tempMobile);*/ + } + + //dd($this->apiEndpoint, $formParams); + $requestObject = new Request($this->apiEndpoint, [], $queue, [], $queueName, $tries, $backoff); + $requestObject->setFormParams($formParams); + $response = $requestObject->post(false, 60); + if ($queue) { + return true; + } + + + $body = $response->getBody(); + $smsResult = $body->getContents(); + + $data['number'] = $mobile; + $data['message'] = $text; + return $this->generateReport($smsResult, $data)->getContent(); + } + + /** + * @throws RenderException + * @version v1.0.32 + * @since v1.0.31 + */ + public function errorException() + { + $config = $this->senderObject->getConfig(); + + if (!array_key_exists('token', $config)) { + throw new RenderException('token key is absent in configuration'); + } + } +}