protected function get($uri, array $options = []) { try { $response = $this->httpClient->get($uri, $options); return $response->getBody()->getContents(); } catch (RequestException $exception) { throw ExceptionWrapper::wrap($exception, $this->serializer); } }
/** * @param string $url * * @param array $options * * @return \GuzzleHttp\Psr7\Response */ public function downloadAttachment($url, $options = []) { try { $url = str_replace(" ", "%20", $url); return $this->httpClient->attachmentRequest($url, $options); } catch (RequestException $exception) { throw ExceptionWrapper::wrap($exception, $this->serializer); } }
/** * @test */ public function wrap_Non4xxException_ReturnsApiException() { $request = $this->createMock(RequestInterface::class); $response = $this->createMock(ResponseInterface::class); $response->expects($this->once())->method('getStatusCode')->willReturn(500); $requestException = new RequestException('Error 500', $request, $response); $this->assertEquals(new ApiException('Error 500', 500, $requestException), ExceptionWrapper::wrap($requestException, $this->getSerializer())); }