Skip to content

Commit

Permalink
Use parameter config if given
Browse files Browse the repository at this point in the history
  • Loading branch information
datashaman committed Mar 4, 2024
1 parent 9308b57 commit 2fac1a6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ServiceBusSQSChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@

use Aws\Sqs\SqsClient;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Log;

class ServiceBusSQSChannel
{
protected SqsClient $sqs;

public function __construct()
public function __construct(array $config = [])
{
$this->config = $config ?: config('services.service_bus');

$this->sqs = new SqsClient([
'region' => config('services.service_bus.sqs.region'),
'region' => Arr::get($this->config, 'sqs.region'),
'version' => 'latest',
'credentials' => [
'key' => config('services.service_bus.sqs.key'),
'secret' => config('services.service_bus.sqs.secret'),
'key' => Arr::get($this->config, 'sqs.key'),
'secret' => Arr::get($this->config, 'sqs.secret'),
],
]);
}
Expand All @@ -29,7 +32,7 @@ public function send($notifiable, Notification $notification)
->getParams();

$response = $this->sqs->sendMessage([
'QueueUrl' => config('services.service_bus.sqs.queue_url'),
'QueueUrl' => Arr::get($this->config, 'sqs.queue_url'),
'MessageBody' => json_encode($message),
'MessageGroupId' => $message['from'],
]);
Expand Down

0 comments on commit 2fac1a6

Please sign in to comment.