Skip to content

Commit 6a03940

Browse files
committed
added Http Client Config options
1 parent 65968a5 commit 6a03940

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

src/AbstractApi.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,19 @@ abstract class AbstractApi
4747
*/
4848
protected $response = Response::class;
4949

50+
/**
51+
* @var array
52+
*/
53+
protected $config = [];
54+
5055
/**
5156
* AbstractApi constructor.
5257
* @param Request|null $request
5358
*/
5459
public function __construct(Request $request = null)
5560
{
5661
if (!$request) {
57-
$this->request = new Request(new GuzzleClient());
62+
$this->request = new Request(new GuzzleClient($this->config));
5863
}
5964

6065
$this->setBaseURL($this->getBaseURL());
@@ -66,6 +71,26 @@ public function __construct(Request $request = null)
6671
*/
6772
abstract protected function getBaseURL();
6873

74+
/**
75+
* Get client configs
76+
*
77+
* @return array
78+
*/
79+
public function getConfig()
80+
{
81+
return $this->config;
82+
}
83+
84+
/**
85+
* Set client config
86+
*
87+
* @param $config
88+
*/
89+
public function setConfig($config)
90+
{
91+
$this->config = $config;
92+
}
93+
6994
/**
7095
* Get request instance
7196
*

src/Http/Clients/AbstractClient.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99

1010
abstract class AbstractClient
1111
{
12+
13+
/**
14+
* @var array
15+
*/
16+
protected $config;
17+
18+
public function __construct($config = [])
19+
{
20+
$this->config = $config;
21+
}
1222
/**
1323
* @return string
1424
*/

src/Http/Clients/GuzzleClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getUriClass()
4242
*/
4343
public function send(...$args)
4444
{
45-
$client = new Client();
45+
$client = new Client($this->config);
4646

4747
return $client->send(... $args);
4848
}

0 commit comments

Comments
 (0)