diff --git a/src/ServiceBusSQSChannel.php b/src/ServiceBusSQSChannel.php index 43f0c65..89d244a 100644 --- a/src/ServiceBusSQSChannel.php +++ b/src/ServiceBusSQSChannel.php @@ -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'), ], ]); } @@ -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'], ]);