diff --git a/Infrastructure/Service/Rest/Client.php b/Infrastructure/Service/Rest/Client.php deleted file mode 100644 index 25e213b..0000000 --- a/Infrastructure/Service/Rest/Client.php +++ /dev/null @@ -1,139 +0,0 @@ -httpClient = $platformHttpClient; - $this->jwtTokenManager = $jwtTokenManager; - $this->administratorRepository = $administratorRepository; - - $privateAdmin = $this->administratorRepository->getInnerGlobalAdmin(); - $this->jwtToken = $this->jwtTokenManager->create( - $privateAdmin - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function get(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'GET', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function post(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'POST', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function put(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'PUT', - $uri, - $options - ); - } - - /** - * @param string $uri - * @param array $options - * @return ResponseInterface - */ - public function delete(string $uri, array $options = []) - { - $options = $this->appendAuthHeaders($options); - - return $this->request( - 'DELETE', - $uri, - $options - ); - } - - /** - * - * @param string $method HTTP method. - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. - * - * @return ResponseInterface - * @throws \RuntimeException - */ - protected function request($method, $uri = '', array $options = []) - { - try { - return $this->httpClient->request( - $method, - $uri, - $options - ); - } catch (\Exception $e) { - throw new \RuntimeException( - $e->getMessage(), - $e->getCode(), - $e - ); - } - } - - /** - * @return array - * - * @psalm-return array{"headers":empty, headers:array{Authorization:string}} - */ - private function appendAuthHeaders(array $options): array - { - if (!array_key_exists('headers', $options)) { - $options['headers'] = []; - } - $options['headers']['Authorization'] = 'Bearer ' . $this->jwtToken; - - return $options; - } -} diff --git a/Infrastructure/Service/Rest/FakeClient.php b/Infrastructure/Service/Rest/FakeClient.php deleted file mode 100644 index fd26e33..0000000 --- a/Infrastructure/Service/Rest/FakeClient.php +++ /dev/null @@ -1,47 +0,0 @@ -