<?php
declare(strict_types=1);
namespace App\Component\ExternalIntegration\Integration\Workday;
use App\Component\ExternalIntegration\Integration\FetchStorageVacanciesEvent;
use App\Component\ExternalIntegration\Integration\Workday\Client\WorkdayClient;
use App\Component\ExternalIntegration\Integration\Workday\Configuration\ConfigEnum;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FetchExternalVacanciesSubscriber implements EventSubscriberInterface
{
public function __construct(
private readonly WorkdayClient $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));
}
}