module = $module; $this->jwt = $psAccountsAdapterService->getOrRefreshToken(); $this->syncApiUrl = $syncApiUrl; } /** * @see https://docs.guzzlephp.org/en/stable/quickstart.html- * * @param int $timeout * * @return HttpClientInterface */ private function getClient($timeout = Config::SYNC_API_MAX_TIMEOUT) { return (new ClientFactory())->getClient([ 'allow_redirects' => true, 'connect_timeout' => 10, 'http_errors' => false, 'timeout' => $timeout, ]); } /** * @param string $jobId * * @return array|bool */ public function validateJobId($jobId) { $response = $this->getClient()->sendRequest( new Request( 'GET', $this->syncApiUrl . '/job/' . $jobId, [ 'Accept' => 'application/json', 'Authorization' => 'Bearer ' . $this->jwt, 'User-Agent' => 'ps-eventbus/' . $this->module->version, ] ) ); return [ 'status' => substr((string) $response->getStatusCode(), 0, 1) === '2', 'httpCode' => $response->getStatusCode(), ]; } }