Added env var SMS_GATEWAY_API_KEY

This commit is contained in:
Marko Jovanovic 2025-10-02 16:18:00 +02:00
parent 9610fe647d
commit 986fa1d901
2 changed files with 10 additions and 4 deletions

View File

@ -4,13 +4,14 @@
# Put parameters here that don't need to change on each machine where the app is deployed # Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration # https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters: parameters:
app.sms_gateway_api_key: '%env(SMS_GATEWAY_API_KEY)%'
services: services:
# default configuration for services in *this* file # default configuration for services in *this* file
_defaults: _defaults:
autowire: true # Automatically injects dependencies in your services. autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
string $sms_gateway_api_key: '%env(SMS_GATEWAY_API_KEY)%'
# makes classes in src/ available to be used as services # makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name # this creates a service per class whose id is the fully-qualified class name

View File

@ -28,11 +28,16 @@ class ContactUncontactedCommand extends Command
private EntityManagerInterface $entityManager; private EntityManagerInterface $entityManager;
private HttpClientInterface $httpClient; private HttpClientInterface $httpClient;
public function __construct(EntityManagerInterface $entityManager, HttpClientInterface $httpClient) private string $sms_gateway_api_key;
public function __construct(EntityManagerInterface $entityManager,
HttpClientInterface $httpClient,
string $sms_gateway_api_key)
{ {
parent::__construct(); parent::__construct();
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->httpClient = $httpClient; $this->httpClient = $httpClient;
$this->sms_gateway_api_key = $sms_gateway_api_key;
} }
protected function configure(): void protected function configure(): void
@ -72,9 +77,9 @@ class ContactUncontactedCommand extends Command
try { try {
$response = $this->httpClient->request('GET', self::$apiEndpoint, [ $response = $this->httpClient->request('GET', self::$apiEndpoint, [
'query' => [ 'query' => [
'producttoken' => $this->getParameter('SMS_GATEWAY_API_KEY'), 'producttoken' => $this->sms_gateway_api_key,
'body' => 'Bitte starten Sie die Umfrage jetzt: https://umfragetool.ukbonn.de/login?id=QMBEFR_TEST Ihr UKB.', 'body' => 'Bitte starten Sie die Umfrage jetzt: https://umfragetool.ukbonn.de/login?id=QMBEFR_TEST Ihr UKB.',
'to' => '004917672121270', 'to' => $phoneNumber,
'from' => 'UKB', 'from' => 'UKB',
'reference' => 'Test-Reference' 'reference' => 'Test-Reference'
] ]