<?php
declare(strict_types=1);
namespace App\Component\ExternalIntegration\Integration\Tigris;
use App\Component\ExternalIntegration\Integration\FetchStorageVacanciesEvent;
use App\Component\ExternalIntegration\Integration\Tigris\Client\Client;
use App\Component\ExternalIntegration\Integration\Tigris\Configuration\ConfigEnum;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FetchExternalVacanciesSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly Client $client
) {
}
/** @return array<string, string> */
public static function getSubscribedEvents(): array
{
return [
FetchStorageVacanciesEvent::class => 'fetch',
];
}
public function fetch(FetchStorageVacanciesEvent $event): void
{
if (ConfigEnum::EXTERNAL_INTEGRATION_REFERENCE->value !== $event->getExternalIntegration()) {
return;
}
$event->setVacancies($this->client->getVacanciesForStorage(3));
}
}