Skip to content

Commit

Permalink
fix: removed duplicate log insert error
Browse files Browse the repository at this point in the history
  • Loading branch information
arif98741 committed May 24, 2024
1 parent 945fa3d commit 07c740d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/Job/SendSmsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
use JsonException;
use Psr\Http\Message\ResponseInterface;
use Xenon\LaravelBDSms\Facades\Logger;

class SendSmsJob implements ShouldQueue
Expand Down Expand Up @@ -64,10 +63,11 @@ public function handle()
{

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

$this->getMethodHandler();
}

/**
Expand Down
46 changes: 24 additions & 22 deletions src/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

use Exception;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use JsonException;
use Xenon\LaravelBDSms\Facades\Logger;
use Xenon\LaravelBDSms\Handler\ParameterException;
use Xenon\LaravelBDSms\Handler\RenderException;
Expand Down Expand Up @@ -70,17 +72,27 @@ class Sender
private $queueName = 'default';


/*
|------------------------------------------------------------------------------------------
| Instance of Sender class
|------------------------------------------------------------------------------------------
| This is the static method that controls the access to the singleton instance. On the first run,
| it creates a singleton object and places it into the static field.
| On subsequent runs, it returns the client existing object stored in the static field. This implementation
| lets you subclass the Singleton class while keeping just one instance of each subclass around.
*/
/**
* This is the static method that controls the access to the singleton
* instance. On the first run, it creates a singleton object and places it
* into the static field. On subsequent runs, it returns the client existing
* object stored in the static field.
*
* This implementation lets you subclass the Singleton class while keeping
* just one instance of each subclass around.
* @throws RenderException
*/
public static function getInstance(): Sender
{
if (!File::exists(config_path('sms.php'))) {
throw new RenderException("missing config/sms.php. Be sure to run
'php artisan vendor:publish --provider=Xenon\LaravelBDSms\LaravelBDSmsServiceProvider'
and also set provider using setProvider() method. Set default provider from config/sms.php if
you use Xenon\LaravelBDSms\Facades\SMS::shoot() facade. You can also clear your cache");
}

if (!isset(self::$instance)) {
self::$instance = new self;
}
Expand Down Expand Up @@ -196,6 +208,7 @@ public function getQueue()
* @param array $headers
* @param bool $contentTypeJson
* @return Sender
* @throws RenderException
* @since v1.0.55.0-beta
*/
public function setHeaders(array $headers, bool $contentTypeJson = true): Sender
Expand All @@ -208,7 +221,6 @@ public function setHeaders(array $headers, bool $contentTypeJson = true): Sender
/**
* Send Message Finally
* @throws ParameterException
* @throws \JsonException
* @since v1.0.5
*/
public function send()
Expand Down Expand Up @@ -253,6 +265,7 @@ public function getMobile()
/**
* @param mixed $mobile
* @return Sender
* @throws RenderException
* @since v1.0.0
*/
public function setMobile($mobile): Sender
Expand All @@ -273,6 +286,7 @@ public function getMessage()
/**
* @param mixed $message
* @return Sender
* @throws RenderException
* @since v1.0.0
*/
public function setMessage($message = ''): Sender
Expand All @@ -285,6 +299,7 @@ public function setMessage($message = ''): Sender
/**
* @param string $url
* @return $this
* @throws RenderException
*/
public function setUrl(string $url)
{
Expand Down Expand Up @@ -313,12 +328,6 @@ public function setProvider($providerClass): Sender

try {

if ($providerClass === null) {
throw new RenderException("Provider is empty. Be sure to run 'php artisan vendor:publish --provider=Xenon\LaravelBDSms\LaravelBDSmsServiceProvider'
and also set provider using setProvider() method. Set default provider from config/sms.php
if you use Xenon\LaravelBDSms\Facades\SMS::shoot() facade. You can also clear your cache");
}

if (!class_exists($providerClass)) {
throw new RenderException("Sms Gateway Provider '$providerClass' not found. ");
}
Expand All @@ -339,18 +348,11 @@ public function setProvider($providerClass): Sender
* @param $config
* @param $response
* @return void
* @throws \JsonException
* @throws JsonException
* @throws RenderException
*/
private function logGenerate($config, $response): void
{
if ($config == null)
{
throw new RenderException("Provider is empty. Be sure to run 'php artisan vendor:publish --provider=Xenon\LaravelBDSms\LaravelBDSmsServiceProvider'
and also set provider using setProvider() method. Set default provider from config/sms.php if
you use Xenon\LaravelBDSms\Facades\SMS::shoot() facade. You can also clear your cache");

}

if ($config['sms_log']) {

Expand Down

0 comments on commit 07c740d

Please sign in to comment.