Skip to content

Commit

Permalink
Merge pull request #59 from arif98741/dev
Browse files Browse the repository at this point in the history
Merge Request to Add Quick Sms Gateway
  • Loading branch information
arif98741 authored Oct 26, 2023
2 parents 0514d6a + 5084bfb commit f4d0de3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ $status = $sender->send();
| Muthofun | sender_id | Yes | Done | - | - |
| NovocomBD | ApiKey , ClientId , SenderId | - | Done | - | - |
| OnnoRokomSMS | userName, userPassword, type, maskName, campaignName | - | Done | not tested yet in live | - |
| QuickSms | api_key, senderid, type,scheduledDateTime | - | Done | not tested yet in live | - |
| RedmoITSms | api_token, sender_id | - | Support closed | - |
| SmartLabSMS | user, password, sender | - | Done | - | - |
| SmsinBD | api_token, senderid | - | Done | | - |
Expand Down
7 changes: 7 additions & 0 deletions src/Config/sms.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Xenon\LaravelBDSms\Provider\Muthofun;
use Xenon\LaravelBDSms\Provider\NovocomBd;
use Xenon\LaravelBDSms\Provider\Onnorokom;
use Xenon\LaravelBDSms\Provider\QuickSms;
use Xenon\LaravelBDSms\Provider\RedmoItSms;
use Xenon\LaravelBDSms\Provider\SmartLabSms;
use Xenon\LaravelBDSms\Provider\Sms4BD;
Expand Down Expand Up @@ -197,6 +198,12 @@
'maskName' => env('SMS_ONNOROKOM_MASK', ''),
'campaignName' => env('SMS_ONNOROKOM_CAMPAIGN_NAME', ''),
],
QuickSms::class => [
'api_key' => env('SMS_QUICKSMS_API_KEY'),
'senderid' => env('SMS_QUICKSMS_SENDER_ID'),
'type' => env('SMS_QUICKSMS_SENDER_ID'),
'scheduledDateTime' => env('SMS_QUICKSMS_SCHEDULED_DATE_TIME'),
],
RedmoItSms::class => [
'sender_id' => env('SMS_REDMOIT_SENDER_ID', ''),
'api_token' => env('SMS_REDMOIT_API_TOKEN', ''),
Expand Down
85 changes: 85 additions & 0 deletions src/Provider/QuickSms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/*
* Last Modified: 26/10/23, 10:40 PM
* Copyright (c) 2023
* -created by Ariful Islam
* -All Rights Preserved By
* -If you have any query then knock me at
* arif98741@gmail.com
* See my profile @ https://github.com/arif98741
*/

namespace Xenon\LaravelBDSms\Provider;

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

class QuickSms extends AbstractProvider
{
/**
* QuickSms constructor.
* @param Sender $sender
*/
public function __construct(Sender $sender)
{
$this->senderObject = $sender;
}

/**
* Send Request To Api and Send Message
* @throws RenderException
*/
public function sendRequest()
{
$mobile = $this->senderObject->getMobile();
$text = $this->senderObject->getMessage();
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();

$query = [
'api_key' => $config['api_key'],
'senderid' => $config['senderid'],
'contacts' => $mobile,
'msg' => $text,
];

if (array_key_exists('type', $config)) {
$query ['type'] = $config['type'];
}

if (array_key_exists('scheduledDateTime', $config)) {
$query ['scheduledDateTime'] = $config['scheduledDateTime'];
}

if (is_array($mobile)) {
$query['contacts'] = implode(',', $mobile);
}

$requestObject = new Request('https://server1.quicksms.xyz/smsapi', $query, $queue);
$requestObject->setContentTypeJson(true);

$response = $requestObject->post();
if ($queue) {
return true;
}
$body = $response->getBody();
$smsResult = $body->getContents();
$data['number'] = $mobile;
$data['message'] = $text;
return $this->generateReport($smsResult, $data)->getContent();
}

/**
* @throws RenderException
*/
public function errorException(): void
{
if (!array_key_exists('api_key', $this->senderObject->getConfig())) {
throw new RenderException('api_key key is absent in configuration');
}
if (!array_key_exists('senderid', $this->senderObject->getConfig())) {
throw new RenderException('senderid key is absent in configuration');
}
}
}

0 comments on commit f4d0de3

Please sign in to comment.