call($method, $url, $options); $data = $response->toArray(); } catch (Exception $exception) { $data = null; } return $data; } /** * [This method is used to let return full data response content from request, instead of throw an exception, in order to display error returned by other modules with a status code error] * * @param string $method [description] * @param string $url [description] * @param array $options [description] * * @return array [description] */ public function dataProvider(string $method, string $url, array $options): array { $options['headers']['x-auth-provider'] = true; $response = $this->call($method, $url, $options); $content = $response->getContent(false); return $content ? json_decode($content, true) : []; } /** * @param string $method [description] * @param string $url [description] * @param array $options [description] * * @throws TransportExceptionInterface * * @return int|null [description] */ public function status(string $method, string $url, array $options): ?int { try { $options['headers']['x-auth-provider'] = true; $response = $this->call($method, $url, $options); $status = $response->getStatusCode(); } catch (Exception $exception) { $status = null; } return $status; } /** * @param string $method [description] * @param string $url [description] * @param array $options [description] * * @throws TransportExceptionInterface * * @return ResponseInterface [description] */ private function call(string $method, string $url, array $options): ResponseInterface { $httpClient = HttpClient::create(); return $httpClient->request($method, $url, $options); } }