|
...
|
...
|
@@ -16,17 +16,31 @@ use Lackoxygen\TopWarehouse\Utils\SignatureUtil; |
|
|
|
|
|
|
|
class Client implements ClientInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var RequestInterface
|
|
|
|
*/
|
|
|
|
protected $request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var guzzleClient
|
|
|
|
*/
|
|
|
|
protected $guzzleClient;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array|null
|
|
|
|
*/
|
|
|
|
protected $config;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Client constructor.
|
|
|
|
*
|
|
|
|
* @param RequestInterface $request
|
|
|
|
*/
|
|
|
|
protected function __construct(RequestInterface $request)
|
|
|
|
{
|
|
|
|
$this->request = $request();
|
|
|
|
|
|
|
|
$this->config = config(TopWarehouseServiceProvider::CONFIG_NAME);
|
|
|
|
$this->config = config('top-warehouse');
|
|
|
|
|
|
|
|
$clientOption = \Arr::get($this->config, 'options.client', []);
|
|
|
|
|
|
...
|
...
|
@@ -34,9 +48,11 @@ class Client implements ClientInterface |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @param RequestInterface $request
|
|
|
|
*
|
|
|
|
* @return ClientInterface
|
|
|
|
*/
|
|
|
|
public static function make(RequestInterface $request): ClientInterface
|
|
|
|
protected static function make(RequestInterface $request): ClientInterface
|
|
|
|
{
|
|
|
|
return new static($request);
|
|
|
|
}
|
|
...
|
...
|
@@ -44,10 +60,17 @@ class Client implements ClientInterface |
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public static function request(RequestInterface $request): ResponseInterface
|
|
|
|
{
|
|
|
|
return self::make($request)->send();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function send(): ResponseInterface
|
|
|
|
{
|
|
|
|
$retry = Arr::get($this->config, 'options.retry', 1);
|
|
|
|
|
|
|
|
try {
|
|
|
|
return retry($retry, function ($attempt) {
|
|
|
|
return $this->execute($attempt);
|
|
...
|
...
|
@@ -59,7 +82,6 @@ class Client implements ClientInterface |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $attempt
|
|
|
|
*
|
...
|
...
|
|