-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
192 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
parameters: | ||
level: 7 | ||
checkMissingIterableValueType: false | ||
checkGenericClassInNonGenericObjectType: false | ||
ignoreErrors: | ||
- '#Parameter \#1 \$httpClient of method Akeneo\\Pim\\ApiClient\\AkeneoPimClientBuilder::setHttpClient\(\) expects Akeneo\\Pim\\ApiClient\\Client\\ClientInterface, Psr\\Http\\Client\\ClientInterface given\.#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...Eco/Service/AkeneoPim/Dependencies/External/Api/Adapter/HttpClient/AbstractHttpClient.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\HttpClient; | ||
|
||
use GuzzleHttp\Client as GuzzleHttpClient; | ||
use GuzzleHttp\ClientInterface; | ||
use GuzzleHttp\HandlerStack; | ||
use GuzzleHttp\Middleware; | ||
use GuzzleHttp\Utils; | ||
use Http\Promise\Promise as HttpPromise; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
use function GuzzleHttp\choose_handler; | ||
|
||
abstract class AbstractHttpClient | ||
{ | ||
/** | ||
* @var \GuzzleHttp\ClientInterface | ||
*/ | ||
protected $client; | ||
|
||
public function __construct() | ||
{ | ||
$this->client = $this->buildClient(); | ||
} | ||
|
||
/** | ||
* @param \Psr\Http\Message\RequestInterface $request | ||
* | ||
* @return \Psr\Http\Message\ResponseInterface | ||
*/ | ||
public function sendRequest(RequestInterface $request): ResponseInterface | ||
{ | ||
return $this->client->send($request); | ||
} | ||
|
||
/** | ||
* @param \Psr\Http\Message\RequestInterface $request | ||
* | ||
* @return \Http\Promise\Promise | ||
*/ | ||
public function sendAsyncRequest(RequestInterface $request): HttpPromise | ||
{ | ||
$promise = $this->client->sendAsync($request); | ||
|
||
return new Promise($promise, $request); | ||
} | ||
|
||
/** | ||
* @return \GuzzleHttp\ClientInterface | ||
*/ | ||
protected function buildClient(): ClientInterface | ||
{ | ||
$handlerStack = $this->createHandlerStack(); | ||
$handlerStack->push(Middleware::prepareBody(), 'prepare_body'); | ||
|
||
return new GuzzleHttpClient(['handler' => $handlerStack]); | ||
} | ||
|
||
/** | ||
* @return \GuzzleHttp\HandlerStack | ||
*/ | ||
protected function createHandlerStack(): HandlerStack | ||
{ | ||
if (method_exists(Utils::class, 'chooseHandler')) { | ||
return new HandlerStack(Utils::chooseHandler()); | ||
} | ||
|
||
return new HandlerStack(choose_handler()); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...erEco/Service/AkeneoPim/Dependencies/External/Api/Adapter/HttpClient/AkeneoHttpClient.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\HttpClient; | ||
|
||
use Akeneo\Pim\ApiClient\Client\ClientInterface; | ||
|
||
class AkeneoHttpClient extends AbstractHttpClient implements ClientInterface | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
...eoPim/Dependencies/External/Api/Adapter/HttpClient/Exception/UnexpectedValueException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Service\AkeneoPim\Dependencies\External\Api\Adapter\HttpClient\Exception; | ||
|
||
use Http\Client\Exception; | ||
use UnexpectedValueException as UnexpectedValueExceptionUnexpectedValueException; | ||
|
||
class UnexpectedValueException extends \UnexpectedValueException implements Exception | ||
class UnexpectedValueException extends UnexpectedValueExceptionUnexpectedValueException implements Exception | ||
{ | ||
} |
Oops, something went wrong.