Skip to content

Commit

Permalink
Merge pull request #31 from sim8568X/master
Browse files Browse the repository at this point in the history
Merge Request for Adding SmsQ Gateway
  • Loading branch information
sim8568X authored Mar 16, 2023
2 parents d84bbe8 + 405601d commit f90e838
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | - | [email protected], +880 1705 691269, +880 1733393 712 |
| SmsNoc | sender_id, bearer_token | Done | - | |
| Sslsms | api_token, sid, csms_id | Done | - | - |
Expand Down
6 changes: 6 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', ''),
Expand Down
88 changes: 88 additions & 0 deletions src/Provider/SmsQ.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/*
* Last Modified: 6/29/21, 12:06 AM
* Copyright (c) 2021
* -created by Ariful Islam
* -All Rights Preserved By
* -If you have any query then knock me at
* [email protected]
* See my profile @ https://github.com/arif98741
*/

namespace Xenon\LaravelBDSms\Provider;

use Xenon\LaravelBDSms\Handler\ParameterException;
use Xenon\LaravelBDSms\Handler\RenderException;
use Xenon\LaravelBDSms\Request;
use Xenon\LaravelBDSms\Sender;

class SmsQ extends AbstractProvider
{
/**
* SmsQ constructor.
* @param Sender $sender
*/
public function __construct(Sender $sender)
{
$this->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');
}

}

}

0 comments on commit f90e838

Please sign in to comment.