Skip to content

Commit

Permalink
Merge pull request #69 from arif98741/temp_queue_process
Browse files Browse the repository at this point in the history
Minor refactor and some property type declaration added
  • Loading branch information
arif98741 authored Mar 16, 2024
2 parents fcd3bca + 5d854c7 commit a2469d6
Show file tree
Hide file tree
Showing 36 changed files with 127 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ src/Test
vendor/
.phpintel
*.lock
composer.lock
2 changes: 1 addition & 1 deletion src/Handler/RenderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function report()
* Render the exception into an HTTP response.
*
* @param Request $request
* @return Response
* @return void
*/
public function render(Request $request)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static function getCommaSeperatedNumbers(array $numbers)
* @since v1.0.12
* @version v1.0.43.1-dev
*/
public static function checkMobileNumberPrefixExistence($mobile)
public static function checkMobileNumberPrefixExistence(string $mobile)
{
$prefix = substr($mobile, 0, 3);
if ($prefix === '880') {
Expand Down
17 changes: 8 additions & 9 deletions src/Job/SendSmsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SendSmsJob implements ShouldQueue
*
* @var int
*/
public $backoffSeconds=60;
public $backoffSeconds = 60;


/**
Expand All @@ -46,29 +46,28 @@ class SendSmsJob implements ShouldQueue
public function __construct(array $jobDetails)
{
$this->jobDetails = $jobDetails;
if (isset($jobDetails['tries']) && is_integer($jobDetails['tries'])){
$this->tries=$jobDetails['tries'];
if (isset($jobDetails['tries']) && is_integer($jobDetails['tries'])) {
$this->tries = $jobDetails['tries'];
}
if (isset($jobDetails['backoff']) && is_integer($jobDetails['backoff'])){
$this->backoffSeconds=$jobDetails['backoff'];
if (isset($jobDetails['backoff']) && is_integer($jobDetails['backoff'])) {
$this->backoffSeconds = $jobDetails['backoff'];
}
}

/**
* Execute the job.
*
* @return ResponseInterface|null
* @return void
* @throws GuzzleException|JsonException
*/
public function handle()
{

if ($this->jobDetails['method'] == 'post') {
return $this->postMethodHandler();

$this->postMethodHandler();
}

return $this->getMethodHandler();
$this->getMethodHandler();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Log/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function viewLastLog()
}

/**
* @return Collection|LaravelBDSmsLog[]
* @return Collection
* @since v1.0.35
* @version v1.0.35
*/
Expand Down
1 change: 1 addition & 0 deletions src/Provider/Adn.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function sendRequest()
$requestObject = new Request($this->apiEndpoint, $query, $queue, [
'Accept' => 'application/json'
], $queueName,$tries,$backoff);

$requestObject->setFormParams([
'api_key' => $config['api_key'],
'type' => $config['type'],
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/Alpha.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
class Alpha extends AbstractProvider
{
private $apiEndpoint ='https://api.sms.net.bd/sendsms';

/**
* Alpha SMS constructor.
* @param Sender $sender
Expand Down Expand Up @@ -70,7 +72,7 @@ public function sendRequest()
$query['to'] = implode(',', $mobile);
}

$requestObject = new Request('https://api.sms.net.bd/sendsms', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);

$response = $requestObject->post();
if ($queue) {
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/DnsBd.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function generateReport($result, $data): JsonResponse
}

/**
* @return mixed
* @return void
*/
public function errorException()
{
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/GreenWeb.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class GreenWeb extends AbstractProvider
{
private string $apiEndpoint = 'https://api.greenweb.com.bd/api.php?json';

/**
* GreenWeb constructor.
* @param Sender $sender
Expand Down Expand Up @@ -45,7 +47,7 @@ public function sendRequest()
'message' => $text,
];

$requestObject = new Request('https://api.greenweb.com.bd/api.php?json', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/Lpeek.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class Lpeek extends AbstractProvider
{
private string $apiEndpoint = 'https://sms.lpeek.com/API/sendSMS';

/**
* Lpeek constructor.
* @param Sender $sender
Expand Down Expand Up @@ -58,7 +60,7 @@ public function sendRequest()
],
];

$requestObject = new Request('https://sms.lpeek.com/API/sendSMS', $data, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $data, $queue, [], $queueName,$tries,$backoff);
$requestObject->setContentTypeJson(true);
$response = $requestObject->post();
if ($queue) {
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/MDL.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class MDL extends AbstractProvider
{
private string $apiEndpoint = 'http://premium.mdlsms.com/smsapi';

/**
* MDL constructor.
* @param Sender $sender
Expand Down Expand Up @@ -47,7 +49,7 @@ public function sendRequest()
'msg' => $text,
];

$requestObject = new Request('http://premium.mdlsms.com/smsapi', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/Metronet.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class Metronet extends AbstractProvider
{
private string $apiEndpoint = '202.164.208.212/smsnet/bulk/api';

/**
* MentroNet constructor.
* @param Sender $sender
Expand Down Expand Up @@ -51,7 +53,7 @@ public function sendRequest()
'message' => $text,
];

$requestObject = new Request('202.164.208.212/smsnet/bulk/api', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/MimSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
class MimSms extends AbstractProvider
{
private string $apiEndpoint = 'https://esms.mimsms.com/smsapi';

/**
* Mimsms constructor.
* @param Sender $sender
Expand Down Expand Up @@ -62,7 +64,7 @@ public function sendRequest()
'msg' => $text,
];

$requestObject = new Request('https://esms.mimsms.com/smsapi', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
8 changes: 5 additions & 3 deletions src/Provider/Mobireach.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class Mobireach extends AbstractProvider
{
private string $apiEndpoint = 'https://api.mobireach.com.bd/SendTextMessage';

/**
* Mobireach constructor.
* @param Sender $sender
Expand All @@ -41,8 +43,8 @@ public function sendRequest()
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries=$this->senderObject->getTries();
$backoff=$this->senderObject->getBackoff();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();

$query = [
'Username' => $config['Username'],
Expand All @@ -52,7 +54,7 @@ public function sendRequest()
'Message' => $text,
];

$requestObject = new Request('https://api.mobireach.com.bd/SendTextMessage', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
8 changes: 5 additions & 3 deletions src/Provider/Mobishasra.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class Mobishasra extends AbstractProvider
{
private string $apiEndpoint = 'https://mshastra.com/sendurlcomma.aspx';

/**
* BulkSmsBD constructor.
* @param Sender $sender
Expand All @@ -39,8 +41,8 @@ public function sendRequest()
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries=$this->senderObject->getTries();
$backoff=$this->senderObject->getBackoff();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();
$query = [
'user' => $config['user'],
'pwd' => $config['pwd'],
Expand All @@ -50,7 +52,7 @@ public function sendRequest()
'priority' => 'High',
'CountryCode' => 'ALL',
];
$requestObject = new Request('https://mshastra.com/sendurlcomma.aspx', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff);

$response = $requestObject->get();
if ($queue) {
Expand Down
10 changes: 6 additions & 4 deletions src/Provider/Muthofun.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class Muthofun extends AbstractProvider
{
private string $apiEndpoint = 'https://sysadmin.muthobarta.com/api/v1/send-sms';

/**
* Muthofun constructor.
* @param Sender $sender
Expand All @@ -37,8 +39,8 @@ public function sendRequest()
$config = $this->senderObject->getConfig();
$queue = $this->senderObject->getQueue();
$queueName = $this->senderObject->getQueueName();
$tries=$this->senderObject->getTries();
$backoff=$this->senderObject->getBackoff();
$tries = $this->senderObject->getTries();
$backoff = $this->senderObject->getBackoff();

$query = [
'sender_id' => $config['sender_id'],
Expand All @@ -48,10 +50,10 @@ public function sendRequest()
];

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

$requestObject = new Request('https://sysadmin.muthobarta.com/api/v1/send-sms', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName, $tries, $backoff);

if (!str_starts_with($config['api_key'], "Token ")) {
$config['api_key'] = "Token " . $config['api_key'];
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/NovocomBd.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

class NovocomBd extends AbstractProvider
{
private string $apiEndpoint = 'https://sms.novocom-bd.com/api/v2/SendSMS';

/**
* Novocom constructor.
* @param Sender $sender
Expand Down Expand Up @@ -53,7 +55,7 @@ public function sendRequest()
'Is_Unicode' => true,
];

$requestObject = new Request('https://sms.novocom-bd.com/api/v2/SendSMS', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$response = $requestObject->get();
if ($queue) {
return true;
Expand Down
8 changes: 5 additions & 3 deletions src/Provider/Onnorokom.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
*/
class Onnorokom extends AbstractProvider
{
private string $apiEndpoint = "https://api2.onnorokomsms.com/sendsms.asmx?wsdl";

/**
* Onnorokom constructor.
* @param Sender $sender
Expand All @@ -33,7 +35,7 @@ public function __construct(Sender $sender)

/**
* Send Request To Server
* @throws RenderException
* @throws RenderException|\SoapFault
*/
public function sendRequest()
{
Expand All @@ -42,11 +44,11 @@ public function sendRequest()
'message' => $this->senderObject->getMessage()
];

if (!extension_loaded('soap')) {
if (!extension_loaded('soap')) { //check if soap extension is enabled for onnorokom provider
throw new RenderException("Soap extension is not enabled in your server. Please install/enable it before using onnorokom sms client");
}

$soapClient = new SoapClient("https://api2.onnorokomsms.com/sendsms.asmx?wsdl");
$soapClient = new SoapClient($this->apiEndpoint);
$config = $this->senderObject->getConfig();
$mobile = $this->senderObject->getMobile();
$message = $this->senderObject->getMessage();
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/QuickSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

class QuickSms extends AbstractProvider
{
private string $apiEndpoint = 'https://server1.quicksms.xyz/smsapi';

/**
* QuickSms constructor.
* @param Sender $sender
Expand Down Expand Up @@ -59,7 +61,7 @@ public function sendRequest()
$query['contacts'] = implode(',', $mobile);
}

$requestObject = new Request('https://server1.quicksms.xyz/smsapi', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$requestObject->setContentTypeJson(true);

$response = $requestObject->post();
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/RedmoItSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

class RedmoItSms extends AbstractProvider
{
private string $apiEndpoint = 'https://sms.redmoit.com/api/v3/sms/send';

/**
* DianaHost constructor.
* @param Sender $sender
Expand Down Expand Up @@ -52,7 +54,7 @@ public function sendRequest()
'Content-Type' => 'application/json'
];

$requestObject = new Request('https://sms.redmoit.com/api/v3/sms/send', $query, $queue, [], $queueName,$tries,$backoff);
$requestObject = new Request($this->apiEndpoint, $query, $queue, [], $queueName,$tries,$backoff);
$requestObject->setHeaders($headers)->setContentTypeJson(true);
$response = $requestObject->post();
if ($queue) {
Expand Down
Loading

0 comments on commit a2469d6

Please sign in to comment.