eventbusSyncRepository = $eventbusSyncRepository; $this->syncApiClient = $syncApiClient; } /** * Authorizes and cache job ids * * @param string $jobId * * @return array|bool */ public function authorizeCall($jobId) { // Check if the job already exists $job = $this->eventbusSyncRepository->findJobById($jobId); if ($job) { return true; } // Check the jobId validity to avoid Denial Of Service $jobValidationResponse = $this->syncApiClient->validateJobId($jobId); if (!is_array($jobValidationResponse) || (int) $jobValidationResponse['httpCode'] !== 201) { return false; } // Cache the valid jobId return $this->eventbusSyncRepository->insertJob($jobId, date(DATE_ATOM)); } }