Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 5.0.0

## BC Breaks

Use PSR-7, PSR-17 and PSR-18 instead of HttpPlug.

- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setHttpClient` from `Http\Client\HttpClient` to `Psr\Http\Client\ClientInterface`
- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setRequestFactory` from `Http\Message\RequestFactory` to `Psr\Http\Message\RequestFactoryInterface`
- Change the type of the first parameter of `Akeneo\PimEnterprise\ApiClient\AkeneoPimEnterpriseClientBuilder::setStreamFactory` from `Http\Message\StreamFactory` to `Psr\Http\Message\StreamFactoryInterface`

Factory implementations are necessary as dependency.
For example, with Guzzle:

```bash
$ php composer.phar require akeneo/api-php-client-ee php-http/guzzle6-adapter:^2.0 http-interop/http-factory-guzzle:^1.0
```

# 4.0.0 (2019-02-08)

## Improvements
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"phpspec/phpspec": "^5.0",
"symfony/yaml": "^4.2",
"donatj/mock-webserver": "^2.0",
"http-interop/http-factory-guzzle": "^1.0",
"php-http/guzzle6-adapter": "^2.0"
},
"config": {
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
PHP_IDE_CONFIG: 'serverName=akeneo-client'
PHP_XDEBUG_ENABLED: 0
PHP_XDEBUG_IDE_KEY: XDEBUG_IDE_KEY
PHP_XDEBUG_REMOTE_HOST: xxx.xxx.xxx.xxx
XDEBUG_CONFIG: 'remote_host=xxx.xxx.xxx.xxx'
user: docker
volumes:
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">

Expand Down
49 changes: 19 additions & 30 deletions src/AkeneoPimEnterpriseClientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityAttributeOptionApi;
use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityMediaFileApi;
use Akeneo\PimEnterprise\ApiClient\Api\ReferenceEntityRecordApi;
use Http\Client\HttpClient as Client;
use Http\Discovery\HttpClientDiscovery;
use Http\Discovery\MessageFactoryDiscovery;
use Http\Discovery\StreamFactoryDiscovery;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Http\Message\RequestFactory;
use Http\Message\StreamFactory;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;

/**
* Builder of the class AkeneoPimEnterpriseClient.
Expand All @@ -62,7 +63,7 @@ class AkeneoPimEnterpriseClientBuilder
/** @var string */
protected $baseUri;

/** @var Client */
/** @var ClientInterface */
protected $httpClient;

/** @var RequestFactory */
Expand All @@ -83,41 +84,29 @@ public function __construct(string $baseUri)
}

/**
* Allows to directly set a client instead of using HttpClientDiscovery::find()
*
* @param Client $httpClient
*
* @return AkeneoPimClientBuilder
* Allows to directly set a client instead of using the discovery
*/
public function setHttpClient(Client $httpClient): self
public function setHttpClient(ClientInterface $httpClient): self
{
$this->httpClient = $httpClient;

return $this;
}

/**
* Allows to directly set a request factory instead of using MessageFactoryDiscovery::find()
*
* @param RequestFactory $requestFactory
*
* @return AkeneoPimClientBuilder
* Allows to directly set a request factory instead of using the discovery
*/
public function setRequestFactory(RequestFactory $requestFactory): self
public function setRequestFactory(RequestFactoryInterface $requestFactory): self
{
$this->requestFactory = $requestFactory;

return $this;
}

/**
* Allows to directly set a stream factory instead of using StreamFactoryDiscovery::find()
*
* @param StreamFactory $streamFactory
*
* @return AkeneoPimClientBuilder
* Allows to directly set a stream factory instead of using the discovery
*/
public function setStreamFactory(StreamFactory $streamFactory): self
public function setStreamFactory(StreamFactoryInterface $streamFactory): self
{
$this->streamFactory = $streamFactory;

Expand Down Expand Up @@ -224,7 +213,7 @@ protected function setUp(Authentication $authentication): array
{
$uriGenerator = new UriGenerator($this->baseUri);

$httpClient = new HttpClient($this->getHttpClient(), $this->getRequestFactory());
$httpClient = new HttpClient($this->getHttpClient(), $this->getRequestFactory(), $this->getStreamFactory());
$authenticationApi = new AuthenticationApi($httpClient, $uriGenerator);
$authenticatedHttpClient = new AuthenticatedHttpClient($httpClient, $authenticationApi, $authentication);

Expand All @@ -244,28 +233,28 @@ protected function setUp(Authentication $authentication): array
return [$resourceClient, $pageFactory, $cursorFactory, $fileSystem];
}

private function getHttpClient(): Client
private function getHttpClient(): ClientInterface
{
if (null === $this->httpClient) {
$this->httpClient = HttpClientDiscovery::find();
$this->httpClient = Psr18ClientDiscovery::find();
}

return $this->httpClient;
}

private function getRequestFactory(): RequestFactory
private function getRequestFactory(): RequestFactoryInterface
{
if (null === $this->requestFactory) {
$this->requestFactory = MessageFactoryDiscovery::find();
$this->requestFactory = Psr17FactoryDiscovery::findRequestFactory();
}

return $this->requestFactory;
}

private function getStreamFactory(): StreamFactory
private function getStreamFactory(): StreamFactoryInterface
{
if (null === $this->streamFactory) {
$this->streamFactory = StreamFactoryDiscovery::find();
$this->streamFactory = Psr17FactoryDiscovery::findStreamFactory();
}

return $this->streamFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function test_upload_from_resource_file()
*/
public function test_upload_for_an_unknown_asset()
{
$filePath = realpath(__DIR__ . '/../../../fixtures/ziggy.png');
$filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png');

$this->server->setResponseOfPath(
'/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unknown_asset', 'en_US'),
Expand All @@ -123,7 +123,7 @@ public function test_upload_for_an_unknown_asset()
*/
public function test_upload_a_file_that_cannot_be_transformed_for_the_variations()
{
$filePath = realpath(__DIR__ . '/../../../fixtures/unicorn.png');
$filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png');

$this->server->setResponseOfPath(
'/'. sprintf(AssetReferenceFileApi::ASSET_REFERENCE_FILE_URI, 'unicorn', AssetReferenceFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function test_upload_from_resource_file()
*/
public function test_upload_for_an_unknown_asset()
{
$filePath = realpath(__DIR__ . '/../../../fixtures/ziggy.png');
$filePath = realpath(__DIR__ . '/../../fixtures/ziggy.png');

$this->server->setResponseOfPath(
'/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unknown_asset', 'ecommerce', 'en_US'),
Expand All @@ -124,7 +124,7 @@ public function test_upload_for_an_unknown_asset()
*/
public function test_upload_for_an_asset_that_should_be_localizable()
{
$filePath = realpath(__DIR__ . '/../../../fixtures/unicorn.png');
$filePath = realpath(__DIR__ . '/../../fixtures/unicorn.png');

$this->server->setResponseOfPath(
'/'. sprintf(AssetVariationFileApi::ASSET_VARIATION_FILE_URI, 'unicorn', 'ecommerce', AssetVariationFileApi::NOT_LOCALIZABLE_ASSET_LOCALE_CODE),
Expand Down