From 0a06b4212be700e4e56f57b860d40f36184ad162 Mon Sep 17 00:00:00 2001 From: Ariful Date: Mon, 30 Sep 2024 19:17:23 +0600 Subject: [PATCH] SendmySms Gateway Added --- src/Config/sms.php | 5 +++ src/Provider/SendMySms.php | 91 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 src/Provider/SendMySms.php diff --git a/src/Config/sms.php b/src/Config/sms.php index 41d87e8..84848bf 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -44,6 +44,7 @@ use Xenon\LaravelBDSms\Provider\Onnorokom; use Xenon\LaravelBDSms\Provider\QuickSms; use Xenon\LaravelBDSms\Provider\RedmoItSms; +use Xenon\LaravelBDSms\Provider\SendMySms; use Xenon\LaravelBDSms\Provider\SmartLabSms; use Xenon\LaravelBDSms\Provider\Sms4BD; use Xenon\LaravelBDSms\Provider\SmsBangladesh; @@ -236,6 +237,10 @@ 'api_token' => env('SMS_REDMOIT_API_TOKEN', ''), 'type' => env('SMS_REDMOIT_TYPE', 'string'), ], + SendMySms::class => [ + 'user' => env('SMS_SENDMYSMS_USER', ''), + 'key' => env('SMS_SENDMYSMS_PASSWORD', ''), + ], SmartLabSms::class => [ 'user' => env('SMS_SMARTLAB_USER', ''), 'password' => env('SMS_SMARTLAB_PASSWORD', ''), diff --git a/src/Provider/SendMySms.php b/src/Provider/SendMySms.php new file mode 100644 index 0000000..481f6b8 --- /dev/null +++ b/src/Provider/SendMySms.php @@ -0,0 +1,91 @@ +senderObject = $sender; + } + + /** + * Send Request To Api and Send Message + * @throws RenderException + */ + public function sendRequest() + { + $number = $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(); + + $query = [ + 'user' => $config['user'], + 'key' => $config['key'], + 'to' => $number, + 'msg' => $text, + ]; + + if (is_array($number)) { + // $query['to'] = ['01733499574', '01750840217']; + } + + + + $requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff); + $requestObject->setFormParams($query); + $response = $requestObject->post(); + if ($queue) { + return true; + } + + $body = $response->getBody(); + $smsResult = $body->getContents(); + + $data['number'] = $number; + $data['message'] = $text; + return $this->generateReport($smsResult, $data)->getContent(); + } + + /** + * @throws ParameterException + */ + public function errorException() + { + if (!array_key_exists('user', $this->senderObject->getConfig())) { + throw new ParameterException('user key is absent in configuration'); + } + if (!array_key_exists('key', $this->senderObject->getConfig())) { + throw new ParameterException('key key is absent in configuration'); + } + + } +}