From 936fcca7080214adcf92a6bb481b02e8ad955229 Mon Sep 17 00:00:00 2001 From: Ariful Islam Date: Wed, 15 Mar 2023 12:19:39 +0600 Subject: [PATCH 1/2] SmsQ Gateway Added --- readme.md | 1 + src/Config/sms.php | 8 +++- src/Provider/SmsQ.php | 88 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/Provider/SmsQ.php diff --git a/readme.md b/readme.md index d788ea4..56ce747 100644 --- a/readme.md +++ b/readme.md @@ -192,6 +192,7 @@ $status = $sender->send(); | RedmoITSms | api_token, sender_id | Support closed | - | | SmartLabSMS | user, password, sender | Done | - | - | | SmsinBD | api_token, senderid | Done | 01777-333677 | - | +| SmsQ | sender_id, client_id, api_key | Done | | - | | SMSNet24 | user_id, user_password, route_id(optional), sms_type_id(optional) | Done | - | admin2@digitallabbd.com, +880 1705 691269, +880 1733393 712 | | SmsNoc | sender_id, bearer_token | Done | - | | | Sslsms | api_token, sid, csms_id | Done | - | - | diff --git a/src/Config/sms.php b/src/Config/sms.php index 523e1f3..e1fe184 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -42,6 +42,7 @@ use Xenon\LaravelBDSms\Provider\SmsinBD; use Xenon\LaravelBDSms\Provider\SmsNet24; use Xenon\LaravelBDSms\Provider\SMSNoc; +use Xenon\LaravelBDSms\Provider\SmsQ; use Xenon\LaravelBDSms\Provider\Ssl; use Xenon\LaravelBDSms\Provider\Tense; use Xenon\LaravelBDSms\Provider\TruboSms; @@ -55,7 +56,7 @@ | You Can change sms log to true or false according to your need. Default is true |--------------------------------------------------------------------------------------------- */ - 'sms_log' => false, + 'sms_log' => true, /* *----------------------------------------------------------------------------------------------- @@ -197,6 +198,11 @@ 'api_token' => env('SMSINBD_API_TOKEN', ''), 'senderid' => env('SMSINBD_SENDERID', ''), ], + SmsQ::class => [ + 'sender_id' => env('SMS_SMSQ_SENDER_ID', ''), + 'api_key' => env('SMS_SMSQ_API_KEY', ''), + 'client_id' => env('SMS_SMSQ_CLIENT_ID', ''), + ], Ssl::class => [ 'api_token' => env('SMS_SSL_API_TOKEN', ''), 'sid' => env('SMS_SSL_SID', ''), diff --git a/src/Provider/SmsQ.php b/src/Provider/SmsQ.php new file mode 100644 index 0000000..ac81681 --- /dev/null +++ b/src/Provider/SmsQ.php @@ -0,0 +1,88 @@ +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(); + + $query = [ + 'SenderId' => $config['sender_id'], + 'ApiKey' => $config['api_key'], + 'ClientId' => $config['client_id'], + 'Message' => $text, + 'MobileNumbers' => $number, + ]; + + $headers = [ + 'Content-Type' => 'application/json' + ]; + + $requestObject = new Request('https://api.smsq.global/api/v2/SendSMS', $query, $queue); + $requestObject->setHeaders($headers)->setContentTypeJson(true); + $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('sender_id', $this->senderObject->getConfig())) { + throw new ParameterException('sender_id key is absent in configuration'); + } + + if (!array_key_exists('api_key', $this->senderObject->getConfig())) { + throw new ParameterException('api_key key is absent in configuration'); + } + + if (!array_key_exists('client_id', $this->senderObject->getConfig())) { + throw new ParameterException('client_id key is absent in configuration'); + } + + } + +} From f2e747248f7f6f8063e6364fbd88ce8ac560667a Mon Sep 17 00:00:00 2001 From: Ariful Islam Date: Wed, 15 Mar 2023 12:21:42 +0600 Subject: [PATCH 2/2] sms log set to false --- src/Config/sms.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Config/sms.php b/src/Config/sms.php index e1fe184..5e7d51d 100644 --- a/src/Config/sms.php +++ b/src/Config/sms.php @@ -56,7 +56,7 @@ | You Can change sms log to true or false according to your need. Default is true |--------------------------------------------------------------------------------------------- */ - 'sms_log' => true, + 'sms_log' => false, /* *-----------------------------------------------------------------------------------------------